Fix referencing inner class constructor on an outer class instance

#KT-12796 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-09-01 17:32:59 +03:00
parent 4a6f35b9c2
commit e7449a3584
10 changed files with 95 additions and 2 deletions
@@ -0,0 +1,20 @@
abstract class A {
inner class InnerInA {
fun returnOk() = "OK"
}
}
class B : A()
fun foo(a: A): String {
if (a is B) {
val v = a::InnerInA
return v().returnOk()
}
return "error"
}
fun box(): String {
return foo(B())
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
abstract class A {
inner class InnerInA
}
abstract class B : A()
fun foo(a: A) {
if (a is B) {
val v = a::InnerInA
}
}
@@ -0,0 +1,24 @@
package
public fun foo(/*0*/ a: A): kotlin.Unit
public abstract class A {
public constructor A()
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 final inner class InnerInA {
public constructor InnerInA()
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 abstract class B : A {
public constructor B()
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
}
@@ -1936,6 +1936,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("innerClassConstructorWithTwoReceivers.kt")
public void testInnerClassConstructorWithTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerClassConstructorWithTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("innerConstructorFromClass.kt")
public void testInnerConstructorFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt");
@@ -2580,6 +2580,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("innerClassConstructorOnOuterClassInstance.kt")
public void testInnerClassConstructorOnOuterClassInstance() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/innerClassConstructorOnOuterClassInstance.kt");
doTest(fileName);
}
@TestMetadata("intersectionTypeOverloadWithWrongParameter.kt")
public void testIntersectionTypeOverloadWithWrongParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt");
@@ -2580,6 +2580,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
doTest(fileName);
}
@TestMetadata("innerClassConstructorOnOuterClassInstance.kt")
public void testInnerClassConstructorOnOuterClassInstance() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/innerClassConstructorOnOuterClassInstance.kt");
doTest(fileName);
}
@TestMetadata("intersectionTypeOverloadWithWrongParameter.kt")
public void testIntersectionTypeOverloadWithWrongParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/intersectionTypeOverloadWithWrongParameter.kt");
@@ -1936,6 +1936,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("innerClassConstructorWithTwoReceivers.kt")
public void testInnerClassConstructorWithTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerClassConstructorWithTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("innerConstructorFromClass.kt")
public void testInnerConstructorFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt");
@@ -1936,6 +1936,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("innerClassConstructorWithTwoReceivers.kt")
public void testInnerClassConstructorWithTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerClassConstructorWithTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("innerConstructorFromClass.kt")
public void testInnerConstructorFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt");
@@ -508,8 +508,8 @@ public class OverridingUtil {
if (!isVisibilityMoreSpecific(a, b)) return false;
if (a instanceof SimpleFunctionDescriptor) {
assert b instanceof SimpleFunctionDescriptor : "b is " + b.getClass();
if (a instanceof FunctionDescriptor) {
assert b instanceof FunctionDescriptor : "b is " + b.getClass();
return isReturnTypeMoreSpecific(a, aReturnType, b, bReturnType);
}
@@ -2278,6 +2278,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("innerClassConstructorWithTwoReceivers.kt")
public void testInnerClassConstructorWithTwoReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerClassConstructorWithTwoReceivers.kt");
doTest(fileName);
}
@TestMetadata("innerConstructorFromClass.kt")
public void testInnerConstructorFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/function/innerConstructorFromClass.kt");