diff --git a/compiler/java8-tests/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsWithJava8TestGenerated.java b/compiler/java8-tests/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsWithJava8TestGenerated.java index 0459c0ea97d..5f70cfddbd5 100644 --- a/compiler/java8-tests/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsWithJava8TestGenerated.java +++ b/compiler/java8-tests/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsWithJava8TestGenerated.java @@ -67,4 +67,19 @@ public class JetDiagnosticsWithJava8TestGenerated extends AbstractJetDiagnostics doTest(fileName); } } + + @TestMetadata("compiler/testData/diagnostics/testsWithJava8/statics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Statics extends AbstractJetDiagnosticsWithFullJdkTest { + public void testAllFilesPresentInStatics() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJava8/statics"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("inheritanceStaticMethodFromInterface.kt") + public void testInheritanceStaticMethodFromInterface() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt"); + doTest(fileName); + } + } } diff --git a/compiler/testData/codegen/boxWithJava/statics/fields/Child.java b/compiler/testData/codegen/boxWithJava/statics/fields/Child.java new file mode 100644 index 00000000000..4b743397bfc --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/fields/Child.java @@ -0,0 +1,4 @@ +class Child extends Parent { + public static int b = 3; + public static int c = 4; +} diff --git a/compiler/testData/codegen/boxWithJava/statics/fields/Parent.java b/compiler/testData/codegen/boxWithJava/statics/fields/Parent.java new file mode 100644 index 00000000000..f4c1d9a5b39 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/fields/Parent.java @@ -0,0 +1,4 @@ +class Parent { + public static int a = 1; + public static int b = 2; +} diff --git a/compiler/testData/codegen/boxWithJava/statics/fields/test.kt b/compiler/testData/codegen/boxWithJava/statics/fields/test.kt new file mode 100644 index 00000000000..da4171e95b1 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/fields/test.kt @@ -0,0 +1,9 @@ +fun box(): String { + if (Parent.a != 1) return "expected Parent.a == 1" + if (Parent.b != 2) return "expected Parent.b == 2" + if (Child.a != 1) return "expected Child.a == 1" + if (Child.b != 3) return "expected Child.b == 3" + if (Child.c != 4) return "expected Child.c == 4" + + return "OK" +} diff --git a/compiler/testData/codegen/boxWithJava/statics/functions/Child.java b/compiler/testData/codegen/boxWithJava/statics/functions/Child.java new file mode 100644 index 00000000000..63e6f8766c6 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/functions/Child.java @@ -0,0 +1,8 @@ +class Child extends Parent { + public static String bar() { + return "Child.bar"; + } + public static String baz() { + return "Child.baz"; + } +} diff --git a/compiler/testData/codegen/boxWithJava/statics/functions/Parent.java b/compiler/testData/codegen/boxWithJava/statics/functions/Parent.java new file mode 100644 index 00000000000..8184cffb3df --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/functions/Parent.java @@ -0,0 +1,8 @@ +class Parent { + public static String foo() { + return "Parent.foo"; + } + public static String baz() { + return "Parent.baz"; + } +} diff --git a/compiler/testData/codegen/boxWithJava/statics/functions/test.kt b/compiler/testData/codegen/boxWithJava/statics/functions/test.kt new file mode 100644 index 00000000000..56d167d2ece --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/functions/test.kt @@ -0,0 +1,9 @@ +fun box(): String { + if (Parent.foo() != "Parent.foo") return "expected: Parent.foo" + if (Parent.baz() != "Parent.baz") return "expected: Parent.baz" + if (Child.foo() != "Parent.foo") return "expected: Child.foo() != Parent.foo" + if (Child.baz() != "Child.baz") return "expected: Child.baz" + if (Child.bar() != "Child.bar") return "expected: Child.bar" + + return "OK" +} diff --git a/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Child.java b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Child.java new file mode 100644 index 00000000000..7dd71b702ac --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Child.java @@ -0,0 +1,9 @@ +class Child extends Parent { + public static String a = "2"; + public static String foo() { + return "Child.foo()"; + } + public static String foo(int i) { + return "Child.foo(int)"; + } +} diff --git a/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Parent.java b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Parent.java new file mode 100644 index 00000000000..592175f5c4f --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/Parent.java @@ -0,0 +1,6 @@ +class Parent { + private static int a = 1; + private static String foo() { + return "Parent.foo"; + } +} diff --git a/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/test.kt b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/test.kt new file mode 100644 index 00000000000..90645449b07 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/test.kt @@ -0,0 +1,7 @@ +fun box(): String { + if (Child.a != "2") return "Fail #1" + if (Child.foo() != "Child.foo()") return "Fail #2" + if (Child.foo(1) != "Child.foo(int)") return "Fail #3" + + return "OK" +} diff --git a/compiler/testData/diagnostics/tests/j+k/StaticMembersFromSuperclasses.txt b/compiler/testData/diagnostics/tests/j+k/StaticMembersFromSuperclasses.txt index 8e3658fdfdf..98a1816a6ac 100644 --- a/compiler/testData/diagnostics/tests/j+k/StaticMembersFromSuperclasses.txt +++ b/compiler/testData/diagnostics/tests/j+k/StaticMembersFromSuperclasses.txt @@ -19,5 +19,5 @@ public open class Bbb : Aaa { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - public const final val i: kotlin.String = "s" + public const final override /*1*/ val i: kotlin.String = "s" } diff --git a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.txt b/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.txt index b0afca73528..019bac015c5 100644 --- a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.txt +++ b/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.txt @@ -45,6 +45,13 @@ public abstract class A : java.util.ArrayList { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun trimToSize(): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake const final override /*1*/ /*fake_override*/ val serialVersionUID: kotlin.Long + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun subListRangeCheck(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.Int): kotlin.Unit } public final class B : A { diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt index 322ca44442b..8da60e8b3a4 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt @@ -22,6 +22,9 @@ public/*package*/ open class MyMap public open override /*1*/ /*fake_override*/ fun remove(/*0*/ key: kotlin.Any?): V? public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun values(): kotlin.MutableCollection + + // Static members + invisible_fake open override /*1*/ /*fake_override*/ fun eq(/*0*/ p0: kotlin.Any!, /*1*/ p1: kotlin.Any!): kotlin.Boolean } public interface ResolverForProject { diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.kt new file mode 100644 index 00000000000..26893cee05e --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.kt @@ -0,0 +1,36 @@ +// FILE: A.java + +class A { + private static int a = 1; + private static void foo() {} + + protected static int b = 1; + protected static void bar() {} +} + +// FILE: B.java + +class B extends A { + public static int a = 1; + public static void foo() {} + public static void foo(int i) {} + + public static int b = 1; + public static void bar() {} + public static void bar(int i) {} +} + +// FILE: test.kt + +fun test() { + A.a + A.foo() + A.b + A.bar() + B.a + B.foo() + B.foo(1) + B.b + B.bar() + B.bar(1) +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.txt new file mode 100644 index 00000000000..21d239ec1a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.txt @@ -0,0 +1,31 @@ +package + +public fun test(): kotlin.Unit + +public/*package*/ open class A { + public/*package*/ 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 + + // Static members + private final var a: kotlin.Int + protected/*protected static*/ final var b: kotlin.Int + protected/*protected static*/ open fun bar(): kotlin.Unit + private open fun foo(): kotlin.Unit +} + +public/*package*/ open class B : A { + public/*package*/ 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 + + // Static members + public final var a: kotlin.Int + public final override /*1*/ var b: kotlin.Int + public open override /*1*/ fun bar(): kotlin.Unit + public open fun bar(/*0*/ i: kotlin.Int): kotlin.Unit + public open fun foo(): kotlin.Unit + public open fun foo(/*0*/ i: kotlin.Int): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.kt new file mode 100644 index 00000000000..d5d11213a21 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.kt @@ -0,0 +1,43 @@ +// FILE: I.java + +public interface I { + int a = 1; +} + +// FILE: C.java + +public class C implements I { + static int b = 1; + static void bar() {} +} + +// FILE: K.kt + +open class K : C() + +// FILE: D.java + +public class D extends K { + static int c = 1; + static void baz() {} +} + +// FILE: test.kt + +fun test() { + I.a + + C.a + C.b + C.bar() + + K.a + K.b + K.bar() + + D.a + D.b + D.c + D.bar() + D.baz() +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.txt new file mode 100644 index 00000000000..216945fb197 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.txt @@ -0,0 +1,45 @@ +package + +public fun test(): kotlin.Unit + +public open class C : I { + public constructor C() + 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 + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public/*package*/ final var b: kotlin.Int + public/*package*/ open fun bar(): kotlin.Unit +} + +public open class D : K { + public constructor D() + 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 + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public/*package*/ final override /*1*/ /*fake_override*/ var b: kotlin.Int + public/*package*/ final var c: kotlin.Int + public/*package*/ open override /*1*/ /*fake_override*/ fun bar(): kotlin.Unit + public/*package*/ open fun baz(): kotlin.Unit +} + +public interface I { + 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 + + // Static members + public const final val a: kotlin.Int = 1 +} + +public open class K : C { + public constructor K() + 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/scopes/inheritance/statics/kjk.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.kt new file mode 100644 index 00000000000..cfda01f129f --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.kt @@ -0,0 +1,37 @@ +// FILE: K.kt + +open class K { + companion object { + fun foo() {} + } +} + +// FILE: D.java + +class D extends K { + static int b = 1; + static void bar() {} +} + +// FILE: K.kt + +class K2 { + companion object { + fun baz() {} + } +} + +// FILE: test.kt + +fun test() { + K.foo() + + D.b + D.bar() + D.foo() + + K2.b + K2.bar() + K2.foo() + K2.baz() +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.txt new file mode 100644 index 00000000000..28086702f21 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.txt @@ -0,0 +1,44 @@ +package + +public fun test(): kotlin.Unit + +public/*package*/ open class D : K { + public/*package*/ constructor D() + 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 + + // Static members + public/*package*/ final var b: kotlin.Int + public/*package*/ open fun bar(): kotlin.Unit +} + +public open class K { + public constructor K() + 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 companion object Companion { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): 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 K2 { + public constructor K2() + 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 companion object Companion { + private constructor Companion() + public final fun baz(): kotlin.Unit + 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/scopes/inheritance/statics/oneInterfaceManyTimes.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.kt new file mode 100644 index 00000000000..f9a240211ea --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.kt @@ -0,0 +1,55 @@ +// FILE: I.java + +public interface I { + int a = 1; +} + +// FILE: C.java + +public class C implements I { + static int b = 1; + static void bar() {} +} + +// FILE: K.kt + +open class K : C(), I + +// FILE: D.java + +public class D extends K, I { + static int c = 1; + static void baz() {} +} + +// FILE: E.java + +public class E extends D, I { + static int a = 1; +} + +// FILE: test.kt + +fun test() { + I.a + + C.a + C.b + C.bar() + + K.a + K.b + K.bar() + + D.a + D.b + D.c + D.bar() + D.baz() + + E.a + E.b + E.c + E.bar() + E.baz() +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.txt new file mode 100644 index 00000000000..5ead921c7d5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.txt @@ -0,0 +1,59 @@ +package + +public fun test(): kotlin.Unit + +public open class C : I { + public constructor C() + 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 + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public/*package*/ final var b: kotlin.Int + public/*package*/ open fun bar(): kotlin.Unit +} + +public open class D : K, I { + public constructor D() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public const final override /*2*/ /*fake_override*/ val a: kotlin.Int + public/*package*/ final override /*1*/ /*fake_override*/ var b: kotlin.Int + public/*package*/ final var c: kotlin.Int + public/*package*/ open override /*1*/ /*fake_override*/ fun bar(): kotlin.Unit + public/*package*/ open fun baz(): kotlin.Unit +} + +public open class E : D, I { + public constructor E() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public/*package*/ final override /*2*/ var a: kotlin.Int + public/*package*/ final override /*1*/ /*fake_override*/ var b: kotlin.Int + public/*package*/ final override /*1*/ /*fake_override*/ var c: kotlin.Int + public/*package*/ open override /*1*/ /*fake_override*/ fun bar(): kotlin.Unit + public/*package*/ open override /*1*/ /*fake_override*/ fun baz(): kotlin.Unit +} + +public interface I { + 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 + + // Static members + public const final val a: kotlin.Int = 1 +} + +public open class K : C, I { + public constructor K() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt b/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt new file mode 100644 index 00000000000..0ace11ee609 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt @@ -0,0 +1,32 @@ +// FILE: I.java + +public interface I { + int a = 1; + static void foo() {} +} + +// FILE: C.java + +public class C implements I { + static int b = 1; + static void bar() {} +} + +// FILE: test.kt + +class K : C() + +fun main(args: Array) { + I.a + I.foo() + + C.a + C.b + C.foo() + C.bar() + + K.a + K.b + K.foo() + K.bar() +} diff --git a/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.txt b/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.txt new file mode 100644 index 00000000000..f9a65124dd7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.txt @@ -0,0 +1,32 @@ +package + +public fun main(/*0*/ args: kotlin.Array): kotlin.Unit + +public open class C : I { + public constructor C() + 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 + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public/*package*/ final var b: kotlin.Int + public/*package*/ open fun bar(): kotlin.Unit +} + +public interface I { + 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 + + // Static members + public const final val a: kotlin.Int = 1 + public open fun foo(): kotlin.Unit +} + +public final class K : C { + public constructor K() + 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/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt index 1162033a80d..2623cd15a36 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt @@ -21,4 +21,9 @@ public fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt index bfc978c179d..bf0964ad7c3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt @@ -35,4 +35,9 @@ public fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/invalidFqName.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/invalidFqName.txt index 36f6aacf1e9..bd06766193d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/invalidFqName.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/invalidFqName.txt @@ -35,6 +35,11 @@ public val y: B public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } @kotlin.jvm.PurelyImplements(value = "[INVALID]") public open class B : java.util.AbstractList { @@ -69,4 +74,9 @@ public val y: B public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt index fb92b3c8a9f..4e1dd2ba26f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt @@ -35,4 +35,9 @@ public fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } diff --git a/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt b/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt index f2e20b8d15f..cfbe4502b86 100644 --- a/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt +++ b/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt @@ -32,4 +32,20 @@ public abstract class ClassDoesNotOverrideMethod : java.util.Date { @kotlin.Deprecated(message = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun toGMTString(): kotlin.String! @kotlin.Deprecated(message = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun toLocaleString(): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit + + // Static members + invisible_fake final override /*1*/ /*fake_override*/ var defaultCenturyStart: kotlin.Int + invisible_fake final override /*1*/ /*fake_override*/ val gcal: sun.util.calendar.BaseCalendar! + invisible_fake final override /*1*/ /*fake_override*/ var jcal: sun.util.calendar.BaseCalendar! + invisible_fake const final override /*1*/ /*fake_override*/ val serialVersionUID: kotlin.Long + invisible_fake final override /*1*/ /*fake_override*/ val ttb: kotlin.IntArray! + invisible_fake final override /*1*/ /*fake_override*/ val wtb: kotlin.Array<(out) kotlin.String!>! + @kotlin.Deprecated(value = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun UTC(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int, /*2*/ p2: kotlin.Int, /*3*/ p3: kotlin.Int, /*4*/ p4: kotlin.Int, /*5*/ p5: kotlin.Int): kotlin.Long + invisible_fake final override /*1*/ /*fake_override*/ fun convertToAbbr(/*0*/ p0: java.lang.StringBuilder!, /*1*/ p1: kotlin.String!): java.lang.StringBuilder! + invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarSystem(/*0*/ p0: kotlin.Int): sun.util.calendar.BaseCalendar! + invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarSystem(/*0*/ p0: kotlin.Long): sun.util.calendar.BaseCalendar! + invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarSystem(/*0*/ p0: sun.util.calendar.BaseCalendar.Date!): sun.util.calendar.BaseCalendar! + invisible_fake final override /*1*/ /*fake_override*/ fun getJulianCalendar(): sun.util.calendar.BaseCalendar! + invisible_fake final override /*1*/ /*fake_override*/ fun getMillisOf(/*0*/ p0: java.util.Date!): kotlin.Long + @kotlin.Deprecated(value = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun parse(/*0*/ p0: kotlin.String!): kotlin.Long } diff --git a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt index 88d514d0773..e34f5859c94 100644 --- a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt +++ b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt @@ -29,4 +29,9 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! + + // Static members + invisible_fake const final override /*1*/ /*fake_override*/ val MAX_ARRAY_SIZE: kotlin.Int + invisible_fake open override /*1*/ /*fake_override*/ fun finishToArray(/*0*/ p0: kotlin.Array<(out) T!>!, /*1*/ p1: kotlin.(Mutable)Iterator<*>!): kotlin.Array<(out) T!>! + invisible_fake open override /*1*/ /*fake_override*/ fun hugeCapacity(/*0*/ p0: kotlin.Int): kotlin.Int } diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.java b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.java new file mode 100644 index 00000000000..d103214e59d --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.java @@ -0,0 +1,18 @@ +package test; + +class Parent { + public static int a = 1; + public static int b = 2; + public static void foo() {} + public static void baz() {} +} + +class Child extends Parent { + public static String b = "3"; + public static int c = 4; + public static void foo(int i) {} + public static void bar() {} + public static void bar(int i) {} + public static void baz() {} + public static void baz(int i) {} +} diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.txt b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.txt new file mode 100644 index 00000000000..c499397f9e6 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.txt @@ -0,0 +1,26 @@ +package test + +public/*package*/ open class Child : test.Parent { + public/*package*/ constructor Child() + + // Static members + public final override /*1*/ /*fake_override*/ var a: kotlin.Int + public final override /*1*/ var b: kotlin.String + public final var c: kotlin.Int + public open fun bar(): kotlin.Unit + public open fun bar(/*0*/ p0: kotlin.Int): kotlin.Unit + public open override /*1*/ fun baz(): kotlin.Unit + public open fun baz(/*0*/ p0: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open fun foo(/*0*/ p0: kotlin.Int): kotlin.Unit +} + +public/*package*/ open class Parent { + public/*package*/ constructor Parent() + + // Static members + public final var a: kotlin.Int + public final var b: kotlin.Int + public open fun baz(): kotlin.Unit + public open fun foo(): kotlin.Unit +} diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.java b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.java new file mode 100644 index 00000000000..d0b1396f89e --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.java @@ -0,0 +1,19 @@ +package test; + +interface Parent1 { + public static int a = 1; + public static int b = 2; +} + +interface Parent2 { + public static int d = 1; + public static int e = 2; +} + +class Child implements Parent1, Parent2 { + public static String b = "3"; + public static int c = 4; + public static String d = "4"; + public static void bar() {} + public static void baz() {} +} diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.txt b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.txt new file mode 100644 index 00000000000..24d330c5a25 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.txt @@ -0,0 +1,28 @@ +package test + +public/*package*/ open class Child : test.Parent1, test.Parent2 { + public/*package*/ constructor Child() + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public final override /*1*/ var b: kotlin.String + public final var c: kotlin.Int + public final override /*1*/ var d: kotlin.String + public const final override /*1*/ /*fake_override*/ val e: kotlin.Int + public open fun bar(): kotlin.Unit + public open fun baz(): kotlin.Unit +} + +public/*package*/ interface Parent1 { + + // Static members + public const final val a: kotlin.Int = 1 + public const final val b: kotlin.Int = 2 +} + +public/*package*/ interface Parent2 { + + // Static members + public const final val d: kotlin.Int = 1 + public const final val e: kotlin.Int = 2 +} diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.java b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.java new file mode 100644 index 00000000000..da03b3c7214 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.java @@ -0,0 +1,21 @@ +package test; + +interface Parent1 { + public static int a = 1; + public static int b = 2; +} + +interface Parent2 { + public static int d = 1; + public static int e = 2; +} + +enum StaticMembersInEnum implements Parent1, Parent2 { + ENTRY; + + public static int b = 3; + public static int c = 4; + public static int d = 4; + + public static void foo() { } +} diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.txt b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.txt new file mode 100644 index 00000000000..ec230ca82bc --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.txt @@ -0,0 +1,35 @@ +package test + +public/*package*/ interface Parent1 { + + // Static members + public const final val a: kotlin.Int = 1 + public const final val b: kotlin.Int = 2 +} + +public/*package*/ interface Parent2 { + + // Static members + public const final val d: kotlin.Int = 1 + public const final val e: kotlin.Int = 2 +} + +public/*package*/ final enum class StaticMembersInEnum : kotlin.Enum, test.Parent1, test.Parent2 { + enum entry ENTRY + + private constructor StaticMembersInEnum() + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.StaticMembersInEnum!): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + // Static members + public const final override /*1*/ /*fake_override*/ val a: kotlin.Int + public final override /*1*/ var b: kotlin.Int + public final var c: kotlin.Int + public final override /*1*/ var d: kotlin.Int + public const final override /*1*/ /*fake_override*/ val e: kotlin.Int + public open fun foo(): kotlin.Unit + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.StaticMembersInEnum + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 01e3966dcf5..b10e39ee5c7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -12899,6 +12899,48 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/diagnostics/tests/scopes/inheritance") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inheritance extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInInheritance() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/scopes/inheritance"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/diagnostics/tests/scopes/inheritance/statics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Statics extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInStatics() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/scopes/inheritance/statics"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("hidePrivateByPublic.kt") + public void testHidePrivateByPublic() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/inheritance/statics/hidePrivateByPublic.kt"); + doTest(fileName); + } + + @TestMetadata("jjkj.kt") + public void testJjkj() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/inheritance/statics/jjkj.kt"); + doTest(fileName); + } + + @TestMetadata("kjk.kt") + public void testKjk() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/inheritance/statics/kjk.kt"); + doTest(fileName); + } + + @TestMetadata("oneInterfaceManyTimes.kt") + public void testOneInterfaceManyTimes() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/scopes/inheritance/statics/oneInterfaceManyTimes.kt"); + doTest(fileName); + } + } + } } @TestMetadata("compiler/testData/diagnostics/tests/sealed") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index b3a1b8b6e9a..6305562ced5 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -512,4 +512,32 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege } } + + @TestMetadata("compiler/testData/codegen/boxWithJava/statics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Statics extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInStatics() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/statics"), Pattern.compile("^([^\\.]+)$"), true); + } + + @TestMetadata("fields") + public void testFields() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/statics/fields/"); + doTestWithJava(fileName); + } + + @TestMetadata("functions") + public void testFunctions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/statics/functions/"); + doTestWithJava(fileName); + } + + @TestMetadata("hidePrivateByPublic") + public void testHidePrivateByPublic() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/statics/hidePrivateByPublic/"); + doTestWithJava(fileName); + } + + } } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 50c263d3dca..f8b924b98ee 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -1848,11 +1848,29 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava(fileName); } + @TestMetadata("StaticMembersFromParentClass.java") + public void testStaticMembersFromParentClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.java"); + doTestCompiledJava(fileName); + } + + @TestMetadata("StaticMembersFromParentInterface.java") + public void testStaticMembersFromParentInterface() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.java"); + doTestCompiledJava(fileName); + } + @TestMetadata("StaticMembersInEnum.java") public void testStaticMembersInEnum() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.java"); doTestCompiledJava(fileName); } + + @TestMetadata("StaticMembersInEnumFromParents.java") + public void testStaticMembersInEnumFromParents() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.java"); + doTestCompiledJava(fileName); + } } @TestMetadata("compiler/testData/loadJava/compiledJava/vararg") diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index aa5dade2dbd..101e2625dbb 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -4203,11 +4203,29 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD doTest(fileName); } + @TestMetadata("StaticMembersFromParentClass.java") + public void testStaticMembersFromParentClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentClass.java"); + doTest(fileName); + } + + @TestMetadata("StaticMembersFromParentInterface.java") + public void testStaticMembersFromParentInterface() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersFromParentInterface.java"); + doTest(fileName); + } + @TestMetadata("StaticMembersInEnum.java") public void testStaticMembersInEnum() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.java"); doTest(fileName); } + + @TestMetadata("StaticMembersInEnumFromParents.java") + public void testStaticMembersInEnumFromParents() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/static/StaticMembersInEnumFromParents.java"); + doTest(fileName); + } } @TestMetadata("compiler/testData/loadJava/compiledJava/vararg") diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt index c3041564dbe..f8f1c8a3205 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt @@ -16,8 +16,13 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors +import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor +import org.jetbrains.kotlin.incremental.components.LookupLocation +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.name.FqName @@ -25,8 +30,9 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.incremental.components.LookupLocation +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.addIfNotNull public class LazyJavaStaticClassScope( @@ -66,6 +72,9 @@ public class LazyJavaStaticClassScope( val nestedClassesScope = getContainingDeclaration().getUnsubstitutedInnerClassesScope() result.addIfNotNull(c.components.samConversionResolver.resolveSamConstructor(name, nestedClassesScope)) + val functionsFromSupertypes = getStaticFunctionsFromJavaSuperClasses(name, getContainingDeclaration()) + result.addAll(DescriptorResolverUtils.resolveOverrides(name, functionsFromSupertypes, result, getContainingDeclaration(), c.components.errorReporter)) + if (jClass.isEnum()) { when (name) { DescriptorUtils.ENUM_VALUE_OF -> result.add(createEnumValueOfMethod(getContainingDeclaration())) @@ -74,5 +83,35 @@ public class LazyJavaStaticClassScope( } } + override fun computeNonDeclaredProperties(name: Name, result: MutableCollection) { + val propertiesFromSupertypes = getStaticPropertiesFromJavaSupertypes(name, getContainingDeclaration()) + result.addAll(DescriptorResolverUtils.resolveOverrides(name, propertiesFromSupertypes, result, getContainingDeclaration(), c.components.errorReporter)) + } + override fun getContainingDeclaration() = super.getContainingDeclaration() as LazyJavaClassDescriptor + + private fun getStaticFunctionsFromJavaSuperClasses(name: Name, descriptor: ClassDescriptor): Set { + val superClassDescriptor = descriptor.getSuperClassNotAny() ?: return emptySet() + + val staticScope = superClassDescriptor.staticScope + + if (staticScope !is LazyJavaStaticClassScope) return getStaticFunctionsFromJavaSuperClasses(name, superClassDescriptor) + + return staticScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet() + } + + private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set { + + fun getStaticProperties(supertype: JetType): Iterable { + val superTypeDescriptor = supertype.constructor.declarationDescriptor as? ClassDescriptor ?: return emptyList() + + val staticScope = superTypeDescriptor.staticScope + + if (staticScope !is LazyJavaStaticClassScope) return getStaticPropertiesFromJavaSupertypes(name, superTypeDescriptor) + + return staticScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as PropertyDescriptor } + } + + return descriptor.typeConstructor.supertypes.flatMap(::getStaticProperties).toSet() + } }