Kapt+JVM_IR: fix "correct error types" mode for delegated properties

Use the property as PSI element origin for delegated property accessors
and field in JVM IR as it is done in the old JVM backend. Otherwise kapt
"correct error types" mode can't find the property type and thus cannot
succeed in "resolving" it, which led to java.lang.Object being used as a
fallback.

Note that in the unmuted test, .txt and _ir.txt dumps differ only in an
unrelated NotNull annotation on a delegate field.

See also KT-37586 for some related changes which fixed this problem
initially in kapt.
This commit is contained in:
Alexander Udalov
2022-12-28 23:27:23 +01:00
parent 549bfb2d9e
commit 4a91957ff0
3 changed files with 45 additions and 2 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES
@file:Suppress("UNRESOLVED_REFERENCE")
@@ -0,0 +1,35 @@
package test;
@kotlin.Metadata()
public final class Bar {
@org.jetbrains.annotations.NotNull()
private final test.Delegate unknown$delegate = null;
public Bar(@org.jetbrains.annotations.NotNull()
test.Delegate delegate) {
super();
}
private final Unknown getUnknown() {
return null;
}
}
////////////////////
package test;
@kotlin.Metadata()
public final class Delegate {
public Delegate() {
super();
}
@org.jetbrains.annotations.NotNull()
public final java.lang.Object getValue(@org.jetbrains.annotations.NotNull()
java.lang.Object thisRef, @org.jetbrains.annotations.NotNull()
KProperty<?> property) {
return null;
}
}