Kapt tests: minor, add case with optimized delegated property

In normal circumstances, it leads to the field `c$delegate` NOT being
generated (see KT-39054). However, it's not the case in kapt in any
mode:
- In the old JVM backend, this optimization is not supported.
- In JVM IR, property initializers are missing in light analysis, so
  backend cannot figure out that this property is optimizable.
- In kapt4, backend is not being run, and symbol light classes do not
  have information about this optimization.

Overall it doesn't matter much which stub is generated here because the
field is private, the test is added just in case.
This commit is contained in:
Alexander Udalov
2023-08-14 22:47:37 +02:00
committed by Space Team
parent 2423b7b62f
commit 28e232f54f
4 changed files with 37 additions and 0 deletions
@@ -16,6 +16,11 @@ package test;
* public final (* delegated *) val b: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: c$delegate:Lkotlin/reflect/KProperty0;
* // getter: getC()Ltest/C;
* public final (* delegated *) val c: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: x$delegate:Lkotlin/Lazy;
* // getter: getX()Lerror/NonExistentClass;
* // synthetic method for annotations: getX$annotations()V
@@ -47,6 +52,8 @@ public final class A {
private final kotlin.Lazy<test.C<java.lang.String>> a$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.Lazy<test.C<java.lang.String>> b$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.reflect.KProperty0<test.C<java.lang.String>> c$delegate = null;
public A() {
super();
@@ -80,6 +87,11 @@ public final class A {
public final test.C<java.lang.String> getB() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final test.C<java.lang.String> getC() {
return null;
}
}
////////////////////
@@ -16,6 +16,11 @@ package test;
* public final (* delegated *) val b: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: c$delegate:Lkotlin/reflect/KProperty0;
* // getter: getC()Ltest/C;
* public final (* delegated *) val c: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: x$delegate:Lkotlin/Lazy;
* // getter: getX()Lkotlin/Unit;
* // synthetic method for annotations: getX$annotations()V
@@ -47,6 +52,8 @@ public final class A {
private final kotlin.Lazy a$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.Lazy b$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.reflect.KProperty0 c$delegate = null;
public A() {
super();
@@ -81,6 +88,11 @@ public final class A {
public final test.C<java.lang.String> getB() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final test.C<java.lang.String> getC() {
return null;
}
}
////////////////////
@@ -11,4 +11,5 @@ class A {
val y by object: C<String>("y") {}
val a by lazy { C<String>("a") }
val b by lazy { object: C<String>("b") {} }
val c by ::a
}
@@ -16,6 +16,11 @@ package test;
* public final (* delegated *) val b: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: c$delegate:Lkotlin/reflect/KProperty0;
* // getter: getC()Ltest/C;
* public final (* delegated *) val c: test/C<kotlin/String>
* public final (* non-default *) get
*
* // field: x$delegate:Lkotlin/Lazy;
* // getter: getX()Lkotlin/Unit;
* // synthetic method for annotations: getX$annotations()V
@@ -47,6 +52,8 @@ public final class A {
private final kotlin.Lazy a$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.Lazy b$delegate = null;
@org.jetbrains.annotations.NotNull()
private final kotlin.reflect.KProperty0 c$delegate = null;
public A() {
super();
@@ -81,6 +88,11 @@ public final class A {
public final test.C<java.lang.String> getB() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final test.C<java.lang.String> getC() {
return null;
}
}
////////////////////