Kapt: Fix stubs for delegated properties with anonymous types (KT-27910)
This commit is contained in:
+4
-1
@@ -143,7 +143,10 @@ class VariableTypeAndInitializerResolver(
|
|||||||
variableDescriptor, delegateExpression, type, trace, scopeForInitializer, dataFlowInfo
|
variableDescriptor, delegateExpression, type, trace, scopeForInitializer, dataFlowInfo
|
||||||
)
|
)
|
||||||
|
|
||||||
getterReturnType?.let { approximateType(it, local) } ?: ErrorUtils.createErrorType("Type from delegate")
|
val delegatedType = getterReturnType?.let { approximateType(it, local) }
|
||||||
|
?: ErrorUtils.createErrorType("Type from delegate")
|
||||||
|
|
||||||
|
transformAnonymousTypeIfNeeded(variableDescriptor, property, delegatedType, trace, anonymousTypeTransformers)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveInitializerType(
|
private fun resolveInitializerType(
|
||||||
|
|||||||
+3
-2
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
||||||
import org.jetbrains.kotlin.resolve.DeclarationSignatureAnonymousTypeTransformer
|
import org.jetbrains.kotlin.resolve.DeclarationSignatureAnonymousTypeTransformer
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||||
@@ -37,9 +38,9 @@ class KaptAnonymousTypeTransformer : DeclarationSignatureAnonymousTypeTransforme
|
|||||||
}
|
}
|
||||||
|
|
||||||
val actualType = when {
|
val actualType = when {
|
||||||
isAnonymousObject(declaration) -> {
|
isAnonymousObject(declaration) || DescriptorUtils.isLocal(declaration) -> {
|
||||||
if (type.constructor.supertypes.size == 1) {
|
if (type.constructor.supertypes.size == 1) {
|
||||||
type.constructor.supertypes.iterator().next()
|
convertPossiblyAnonymousType(type.constructor.supertypes.iterator().next())
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
Frontend reports an error on public properties in this case,
|
Frontend reports an error on public properties in this case,
|
||||||
|
|||||||
+5
@@ -264,6 +264,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt27126.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt27126.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lazyProperty.kt")
|
||||||
|
public void testLazyProperty() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("leadingDollars.kt")
|
@TestMetadata("leadingDollars.kt")
|
||||||
public void testLeadingDollars() throws Exception {
|
public void testLeadingDollars() throws Exception {
|
||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt");
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
interface Intf
|
||||||
|
interface GenericIntf<T>
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
private val foo by lazy {
|
||||||
|
object : Runnable {
|
||||||
|
override fun run() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val bar by lazy {
|
||||||
|
object : Runnable, Intf {
|
||||||
|
override fun run() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val baz by lazy {
|
||||||
|
abstract class LocalIntf
|
||||||
|
object : LocalIntf() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val generic1 by lazy {
|
||||||
|
abstract class LocalIntf : GenericIntf<CharSequence>
|
||||||
|
object : LocalIntf() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public final class Foo {
|
||||||
|
private final kotlin.Lazy foo$delegate = null;
|
||||||
|
private final kotlin.Lazy bar$delegate = null;
|
||||||
|
private final kotlin.Lazy baz$delegate = null;
|
||||||
|
private final kotlin.Lazy generic1$delegate = null;
|
||||||
|
|
||||||
|
private final java.lang.Runnable getFoo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final java.lang.Object getBar() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final java.lang.Object getBaz() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final GenericIntf<java.lang.CharSequence> getGeneric1() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Foo() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public abstract interface GenericIntf<T extends java.lang.Object> {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public abstract interface Intf {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user