KT-2752: add diagnostics that reports about conflicting overridden declarations
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JS
|
||||
package foo
|
||||
|
||||
@native interface A {
|
||||
fun foo(value: Int): String
|
||||
}
|
||||
|
||||
interface B {
|
||||
fun foo(value: Int): String
|
||||
}
|
||||
|
||||
class C : A, B {
|
||||
override fun foo(value: Int) = "C.foo($value)"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a: A = C()
|
||||
assertEquals("C.foo(55)", a.foo(55))
|
||||
|
||||
val b: B = C()
|
||||
assertEquals("C.foo(23)", b.foo(23))
|
||||
|
||||
val d: dynamic = C()
|
||||
assertEquals("C.foo(42)", d.foo(42))
|
||||
assertEquals("C.foo(99)", d.`foo_za3lpa$`(99))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
interface A {
|
||||
@JsName("foo") fun f()
|
||||
}
|
||||
|
||||
interface B {
|
||||
@JsName("foo") fun g()
|
||||
}
|
||||
|
||||
class C : A, B {
|
||||
<!JS_NAME_CLASH!>override fun f() {}<!>
|
||||
|
||||
<!JS_NAME_CLASH!>override fun g() {}<!>
|
||||
}
|
||||
|
||||
<!JS_NAME_CLASH_SYNTHETIC!>abstract class D : A, B<!>
|
||||
|
||||
open class E {
|
||||
open fun f() {}
|
||||
|
||||
open fun g() {}
|
||||
}
|
||||
|
||||
<!JS_NAME_OVERRIDE_CLASH!>class F : E(), A, B<!>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "foo") public abstract fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "foo") public abstract fun g(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class C : A, B {
|
||||
public constructor C()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun f(): kotlin.Unit
|
||||
public open override /*1*/ fun g(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class D : A, B {
|
||||
public constructor D()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "foo") public abstract override /*1*/ /*fake_override*/ fun f(): kotlin.Unit
|
||||
@kotlin.js.JsName(name = "foo") public abstract override /*1*/ /*fake_override*/ fun g(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class E {
|
||||
public constructor E()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun f(): kotlin.Unit
|
||||
public open fun g(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class F : E, A, B {
|
||||
public constructor F()
|
||||
public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun f(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun g(): kotlin.Unit
|
||||
public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
interface A {
|
||||
@JsName("f") fun foo(value: Int)
|
||||
}
|
||||
|
||||
interface B {
|
||||
@JsName("g") fun foo(value: Int)
|
||||
}
|
||||
|
||||
class C : A, B {
|
||||
<!JS_NAME_OVERRIDE_CLASH!>override fun foo(value: Int) { }<!>
|
||||
}
|
||||
|
||||
@native interface NA {
|
||||
@JsName("f") fun foo(value: Int)
|
||||
}
|
||||
|
||||
@native interface NB {
|
||||
@JsName("g") fun foo(value: Int)
|
||||
}
|
||||
|
||||
class NC : NA, NB {
|
||||
<!JS_NAME_OVERRIDE_CLASH!>override fun foo(value: Int) { }<!>
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "f") public abstract fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "g") public abstract fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class C : A, B {
|
||||
public constructor C()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.js.native() public interface NA {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "f") public abstract fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.js.native() public interface NB {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@kotlin.js.JsName(name = "g") public abstract fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class NC : NA, NB {
|
||||
public constructor NC()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ fun foo(/*0*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+12
@@ -301,6 +301,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("conflictingNamesFromSuperclass.kt")
|
||||
public void testConflictingNamesFromSuperclass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/conflictingNamesFromSuperclass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionPropertyAndMethod.kt")
|
||||
public void testExtensionPropertyAndMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethod.kt");
|
||||
@@ -367,6 +373,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenJsNameClash.kt")
|
||||
public void testOverriddenJsNameClash() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/overriddenJsNameClash.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("packageAndMethod.kt")
|
||||
public void testPackageAndMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMethod.kt");
|
||||
|
||||
@@ -906,6 +906,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Bridges extends AbstractBlackBoxCodegenTest {
|
||||
@TestMetadata("jsNative.kt")
|
||||
public void ignoredJsNative() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/jsNative.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBridges() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/bridges"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user