JVM_IR KT-41214 emit PermittedSubclasses on JDK17+
This commit is contained in:
committed by
TeamCityServer
parent
dca4a8e722
commit
146f0f4904
+21
@@ -0,0 +1,21 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
|
||||
// ENABLE_JVM_PREVIEW
|
||||
|
||||
// FILE: javaExhaustiveWhenOnKotlinSealedClass.kt
|
||||
sealed class KS
|
||||
class KO : KS()
|
||||
class KK : KS()
|
||||
|
||||
fun box(): String =
|
||||
J.test(KO()) + J.test(KK())
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String test(KS ks) {
|
||||
return switch (ks) {
|
||||
case KO ko -> "O";
|
||||
case KK kk -> "K";
|
||||
};
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
|
||||
|
||||
sealed class Base
|
||||
class O : Base()
|
||||
class K : Base()
|
||||
|
||||
sealed interface IBase
|
||||
class X : IBase
|
||||
class Y : IBase
|
||||
|
||||
fun box(): String {
|
||||
val cBase = Base::class.java
|
||||
if (!cBase.isSealed) return "Error: Base is not sealed"
|
||||
val pBase = cBase.permittedSubclasses.mapTo(HashSet()) { it.simpleName ?: "???" }
|
||||
if (pBase != setOf("O", "K")) {
|
||||
return "Failed: $pBase"
|
||||
}
|
||||
|
||||
val cIBase = IBase::class.java
|
||||
if (!cIBase.isSealed) return "Error: IBase is not sealed"
|
||||
val pIBase = cIBase.permittedSubclasses.mapTo(HashSet()) { it.simpleName ?: "???" }
|
||||
if (pIBase != setOf("X", "Y")) {
|
||||
return "Failed: $pIBase"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_DEXING
|
||||
// JVM_TARGET: 17
|
||||
// !LANGUAGE: +JvmPermittedSubclassesAttributeForSealed
|
||||
|
||||
// FILE: Expr.kt
|
||||
sealed interface Expr
|
||||
|
||||
class VarExpr(val name: String) : Expr
|
||||
class ParensExpr(val arg: Expr) : Expr
|
||||
|
||||
// FILE: Literals.kt
|
||||
class IntExpr(val value: Int) : Expr
|
||||
class DoubleExpr(val value: Double) : Expr
|
||||
|
||||
// FILE: UnaryOperators.kt
|
||||
sealed class UnaryExpr(val arg: Expr) : Expr
|
||||
class UnaryPlusExpr(arg: Expr) : UnaryExpr(arg)
|
||||
class UnaryMinusExpr(arg: Expr) : UnaryExpr(arg)
|
||||
|
||||
// FILE: BinaryOperators.kt
|
||||
sealed class BinaryExpr(val arg1: Expr, val arg2: Expr) : Expr
|
||||
class BinaryPlusExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
|
||||
class BinaryMinusExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
|
||||
class BinaryMulExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
|
||||
class BinaryDivExpr(arg1: Expr, arg2: Expr) : BinaryExpr(arg1, arg2)
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
@kotlin.Metadata
|
||||
public final class BinaryDivExpr {
|
||||
// source: 'BinaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class BinaryExpr {
|
||||
// source: 'BinaryOperators.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field arg1: Expr
|
||||
private final @org.jetbrains.annotations.NotNull field arg2: Expr
|
||||
private method <init>(p0: Expr, p1: Expr): void
|
||||
public synthetic method <init>(p0: Expr, p1: Expr, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public final @org.jetbrains.annotations.NotNull method getArg1(): Expr
|
||||
public final @org.jetbrains.annotations.NotNull method getArg2(): Expr
|
||||
permittedSubclass: BinaryDivExpr
|
||||
permittedSubclass: BinaryMinusExpr
|
||||
permittedSubclass: BinaryMulExpr
|
||||
permittedSubclass: BinaryPlusExpr
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class BinaryMinusExpr {
|
||||
// source: 'BinaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class BinaryMulExpr {
|
||||
// source: 'BinaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class BinaryPlusExpr {
|
||||
// source: 'BinaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr, @org.jetbrains.annotations.NotNull p1: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class DoubleExpr {
|
||||
// source: 'Literals.kt'
|
||||
private final field value: double
|
||||
public method <init>(p0: double): void
|
||||
public final method getValue(): double
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public interface Expr {
|
||||
// source: 'Expr.kt'
|
||||
permittedSubclass: BinaryExpr
|
||||
permittedSubclass: DoubleExpr
|
||||
permittedSubclass: IntExpr
|
||||
permittedSubclass: ParensExpr
|
||||
permittedSubclass: UnaryExpr
|
||||
permittedSubclass: VarExpr
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class IntExpr {
|
||||
// source: 'Literals.kt'
|
||||
private final field value: int
|
||||
public method <init>(p0: int): void
|
||||
public final method getValue(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class ParensExpr {
|
||||
// source: 'Expr.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field arg: Expr
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
|
||||
public final @org.jetbrains.annotations.NotNull method getArg(): Expr
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class UnaryExpr {
|
||||
// source: 'UnaryOperators.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field arg: Expr
|
||||
private method <init>(p0: Expr): void
|
||||
public synthetic method <init>(p0: Expr, p1: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public final @org.jetbrains.annotations.NotNull method getArg(): Expr
|
||||
permittedSubclass: UnaryMinusExpr
|
||||
permittedSubclass: UnaryPlusExpr
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class UnaryMinusExpr {
|
||||
// source: 'UnaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class UnaryPlusExpr {
|
||||
// source: 'UnaryOperators.kt'
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: Expr): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class VarExpr {
|
||||
// source: 'Expr.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field name: java.lang.String
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final @org.jetbrains.annotations.NotNull method getName(): java.lang.String
|
||||
}
|
||||
Reference in New Issue
Block a user