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
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
FILE fqName:<root> fileName:/sealedClasses.kt
|
||||
CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any]
|
||||
sealedSubclasses:
|
||||
CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[<root>.Expr]
|
||||
CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[<root>.Expr]
|
||||
CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[<root>.Expr]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Expr
|
||||
CONSTRUCTOR visibility:protected <> () returnType:<root>.Expr [primary]
|
||||
BLOCK_BODY
|
||||
|
||||
+4
@@ -1,5 +1,7 @@
|
||||
FILE fqName:<root> fileName:/expectedSealedClass.kt
|
||||
CLASS CLASS name:Ops modality:SEALED visibility:public [expect] superTypes:[kotlin.Any]
|
||||
sealedSubclasses:
|
||||
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Ops]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ops
|
||||
CONSTRUCTOR visibility:protected <> () returnType:<root>.Ops [primary,expect]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
@@ -32,6 +34,8 @@ FILE fqName:<root> fileName:/expectedSealedClass.kt
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.Ops
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any]
|
||||
sealedSubclasses:
|
||||
CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[<root>.Ops]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Ops
|
||||
CONSTRUCTOR visibility:protected <> () returnType:<root>.Ops [primary]
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
FILE fqName:<root> fileName:/ArrayMap.kt
|
||||
CLASS CLASS name:ArrayMap modality:SEALED visibility:public superTypes:[kotlin.collections.Iterable<T of <root>.ArrayMap>]
|
||||
sealedSubclasses:
|
||||
CLASS OBJECT name:EmptyArrayMap modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<kotlin.Nothing>]
|
||||
CLASS CLASS name:OneElementArrayMap modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<T of <root>.OneElementArrayMap>]
|
||||
CLASS CLASS name:ArrayMapImpl modality:FINAL visibility:internal superTypes:[<root>.ArrayMap<T of <root>.ArrayMapImpl>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.ArrayMap<T of <root>.ArrayMap>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
|
||||
CONSTRUCTOR visibility:protected <> () returnType:<root>.ArrayMap<T of <root>.ArrayMap> [primary]
|
||||
@@ -859,3 +863,4 @@ FILE fqName:<root> fileName:/ArrayMap.kt
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.ArrayMap
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
FILE fqName:<root> fileName:/kt45236.kt
|
||||
CLASS CLASS name:NetRequestStatus modality:SEALED visibility:public superTypes:[kotlin.Any]
|
||||
sealedSubclasses:
|
||||
CLASS CLASS name:Error modality:FINAL visibility:public [data] superTypes:[<root>.NetRequestStatus<T of <root>.NetRequestStatus.Error>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.NetRequestStatus<T of <root>.NetRequestStatus>
|
||||
TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any]
|
||||
CONSTRUCTOR visibility:protected <> () returnType:<root>.NetRequestStatus<T of <root>.NetRequestStatus> [primary]
|
||||
|
||||
Reference in New Issue
Block a user