diff --git a/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.kt b/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.kt new file mode 100644 index 00000000000..928b78be8ea --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.kt @@ -0,0 +1,13 @@ +// FILE: Hello.kt +private class Hello() +{ + val a = 4 +} + +fun test() { + // no exception is thrown (see KT-3897) + Hello().a +} + +// FILE: Hello.java +public class Hello {} diff --git a/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.txt b/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.txt new file mode 100644 index 00000000000..c0eca88b98e --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.txt @@ -0,0 +1,18 @@ +package + +public fun test(): kotlin.Unit + +private final class Hello { + public constructor Hello() + public final val a: kotlin.Int = 4 + 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 open class Hello { + public constructor Hello() + 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 +} diff --git a/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.kt b/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.kt new file mode 100644 index 00000000000..f4a7c0eb5ec --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.kt @@ -0,0 +1,13 @@ +// FILE: A.java + +public class A { + public String foo; + public String foo = ""; +} + +// FILE: main.kt + +fun foo() { + // no exception is thrown (see KT-3898) + A().foo +} diff --git a/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.txt b/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.txt new file mode 100644 index 00000000000..25d65cbec84 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.txt @@ -0,0 +1,11 @@ +package + +public fun foo(): kotlin.Unit + +public open class A { + public constructor A() + public final var foo: kotlin.String! + 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 +} diff --git a/compiler/testData/diagnostics/tests/j+k/differentFilename.kt b/compiler/testData/diagnostics/tests/j+k/differentFilename.kt new file mode 100644 index 00000000000..7d4bd7d58a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/differentFilename.kt @@ -0,0 +1,25 @@ +// FILE: A.java +public class A { + public B b() {} + public F f() {} +} + +class B { public void bar() {} } + +// FILE: C.java +class D { + public void baz() {} +} + +// FILE: E.java +class F { + public void foobaz() {} +} + +// FILE: main.kt +fun main(x: A) { + x.b().bar() + x.f().foobaz() + + D().baz() +} diff --git a/compiler/testData/diagnostics/tests/j+k/differentFilename.txt b/compiler/testData/diagnostics/tests/j+k/differentFilename.txt new file mode 100644 index 00000000000..9824260209f --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/differentFilename.txt @@ -0,0 +1,12 @@ +package + +public fun main(/*0*/ x: A): kotlin.Unit + +public open class A { + public constructor A() + public open fun b(): B! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun f(): [ERROR : Unresolved java classifier: F]! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/kt7523.kt b/compiler/testData/diagnostics/tests/j+k/kt7523.kt new file mode 100644 index 00000000000..64e8ab34bc1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/kt7523.kt @@ -0,0 +1,14 @@ +// FILE: A.java +public interface A, S extends A> {} + +// FILE: C.java +public class C +{ + public , S extends A> void f(A x){} +} + +// FILE: main.kt +fun foo() { + // TODO: uncomment when KT-9597 is fixed + // C().f(object : A<*, *> {}) +} diff --git a/compiler/testData/diagnostics/tests/j+k/kt7523.txt b/compiler/testData/diagnostics/tests/j+k/kt7523.txt new file mode 100644 index 00000000000..b4d646c0ea2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/kt7523.txt @@ -0,0 +1,17 @@ +package + +public fun foo(): kotlin.Unit + +public interface A!, /*1*/ S : 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 open class C { + public constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun !, /*1*/ S : A!> f(/*0*/ x: A!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 48ecfb1eeb5..2b4dd840015 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -9987,6 +9987,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("differentFilename.kt") + public void testDifferentFilename() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/differentFilename.kt"); + doTest(fileName); + } + @TestMetadata("enumGetOrdinal.kt") public void testEnumGetOrdinal() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/enumGetOrdinal.kt"); @@ -10149,6 +10155,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt7523.kt") + public void testKt7523() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/kt7523.kt"); + doTest(fileName); + } + @TestMetadata("mutableIterator.kt") public void testMutableIterator() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/mutableIterator.kt"); @@ -10293,6 +10305,27 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("compiler/testData/diagnostics/tests/j+k/brokenCode") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BrokenCode extends AbstractDiagnosticsTest { + public void testAllFilesPresentInBrokenCode() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/brokenCode"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("classDuplicates.kt") + public void testClassDuplicates() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/brokenCode/classDuplicates.kt"); + doTest(fileName); + } + + @TestMetadata("fieldDuplicates.kt") + public void testFieldDuplicates() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/brokenCode/fieldDuplicates.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/j+k/collectionOverrides") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)