Kapt+JVM_IR: fix error on delegation to anonymous object
In kapt stub generation mode, psi2ir does not generate bodies of declarations. This means that the delegate type was translated into an IrType which is based on a class which is not generated by psi2ir, thus leading to an unbound symbol error. The fix is to avoid using anonymous types for delegate fields in this mode. #KT-59211 Fixed
This commit is contained in:
committed by
Space Team
parent
fd4e59f279
commit
04998cff8a
@@ -204,7 +204,9 @@ internal class ClassGenerator(
|
||||
val delegateType = if (context.configuration.generateBodies) {
|
||||
getTypeInferredByFrontendOrFail(ktDelegateExpression)
|
||||
} else {
|
||||
getTypeInferredByFrontend(ktDelegateExpression) ?: createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, ktDelegateExpression.text)
|
||||
getTypeInferredByFrontend(ktDelegateExpression).takeUnless {
|
||||
it?.constructor?.declarationDescriptor?.let(DescriptorUtils::isLocal) == true
|
||||
} ?: createErrorType(ErrorTypeKind.UNRESOLVED_TYPE, ktDelegateExpression.text)
|
||||
}
|
||||
val superType = getOrFail(BindingContext.TYPE, ktEntry.typeReference!!)
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
interface I
|
||||
|
||||
class C : I by (object : I {})
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
@kotlin.Metadata()
|
||||
public final class C implements I {
|
||||
|
||||
public C() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
@kotlin.Metadata()
|
||||
public abstract interface I {
|
||||
}
|
||||
+6
@@ -175,6 +175,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegationToAnonymousObject.kt")
|
||||
public void testDelegationToAnonymousObject() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegationToAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
|
||||
+6
@@ -175,6 +175,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegationAndCompanionObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegationToAnonymousObject.kt")
|
||||
public void testDelegationToAnonymousObject() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegationToAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user