[FE 1.0] Support java sealed classes
^KT-46778 Fixed
This commit is contained in:
committed by
teamcityserver
parent
972211f8e6
commit
fa1d09c778
@@ -33,6 +33,7 @@ enum class JvmTarget(
|
||||
JVM_14("14", Opcodes.V12 + 2),
|
||||
JVM_15("15", Opcodes.V12 + 3),
|
||||
JVM_16("16", Opcodes.V12 + 4),
|
||||
JVM_17("17", Opcodes.V12 + 5),
|
||||
;
|
||||
|
||||
companion object {
|
||||
|
||||
+16
-6
@@ -29886,38 +29886,48 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/jvmRecord/supertypesCheck.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses")
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SealedClasses {
|
||||
@Test
|
||||
public void testAllFilesPresentInSealedClasses() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClassExhaustiveness.kt")
|
||||
public void testJavaSealedClassExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterfaceExhaustiveness.kt")
|
||||
public void testJavaSealedInterfaceExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaClass.kt")
|
||||
public void testKotlinInheritsJavaClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaInterface.kt")
|
||||
public void testKotlinInheritsJavaInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-6
@@ -29886,38 +29886,48 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/jvmRecord/supertypesCheck.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses")
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SealedClasses {
|
||||
@Test
|
||||
public void testAllFilesPresentInSealedClasses() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClassExhaustiveness.kt")
|
||||
public void testJavaSealedClassExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterfaceExhaustiveness.kt")
|
||||
public void testJavaSealedInterfaceExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaClass.kt")
|
||||
public void testKotlinInheritsJavaClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaInterface.kt")
|
||||
public void testKotlinInheritsJavaInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -116,7 +116,10 @@ public class KtTestUtil {
|
||||
|
||||
@NotNull
|
||||
private static File getJdkHome(@NotNull String prop, @Nullable String otherProp, @NotNull String propToReport) {
|
||||
String jdk = System.getenv(prop);
|
||||
String jdk = System.getProperty(prop);
|
||||
if (jdk == null) {
|
||||
jdk = System.getenv(prop);
|
||||
}
|
||||
if (jdk == null) {
|
||||
if (otherProp != null) {
|
||||
return getJdkHome(otherProp, null, prop);
|
||||
@@ -152,6 +155,11 @@ public class KtTestUtil {
|
||||
return getJdkHome("JDK_15", "JDK_15_0");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk17Home() {
|
||||
return getJdkHome("JDK_17_0", "JDK_17");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTestDataPathBase() {
|
||||
return getHomeDirectory() + "/compiler/testData";
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
error: unknown JVM target version: 1.5
|
||||
Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16
|
||||
Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17
|
||||
COMPILATION_ERROR
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<modernJava>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// ISSUE: KT-41215, KT-43551
|
||||
|
||||
// MODULE: lib
|
||||
|
||||
// FILE: Base.java
|
||||
public sealed class Base permits A, B {}
|
||||
|
||||
// FILE: A.java
|
||||
public final class A extends Base {}
|
||||
|
||||
// FILE: B.java
|
||||
public sealed class B extends Base permits B.C, B.D {
|
||||
public static final class C extends B {}
|
||||
|
||||
public static non-sealed class D extends B {}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
fun test_1(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "O"
|
||||
is B -> "Fail"
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B.C -> "K"
|
||||
is B.D -> "Fail B.D"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test_1(A()) + test_2(B.C())
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// ISSUE: KT-41215, KT-43551
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: Base.java
|
||||
public sealed interface Base permits A, B, E {}
|
||||
|
||||
// FILE: A.java
|
||||
public non-sealed interface A extends Base {}
|
||||
|
||||
// FILE: B.java
|
||||
public sealed interface B extends Base permits B.C, B.D {
|
||||
public static final class C implements B {}
|
||||
|
||||
public static non-sealed interface D extends B {}
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
public enum E implements Base {
|
||||
First, Second
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
fun test_1(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B -> "Fail B"
|
||||
is E -> "O"
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B.C -> "Fail B.C"
|
||||
is B.D -> "K"
|
||||
E.First -> "Fail E.First"
|
||||
E.Second -> "Fail E.Second"
|
||||
}
|
||||
}
|
||||
|
||||
class MyD : B.D
|
||||
|
||||
fun box(): String {
|
||||
return test_1(E.First) + test_2(MyD())
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// ISSUE: KT-41215, KT-43551
|
||||
|
||||
// FILE: Base.java
|
||||
public sealed class Base permits A, B {}
|
||||
|
||||
// FILE: A.java
|
||||
public final class A extends Base {}
|
||||
|
||||
// FILE: B.java
|
||||
public sealed class B extends Base permits B.C, B.D {
|
||||
public static final class C extends B {}
|
||||
|
||||
public static non-sealed class D extends B {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test_1(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "O"
|
||||
is B -> "Fail"
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B.C -> "K"
|
||||
is B.D -> "Fail B.D"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test_1(A()) + test_2(B.C())
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// ISSUE: KT-41215, KT-43551
|
||||
|
||||
// FILE: Base.java
|
||||
public sealed interface Base permits A, B, E {}
|
||||
|
||||
// FILE: A.java
|
||||
public non-sealed interface A extends Base {}
|
||||
|
||||
// FILE: B.java
|
||||
public sealed interface B extends Base permits B.C, B.D {
|
||||
public static final class C implements B {}
|
||||
|
||||
public static non-sealed interface D extends B {}
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
public enum E implements Base {
|
||||
First, Second
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test_1(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B -> "Fail B"
|
||||
is E -> "O"
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: Base): String {
|
||||
return when (base) {
|
||||
is A -> "Fail A"
|
||||
is B.C -> "Fail B.C"
|
||||
is B.D -> "K"
|
||||
E.First -> "Fail E.First"
|
||||
E.Second -> "Fail E.Second"
|
||||
}
|
||||
}
|
||||
|
||||
class MyD : B.D
|
||||
|
||||
fun box(): String {
|
||||
return test_1(E.First) + test_2(MyD())
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: Base.java
|
||||
public sealed class Base permits O, K {}
|
||||
|
||||
// FILE: O.java
|
||||
public final class O extends Base {}
|
||||
|
||||
// FILE: K.java
|
||||
public non-sealed class K extends Base {}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
val clazz = Base::class.java
|
||||
if (!clazz.isSealed) return "Error: Base is not sealed"
|
||||
return clazz.permittedSubclasses.joinToString("") { it.simpleName ?: "_No name provided_" }
|
||||
}
|
||||
+2
-2
@@ -16,14 +16,14 @@ public sealed class B extends Base permits B.C, B.D {
|
||||
|
||||
// FILE: main.kt
|
||||
fun test_ok_1(base: Base) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B -> 2
|
||||
}
|
||||
}
|
||||
|
||||
fun test_ok_2(base: Base) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B.C -> 2
|
||||
is B.D -> 3
|
||||
+2
-2
@@ -12,7 +12,7 @@ public final class A : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class B : Base {
|
||||
public sealed class B : Base {
|
||||
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
|
||||
@@ -33,7 +33,7 @@ public abstract class B : Base {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Base {
|
||||
public sealed class Base {
|
||||
public constructor Base()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
+2
-2
@@ -21,7 +21,7 @@ public enum E implements Base {
|
||||
|
||||
// FILE: main.kt
|
||||
fun test_ok_1(base: Base) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B -> 2
|
||||
is E -> 3
|
||||
@@ -29,7 +29,7 @@ fun test_ok_1(base: Base) {
|
||||
}
|
||||
|
||||
fun test_ok_2(base: Base) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B.C -> 2
|
||||
is B.D -> 3
|
||||
+2
-2
@@ -12,7 +12,7 @@ public interface A : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : Base {
|
||||
public sealed interface B : Base {
|
||||
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
|
||||
@@ -31,7 +31,7 @@ public interface B : Base {
|
||||
}
|
||||
}
|
||||
|
||||
public interface Base {
|
||||
public sealed interface Base {
|
||||
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
|
||||
+1
-1
@@ -14,7 +14,7 @@ public final class B : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class Base {
|
||||
public sealed class Base {
|
||||
public constructor Base()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
+1
-1
@@ -14,7 +14,7 @@ public final class B : Base {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Base {
|
||||
public sealed interface Base {
|
||||
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
|
||||
Generated
+16
-6
@@ -29982,38 +29982,48 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/jvmRecord/supertypesCheck.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses")
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SealedClasses {
|
||||
@Test
|
||||
public void testAllFilesPresentInSealedClasses() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClassExhaustiveness.kt")
|
||||
public void testJavaSealedClassExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterfaceExhaustiveness.kt")
|
||||
public void testJavaSealedInterfaceExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaClass.kt")
|
||||
public void testKotlinInheritsJavaClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaInterface.kt")
|
||||
public void testKotlinInheritsJavaInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+41
@@ -107,6 +107,47 @@ public class BlackBoxModernJdkCodegenTestGenerated extends AbstractBlackBoxCodeg
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@Tag("<modernJava>")
|
||||
@TestMetadata("compiler/testData/codegen/boxModernJdk/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxModernJdk/testsWithJava17"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compiledJavaSealedClass.kt")
|
||||
public void testCompiledJavaSealedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/compiledJavaSealedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compiledJavaSealedInterface.kt")
|
||||
public void testCompiledJavaSealedInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/compiledJavaSealedInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClass.kt")
|
||||
public void testJavaSealedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/javaSealedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterface.kt")
|
||||
public void testJavaSealedInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/javaSealedInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sealedJavaClassViaJavaReflection.kt")
|
||||
public void testSealedJavaClassViaJavaReflection() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealedJavaClassViaJavaReflection.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@Tag("<modernJava>")
|
||||
@TestMetadata("compiler/testData/codegen/boxModernJdk/testsWithJava9")
|
||||
|
||||
+41
@@ -107,6 +107,47 @@ public class IrBlackBoxModernJdkCodegenTestGenerated extends AbstractIrBlackBoxC
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@Tag("<modernJava>")
|
||||
@TestMetadata("compiler/testData/codegen/boxModernJdk/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxModernJdk/testsWithJava17"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compiledJavaSealedClass.kt")
|
||||
public void testCompiledJavaSealedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/compiledJavaSealedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compiledJavaSealedInterface.kt")
|
||||
public void testCompiledJavaSealedInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/compiledJavaSealedInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClass.kt")
|
||||
public void testJavaSealedClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/javaSealedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterface.kt")
|
||||
public void testJavaSealedInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/javaSealedInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sealedJavaClassViaJavaReflection.kt")
|
||||
public void testSealedJavaClassViaJavaReflection() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxModernJdk/testsWithJava17/sealedJavaClassViaJavaReflection.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@Tag("<modernJava>")
|
||||
@TestMetadata("compiler/testData/codegen/boxModernJdk/testsWithJava9")
|
||||
|
||||
+1
@@ -84,6 +84,7 @@ class JavaCompilerFacade(private val testServices: TestServices) {
|
||||
JvmTarget.JVM_9 -> KtTestUtil.getJdk9Home()
|
||||
JvmTarget.JVM_11 -> KtTestUtil.getJdk11Home()
|
||||
JvmTarget.JVM_15 -> KtTestUtil.getJdk15Home()
|
||||
JvmTarget.JVM_17 -> KtTestUtil.getJdk17Home()
|
||||
else -> null
|
||||
} ?: error("JDK for $jvmTarget is not found")
|
||||
|
||||
|
||||
+8
@@ -112,6 +112,14 @@ abstract class AbstractDiagnosticTest : AbstractKotlinCompilerTest() {
|
||||
}
|
||||
}
|
||||
|
||||
forTestsMatching("compiler/testData/diagnostics/tests/testsWithJava17/*") {
|
||||
defaultDirectives {
|
||||
JDK_KIND with TestJdkKind.FULL_JDK_17
|
||||
+WITH_STDLIB
|
||||
+WITH_REFLECT
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------- constant evaluation tests -----------------------
|
||||
forTestsMatching("compiler/testData/diagnostics/tests/constantEvaluator/*") {
|
||||
defaultDirectives {
|
||||
|
||||
+4
@@ -64,6 +64,10 @@ abstract class AbstractJvmBlackBoxCodegenTestBase<R : ResultingArtifact.Frontend
|
||||
configureModernJavaTest(TestJdkKind.FULL_JDK_15, JvmTarget.JVM_15)
|
||||
}
|
||||
|
||||
forTestsMatching("compiler/testData/codegen/boxModernJdk/testsWithJava17/*") {
|
||||
configureModernJavaTest(TestJdkKind.FULL_JDK_17, JvmTarget.JVM_17)
|
||||
}
|
||||
|
||||
enableMetaInfoHandler()
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -172,6 +172,9 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
|
||||
TestJdkKind.FULL_JDK_15 -> {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, KtTestUtil.getJdk15Home())
|
||||
}
|
||||
TestJdkKind.FULL_JDK_17 -> {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, KtTestUtil.getJdk17Home())
|
||||
}
|
||||
TestJdkKind.FULL_JDK -> {
|
||||
if (SystemInfo.IS_AT_LEAST_JAVA9) {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, File(System.getProperty("java.home")))
|
||||
|
||||
+5
-2
@@ -81,8 +81,11 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
private val modality =
|
||||
if (jClass.isAnnotationType || jClass.isEnum) Modality.FINAL
|
||||
// TODO: replace false with jClass.isSealed when it will be properly supported in platform
|
||||
else Modality.convertFromFlags(sealed = false, jClass.isSealed || jClass.isAbstract || jClass.isInterface, !jClass.isFinal)
|
||||
else Modality.convertFromFlags(
|
||||
sealed = jClass.isSealed,
|
||||
abstract = jClass.isSealed || jClass.isAbstract || jClass.isInterface,
|
||||
open = !jClass.isFinal
|
||||
)
|
||||
|
||||
private val visibility = jClass.visibility
|
||||
private val isInner = jClass.outerClass != null && !jClass.isStatic
|
||||
|
||||
+16
-6
@@ -29886,38 +29886,48 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/jvmRecord/supertypesCheck.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TestsWithJava17 {
|
||||
@Test
|
||||
public void testAllFilesPresentInTestsWithJava17() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses")
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SealedClasses {
|
||||
@Test
|
||||
public void testAllFilesPresentInSealedClasses() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedClassExhaustiveness.kt")
|
||||
public void testJavaSealedClassExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedClassExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSealedInterfaceExhaustiveness.kt")
|
||||
public void testJavaSealedInterfaceExhaustiveness() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/javaSealedInterfaceExhaustiveness.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaClass.kt")
|
||||
public void testKotlinInheritsJavaClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinInheritsJavaInterface.kt")
|
||||
public void testKotlinInheritsJavaInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava15/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
runTest("compiler/testData/diagnostics/tests/testsWithJava17/sealedClasses/kotlinInheritsJavaInterface.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user