Uast: partial fix for reified functions resolve (#3923, KT-41279)
doesn't take into account compiled reified functions from jars
This commit is contained in:
+2
-2
@@ -312,8 +312,8 @@ internal fun resolveToPsiMethod(
|
|||||||
is KtFunction ->
|
is KtFunction ->
|
||||||
if (source.isLocal)
|
if (source.isLocal)
|
||||||
getContainingLightClass(source)?.let { UastFakeLightMethod(source, it) }
|
getContainingLightClass(source)?.let { UastFakeLightMethod(source, it) }
|
||||||
else
|
else // UltraLightMembersCreator.createMethods() returns nothing for JVM-invisible methods, so fake it if we get null here
|
||||||
LightClassUtil.getLightClassMethod(source)
|
LightClassUtil.getLightClassMethod(source) ?: getContainingLightClass(source)?.let { UastFakeLightMethod(source, it) }
|
||||||
is PsiMethod -> source
|
is PsiMethod -> source
|
||||||
null -> resolveDeserialized(context, descriptor) as? PsiMethod
|
null -> resolveDeserialized(context, descriptor) as? PsiMethod
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
inline fun <reified T : Any> foo(init: T.() -> Unit = {}): T {
|
||||||
|
TODO("message")
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <T : Any> bar(init: T.() -> Unit = {}): T {
|
||||||
|
TODO("message")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resolve() {
|
||||||
|
foo<String>()
|
||||||
|
val x: String = foo()
|
||||||
|
|
||||||
|
bar<String>()
|
||||||
|
val y: String = bar()
|
||||||
|
|
||||||
|
val z = listOf("foo").filterIsInstance<String>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
UTypeReferenceExpression (name = java.lang.Object) -> USimpleNameReferenceExpression (identifier = Any) -> PsiClass:Object: Object
|
||||||
|
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> Light PSI class: T: T
|
||||||
|
UTypeReferenceExpression (name = void) -> USimpleNameReferenceExpression (identifier = Unit) -> PsiClass:Void: Void
|
||||||
|
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> Light PSI class: T: T
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))(resolves to PsiMethod:TODO) -> USimpleNameReferenceExpression (identifier = TODO) -> PsiMethod:TODO: TODO
|
||||||
|
UTypeReferenceExpression (name = java.lang.Object) -> USimpleNameReferenceExpression (identifier = Any) -> PsiClass:Object: Object
|
||||||
|
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> Light PSI class: T: T
|
||||||
|
UTypeReferenceExpression (name = void) -> USimpleNameReferenceExpression (identifier = Unit) -> PsiClass:Void: Void
|
||||||
|
UTypeReferenceExpression (name = T) -> USimpleNameReferenceExpression (identifier = T) -> Light PSI class: T: T
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))(resolves to PsiMethod:TODO) -> USimpleNameReferenceExpression (identifier = TODO) -> PsiMethod:TODO: TODO
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))(resolves to LightMethodBuilder:foo) -> USimpleNameReferenceExpression (identifier = foo) -> LightMethodBuilder:foo: foo
|
||||||
|
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||||
|
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))(resolves to LightMethodBuilder:foo) -> USimpleNameReferenceExpression (identifier = foo) -> LightMethodBuilder:foo: foo
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))(resolves to KtUltraLightMethodForSourceDeclaration:bar) -> USimpleNameReferenceExpression (identifier = bar) -> KtUltraLightMethodForSourceDeclaration:bar: bar
|
||||||
|
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||||
|
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))(resolves to KtUltraLightMethodForSourceDeclaration:bar) -> USimpleNameReferenceExpression (identifier = bar) -> KtUltraLightMethodForSourceDeclaration:bar: bar
|
||||||
|
ULocalVariable (name = z) -> UQualifiedReferenceExpression -> null: null
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))(resolves to PsiMethod:listOf) -> USimpleNameReferenceExpression (identifier = listOf) -> PsiMethod:listOf: listOf
|
||||||
|
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))(resolves to null) -> USimpleNameReferenceExpression (identifier = filterIsInstance) -> null: null
|
||||||
|
UTypeReferenceExpression (name = java.lang.String) -> USimpleNameReferenceExpression (identifier = String) -> PsiClass:String: String
|
||||||
@@ -30,6 +30,9 @@ class KotlinUastResolveEverythingTest : AbstractKotlinResolveEverythingTest() {
|
|||||||
@Test
|
@Test
|
||||||
fun testImports() = doTest("Imports")
|
fun testImports() = doTest("Imports")
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testReifiedResolve() = doTest("ReifiedResolve")
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testResolve() = doTest("Resolve")
|
fun testResolve() = doTest("Resolve")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user