Resolve type aliases when looking for default arguments to actual methods.

Change-Id: I059093c1af32fcd7a2de36c25160c352d6f03a3c
This commit is contained in:
Steven Schäfer
2019-03-12 16:59:46 +01:00
committed by Mikhael Bogdanov
parent dfd3947856
commit 3f4c5c8d53
8 changed files with 49 additions and 3 deletions
@@ -50,7 +50,7 @@ object ExpectedActualResolver {
// TODO: support non-source definitions (e.g. from Java)
actual.source.containingFile != SourceFile.NO_SOURCE_FILE
}.groupBy { actual ->
areCompatibleCallables(expected, actual)
areCompatibleCallables(expected, actual, platformModule)
}
}
is ClassDescriptor -> {
@@ -113,7 +113,9 @@ object ExpectedActualResolver {
listOf(module.getPackage(containingDeclaration.fqName).memberScope)
}
is ClassDescriptor -> {
val classes = containingDeclaration.findClassifiersFromModule(module).filterIsInstance<ClassDescriptor>()
val classes = containingDeclaration.findClassifiersFromModule(module)
.mapNotNull { if (it is TypeAliasDescriptor) it.classDescriptor else it }
.filterIsInstance<ClassDescriptor>()
if (this is ConstructorDescriptor) return classes.flatMap { it.constructors }
classes.map { it.unsubstitutedMemberScope }
@@ -0,0 +1,20 @@
// !LANGUAGE: +MultiPlatformProjects
// WITH_RUNTIME
// FILE: common.kt
expect annotation class Foo(val z: String = "OK")
// FILE: platform.kt
actual typealias Foo = Foo2
annotation class Foo2 (val z: String = "OK")
@Foo
fun test() {}
fun box(): String {
test()
return "OK"
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// !LANGUAGE: +MultiPlatformProjects
// WITH_REFLECT
// FILE: main.kt
@@ -15969,6 +15969,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");
}
@TestMetadata("typeAlias.kt")
public void testTypeAlias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
}
}
}
@@ -15969,6 +15969,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testParametersInArgumentValues() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt");
}
@TestMetadata("typeAlias.kt")
public void testTypeAlias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
}
}
}
@@ -15974,6 +15974,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");
}
@TestMetadata("typeAlias.kt")
public void testTypeAlias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
}
}
}
@@ -12349,6 +12349,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");
}
@TestMetadata("typeAlias.kt")
public void testTypeAlias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
}
}
}
@@ -13444,6 +13444,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testSuperCall() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt");
}
@TestMetadata("typeAlias.kt")
public void testTypeAlias() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");
}
}
}