Search in sources :

Example 1 with PyCollectionTypeImpl

use of com.jetbrains.python.psi.types.PyCollectionTypeImpl in project intellij-community by JetBrains.

the class PyListCompExpressionImpl method getType.

@Nullable
@Override
public PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key) {
    final PyExpression resultExpr = getResultExpression();
    final PyBuiltinCache cache = PyBuiltinCache.getInstance(this);
    final PyClass list = cache.getClass("list");
    if (resultExpr != null && list != null) {
        final PyType elementType = context.getType(resultExpr);
        return new PyCollectionTypeImpl(list, false, Collections.singletonList(elementType));
    }
    return cache.getListType();
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyType(com.jetbrains.python.psi.types.PyType) PyExpression(com.jetbrains.python.psi.PyExpression) PyCollectionTypeImpl(com.jetbrains.python.psi.types.PyCollectionTypeImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyClass (com.jetbrains.python.psi.PyClass)1 PyExpression (com.jetbrains.python.psi.PyExpression)1 PyCollectionTypeImpl (com.jetbrains.python.psi.types.PyCollectionTypeImpl)1 PyType (com.jetbrains.python.psi.types.PyType)1 Nullable (org.jetbrains.annotations.Nullable)1