diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt index 50db323f304..5aec717e24e 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt @@ -50,6 +50,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl @@ -234,6 +235,10 @@ internal fun KotlinType.toPsiType(lightDeclaration: PsiModifierListOwner?, conte return typeAlias.expandedType.toPsiType(lightDeclaration, context, boxed) } + if (constructor is TypeVariableTypeConstructor) { + return UastErrorType + } + (constructor.declarationDescriptor as? TypeParameterDescriptor)?.let { typeParameter -> (typeParameter.containingDeclaration.toSource()?.getMaybeLightElement() as? PsiTypeParameterListOwner) ?.typeParameterList?.typeParameters?.getOrNull(typeParameter.index) diff --git a/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.kt b/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.kt new file mode 100644 index 00000000000..41277eeb27a --- /dev/null +++ b/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.kt @@ -0,0 +1,4 @@ +val bar: Any + get() = Unresolved(id(42)) + +fun id(x: T): T = x \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.types.txt b/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.types.txt new file mode 100644 index 00000000000..93ed57c58de --- /dev/null +++ b/plugins/uast-kotlin/testData/InferenceInsideUnresolvedConstructor.types.txt @@ -0,0 +1,18 @@ +UFile (package = ) [public final class InferenceInsideUnresolvedConstructorKt {...] + UClass (name = InferenceInsideUnresolvedConstructorKt) [public final class InferenceInsideUnresolvedConstructorKt {...}] + UAnnotationMethod (name = getBar) [public static final fun getBar() : java.lang.Object {...}] + UBlockExpression [{...}] + UReturnExpression [return (id(42))] + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [(id(42))] + UIdentifier (Identifier (Unresolved)) [UIdentifier (Identifier (Unresolved))] + USimpleNameReferenceExpression (identifier = , resolvesTo = null) [] + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [id(42)] : PsiType: + UIdentifier (Identifier (id)) [UIdentifier (Identifier (id))] + USimpleNameReferenceExpression (identifier = id, resolvesTo = null) [id] : PsiType: + ULiteralExpression (value = 42) [42] : PsiType:int + UAnnotationMethod (name = id) [public static final fun id(@org.jetbrains.annotations.Nullable x: T) : T {...}] + UParameter (name = x) [@org.jetbrains.annotations.Nullable var x: T] + UAnnotation (fqName = org.jetbrains.annotations.Nullable) [@org.jetbrains.annotations.Nullable] + UBlockExpression [{...}] + UReturnExpression [return x] + USimpleNameReferenceExpression (identifier = x) [x] : PsiType:T diff --git a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt index 20244b994bb..25adfb0b941 100644 --- a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt @@ -14,4 +14,6 @@ class KotlinUastTypesTest : AbstractKotlinTypesTest() { @Test fun testStringTemplate() = doTest("StringTemplate") @Test fun testStringTemplateComplex() = doTest("StringTemplateComplex") + + @Test fun testInferenceInsideUnresolvedConstructor() = doTest("InferenceInsideUnresolvedConstructor") } \ No newline at end of file