KT-14400: Properly handle TypeAliasConstructorDescriptor in KotlinTypeMapper.mapToCallableMethod(...)
Implement getDefaultType() in TypeAliasDescriptor subclasses.
This commit is contained in:
@@ -639,9 +639,13 @@ public class KotlinTypeMapper {
|
||||
|
||||
@NotNull
|
||||
public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor descriptor, boolean superCall) {
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
if (descriptor instanceof TypeAliasConstructorDescriptor) {
|
||||
return mapToCallableMethod(((TypeAliasConstructorDescriptor) descriptor).getUnderlyingConstructorDescriptor(), superCall);
|
||||
}
|
||||
|
||||
if (descriptor instanceof ClassConstructorDescriptor) {
|
||||
JvmMethodSignature method = mapSignatureSkipGeneric(descriptor);
|
||||
Type owner = mapClass(((ConstructorDescriptor) descriptor).getContainingDeclaration());
|
||||
Type owner = mapClass(((ClassConstructorDescriptor) descriptor).getContainingDeclaration());
|
||||
String defaultImplDesc = mapDefaultMethod(descriptor, OwnerKind.IMPLEMENTATION).getDescriptor();
|
||||
return new CallableMethod(owner, owner, defaultImplDesc, method, INVOKESPECIAL, null, null, null);
|
||||
}
|
||||
|
||||
+3
@@ -41,9 +41,11 @@ class LazyTypeAliasDescriptor(
|
||||
|
||||
private lateinit var underlyingTypeImpl: NotNullLazyValue<SimpleType>
|
||||
private lateinit var expandedTypeImpl: NotNullLazyValue<SimpleType>
|
||||
private lateinit var defaultTypeImpl: NotNullLazyValue<SimpleType>
|
||||
|
||||
override val underlyingType: SimpleType get() = underlyingTypeImpl()
|
||||
override val expandedType: SimpleType get() = expandedTypeImpl()
|
||||
override fun getDefaultType(): SimpleType = defaultTypeImpl()
|
||||
|
||||
fun initialize(
|
||||
declaredTypeParameters: List<TypeParameterDescriptor>,
|
||||
@@ -53,6 +55,7 @@ class LazyTypeAliasDescriptor(
|
||||
super.initialize(declaredTypeParameters)
|
||||
this.underlyingTypeImpl = lazyUnderlyingType
|
||||
this.expandedTypeImpl = lazyExpandedType
|
||||
this.defaultTypeImpl = storageManager.createLazyValue { computeDefaultType() }
|
||||
}
|
||||
|
||||
private val lazyTypeConstructorParameters =
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
open class Foo<T>(val x: T)
|
||||
|
||||
typealias FooStr = Foo<String>
|
||||
|
||||
val test = object : FooStr("OK") {}
|
||||
|
||||
fun box() = test.x
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
open class Foo<T>
|
||||
|
||||
typealias FooStr = Foo<String>
|
||||
|
||||
val test = object : FooStr() {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public val test: FooStr /* = Foo<kotlin.String> */
|
||||
|
||||
public open class Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias FooStr = Foo<kotlin.String>
|
||||
+6
@@ -15982,6 +15982,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasInAnonymousObjectType.kt")
|
||||
public void testTypeAliasInAnonymousObjectType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasInAnonymousObjectType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasObject.kt")
|
||||
public void testTypeAliasObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasObject.kt");
|
||||
|
||||
@@ -20862,6 +20862,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasInAnonymousObjectType.kt")
|
||||
public void testTypeAliasInAnonymousObjectType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasInAnonymousObjectType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasInvisibleObject.kt")
|
||||
public void testTypeAliasInvisibleObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasInvisibleObject.kt");
|
||||
|
||||
@@ -15982,6 +15982,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasInAnonymousObjectType.kt")
|
||||
public void testTypeAliasInAnonymousObjectType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasInAnonymousObjectType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasObject.kt")
|
||||
public void testTypeAliasObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/typealias/typeAliasObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user