[KAPT] Correct type for property with accessor

^KT-39060 Fixed
This commit is contained in:
Andrey Zinovyev
2021-02-08 10:11:50 +03:00
committed by GitHub
parent dcb47d9934
commit c75d2c05f0
3 changed files with 10 additions and 3 deletions
@@ -1023,10 +1023,10 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
val returnType = getNonErrorType( val returnType = getNonErrorType(
descriptor.returnType, RETURN_TYPE, descriptor.returnType, RETURN_TYPE,
ktTypeProvider = { ktTypeProvider = {
val element = kaptContext.origins[method]?.element when (val element = kaptContext.origins[method]?.element) {
when (element) {
is KtFunction -> element.typeReference is KtFunction -> element.typeReference
is KtProperty -> if (descriptor is PropertyGetterDescriptor) element.typeReference else null is KtProperty -> if (descriptor is PropertyGetterDescriptor) element.typeReference else null
is KtPropertyAccessor -> if (descriptor is PropertyGetterDescriptor) element.property.typeReference else null
is KtParameter -> if (descriptor is PropertyGetterDescriptor) element.typeReference else null is KtParameter -> if (descriptor is PropertyGetterDescriptor) element.typeReference else null
else -> null else -> null
} }
@@ -9,6 +9,8 @@ object NonExistentType {
val c: (ABCDEF) -> Unit = { f -> } val c: (ABCDEF) -> Unit = { f -> }
val d: ABCDEF<String, (List<ABCDEF>) -> Unit>? = null val d: ABCDEF<String, (List<ABCDEF>) -> Unit>? = null
val foo: Foo get() = Foo()
fun a(a: ABCDEF, s: String): ABCDEF {} fun a(a: ABCDEF, s: String): ABCDEF {}
fun b(s: String): ABCDEF {} fun b(s: String): ABCDEF {}
} }
@@ -38,6 +38,11 @@ public final class NonExistentType {
return null; return null;
} }
@org.jetbrains.annotations.NotNull()
public final Foo getFoo() {
return null;
}
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
public final ABCDEF a(@org.jetbrains.annotations.NotNull() public final ABCDEF a(@org.jetbrains.annotations.NotNull()
ABCDEF a, @org.jetbrains.annotations.NotNull() ABCDEF a, @org.jetbrains.annotations.NotNull()