diff --git a/python/pluginJava/src/com/intellij/python/community/plugin/java/psi/impl/PyJavaTypeProvider.java b/python/pluginJava/src/com/intellij/python/community/plugin/java/psi/impl/PyJavaTypeProvider.java index 619ef6437350..1f3ec18513c5 100644 --- a/python/pluginJava/src/com/intellij/python/community/plugin/java/psi/impl/PyJavaTypeProvider.java +++ b/python/pluginJava/src/com/intellij/python/community/plugin/java/psi/impl/PyJavaTypeProvider.java @@ -42,7 +42,7 @@ final class PyJavaTypeProvider extends PyTypeProviderBase { return Ref.create(new PyJavaMethodType((PsiMethod)referenceTarget)); } if (referenceTarget instanceof PsiField) { - return PyTypeUtil.getNotNullToRef(asPyType(((PsiField)referenceTarget).getType())); + return PyTypeUtil.notNullToRef(asPyType(((PsiField)referenceTarget).getType())); } return null; } diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyAnyType.kt b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyAnyType.kt index 1eba990f5f58..a8b244c0f0c6 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyAnyType.kt +++ b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyAnyType.kt @@ -10,6 +10,11 @@ import com.jetbrains.python.psi.resolve.PyResolveContext import com.jetbrains.python.psi.resolve.RatedResolveResult import org.jetbrains.annotations.ApiStatus +/** + * represents `typing.Any` and `Unknown`/untyped + * + * currently unused + */ @ApiStatus.Experimental class PyAnyType private constructor(override val name: String) : PyType { override fun resolveMember( diff --git a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyType.kt b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyType.kt index a3d5c9367d35..ecdf063b43e6 100644 --- a/python/python-psi-api/src/com/jetbrains/python/psi/types/PyType.kt +++ b/python/python-psi-api/src/com/jetbrains/python/psi/types/PyType.kt @@ -44,7 +44,7 @@ interface PyType { @ApiStatus.Experimental - fun getAllMembers(resolveContext: PyResolveContext): List<@JvmWildcard PyTypeMember> { + fun getAllMembers(resolveContext: PyResolveContext): List { return emptyList() } @@ -53,7 +53,7 @@ interface PyType { * There can be several members with the same name (for example, methods with @overload) */ @ApiStatus.Experimental - fun findMember(name: String, resolveContext: PyResolveContext): List<@JvmWildcard PyTypeMember> { + fun findMember(name: String, resolveContext: PyResolveContext): List { return emptyList() } diff --git a/python/python-psi-impl/src/com/jetbrains/python/PyCustomType.java b/python/python-psi-impl/src/com/jetbrains/python/PyCustomType.java index 8fda9fd4fb0f..a204b0d8130b 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/PyCustomType.java +++ b/python/python-psi-impl/src/com/jetbrains/python/PyCustomType.java @@ -326,7 +326,7 @@ public final class PyCustomType implements PyClassLikeType { } @Override - public @NotNull List findMember(@NotNull String name, @NotNull PyResolveContext resolveContext) { + public @NotNull List<@NotNull PyTypeMember> findMember(@NotNull String name, @NotNull PyResolveContext resolveContext) { for (PyClassLikeType type : myTypesToMimic) { var members = type.findMember(name, resolveContext); if (!members.isEmpty()) { diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/decorator/PyDecoratedFunctionTypeProvider.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/decorator/PyDecoratedFunctionTypeProvider.java index 31dcc660b7da..9940041d6a68 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/decorator/PyDecoratedFunctionTypeProvider.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/decorator/PyDecoratedFunctionTypeProvider.java @@ -30,7 +30,7 @@ import java.util.Collections; import java.util.List; import static com.jetbrains.python.psi.resolve.PyResolveUtil.resolveQualifiedNameInScope; -import static com.jetbrains.python.psi.types.PyTypeUtil.getNotNullToRef; +import static com.jetbrains.python.psi.types.PyTypeUtil.notNullToRef; /** * Infer type for reference of decorated {@link PyDecoratable} objects. @@ -127,7 +127,7 @@ public final class PyDecoratedFunctionTypeProvider extends PyTypeProviderBase { } // TODO Don't ignore explicit return type Any on one of the decorators - return getNotNullToRef(currentType); + return notNullToRef(currentType); } private static @Nullable PyCallableType getDecoratorType(@NotNull PyDecorator decorator, diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyDataclassTypeProvider.kt b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyDataclassTypeProvider.kt index 76308d5918c3..4104e84bf907 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyDataclassTypeProvider.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyDataclassTypeProvider.kt @@ -73,7 +73,7 @@ class PyDataclassTypeProvider : PyTypeProviderBase() { else -> null } - return result.notNullToRef + return result.notNullToRef() } override fun getParameterType(param: PyNamedParameter, func: PyFunction, context: TypeEvalContext): Ref? { diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleTypeProvider.kt b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleTypeProvider.kt index 98023d077c45..32617a03990e 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleTypeProvider.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyNamedTupleTypeProvider.kt @@ -52,7 +52,7 @@ private typealias ImmutableNTFields = Map? { - return getNamedTupleTypeForResolvedCallee(referenceTarget, context, anchor).notNullToRef + return getNamedTupleTypeForResolvedCallee(referenceTarget, context, anchor).notNullToRef() } override fun getReferenceExpressionType(referenceExpression: PyReferenceExpression, context: TypeEvalContext): PyType? { diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypedDictTypeProvider.kt b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypedDictTypeProvider.kt index 9c554e1e16c9..ea5417a405a3 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypedDictTypeProvider.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/typing/PyTypedDictTypeProvider.kt @@ -59,7 +59,7 @@ class PyTypedDictTypeProvider : PyTypeProviderBase() { is PyTargetExpression -> getTypedDictTypeForTarget(referenceTarget, context) else -> null } - return type.notNullToRef + return type.notNullToRef() } override fun prepareCalleeTypeForCall(type: PyType?, call: PyCallExpression, context: TypeEvalContext): Ref? { diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PySelfType.java b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PySelfType.java index 528456e2fe65..9be147a04f9f 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PySelfType.java +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PySelfType.java @@ -131,12 +131,12 @@ public final class PySelfType implements PyTypeParameterType, PyClassType { } @Override - public @NotNull List getAllMembers(@NotNull PyResolveContext resolveContext) { + public @NotNull List<@NotNull PyTypeMember> getAllMembers(@NotNull PyResolveContext resolveContext) { return myScopeClassType.getAllMembers(resolveContext); } @Override - public @NotNull List findMember(@NotNull String name, @NotNull PyResolveContext resolveContext) { + public @NotNull List<@NotNull PyTypeMember> findMember(@NotNull String name, @NotNull PyResolveContext resolveContext) { return myScopeClassType.findMember(name, resolveContext); } diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeUtil.kt b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeUtil.kt index 1919715567db..1c253f742183 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeUtil.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/PyTypeUtil.kt @@ -166,9 +166,9 @@ object PyTypeUtil { StreamEx.of(this) @JvmStatic - val PyType?.notNullToRef: Ref? - @Contract("null -> null; !null -> !null") - get() = if (this == null) null else Ref(this) + @Contract("null -> null; !null -> !null") + fun PyType?.notNullToRef(): Ref? = + if (this == null) null else Ref(this) /** * Returns a collector that combines a stream of `Ref` back into a single `Ref` diff --git a/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiTypeProvider.java b/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiTypeProvider.java index 225f025da4e2..7324ee0d59f7 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiTypeProvider.java +++ b/python/python-psi-impl/src/com/jetbrains/python/pyi/PyiTypeProvider.java @@ -78,10 +78,10 @@ public final class PyiTypeProvider extends PyTypeProviderBase { .prepend(PyiUtil.getOverloads(pyFunction, context)) .map(context::getType) .collect(PyTypeUtil.toUnion()); - return PyTypeUtil.getNotNullToRef(allSignatures); + return PyTypeUtil.notNullToRef(allSignatures); } if (pythonStub instanceof PyTypedElement) { - return PyTypeUtil.getNotNullToRef(context.getType((PyTypedElement)pythonStub)); + return PyTypeUtil.notNullToRef(context.getType((PyTypedElement)pythonStub)); } } return null;