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 3585c85fea4..0f2ed86e785 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 @@ -42,6 +42,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.constants.IntegerValueTypeConstructor import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isError @@ -86,7 +87,14 @@ internal fun KotlinType.toPsiType(source: UElement, element: KtElement, boxed: B "kotlin.Double" -> PsiType.DOUBLE.orBoxed() "kotlin.Float" -> PsiType.FLOAT.orBoxed() "kotlin.String" -> PsiType.getJavaLangString(element.manager, GlobalSearchScope.projectScope(element.project)) - else -> null + else -> { + val typeConstructor = this.constructor + if (typeConstructor is IntegerValueTypeConstructor) { + typeConstructor.supertypes.first().toPsiType(source, element, boxed) + } else { + null + } + } } if (psiType != null) return psiType } diff --git a/plugins/uast-kotlin/testData/ea101715.kt b/plugins/uast-kotlin/testData/ea101715.kt new file mode 100644 index 00000000000..262edcb4f9d --- /dev/null +++ b/plugins/uast-kotlin/testData/ea101715.kt @@ -0,0 +1,5 @@ +fun a() { + val a = Obj(555) +} + +object Obj \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/ea101715.types.txt b/plugins/uast-kotlin/testData/ea101715.types.txt new file mode 100644 index 00000000000..1bda09432b3 --- /dev/null +++ b/plugins/uast-kotlin/testData/ea101715.types.txt @@ -0,0 +1,14 @@ +UFile (package = ) [public final class Ea101715Kt {...] + UClass (name = Ea101715Kt) [public final class Ea101715Kt {...}] + UAnnotationMethod (name = a) [public static final fun a() : void {...}] + UBlockExpression [{...}] : PsiType:Unit + UDeclarationsExpression [var a: = Obj(555)] + ULocalVariable (name = a) [var a: = Obj(555)] + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [Obj(555)] + UIdentifier (Identifier (Obj)) [UIdentifier (Identifier (Obj))] + USimpleNameReferenceExpression (identifier = Obj) [Obj] + ULiteralExpression (value = 555) [555] : PsiType:int + UClass (name = Obj) [public final class Obj {...}] + UField (name = INSTANCE) [public static final var INSTANCE: Obj] + UAnnotation (fqName = null) [@null] + UAnnotationMethod (name = Obj) [private fun Obj() = UastEmptyExpression] diff --git a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt index 86a0485ac7c..a7bf54178b5 100644 --- a/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt +++ b/plugins/uast-kotlin/tests/KotlinUastTypesTest.kt @@ -8,4 +8,6 @@ class KotlinUastTypesTest : AbstractKotlinTypesTest() { @Test fun testUnexpectedContainerException() = doTest("UnexpectedContainerException") @Test fun testCycleInTypeParameters() = doTest("CycleInTypeParameters") + + @Test fun testEa101715() = doTest("ea101715") } \ No newline at end of file