[FIR] Fix exhaustiveness check in case of sealed subclass
The problem appear because check was performed only on direct children of sealed class. To fix this, heritage tree is built and used in check #KT-38989 Fixed
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
FILE: exhaustiveness_sealedSubClass.kt
|
||||
public sealed class A : R|kotlin/Any| {
|
||||
private constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public sealed class B : R|A| {
|
||||
private constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|A| {
|
||||
public constructor(): R|C| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
}
|
||||
public sealed class D : R|B| {
|
||||
private constructor(): R|D| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
}
|
||||
public sealed class E : R|B| {
|
||||
private constructor(): R|E| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test_1(e: R|A|): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
($subj$ is R|C|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|D|) -> {
|
||||
Int(2)
|
||||
}
|
||||
($subj$ is R|E|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
lval b: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
($subj$ is R|B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|C|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
lval c: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
($subj$ is R|B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|C|) -> {
|
||||
Int(2)
|
||||
}
|
||||
($subj$ is R|E|) -> {
|
||||
Int(3)
|
||||
}
|
||||
($subj$ is R|D|) -> {
|
||||
Int(4)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
lval d: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
($subj$ is R|E|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|A|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
}
|
||||
public final fun test_2(e: R|A|): R|kotlin/Unit| {
|
||||
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
($subj$ is R|D|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|E|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval b: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
($subj$ is R|B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|D|) -> {
|
||||
Int(2)
|
||||
}
|
||||
($subj$ is R|E|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval c: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
($subj$ is R|B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
($subj$ is R|D|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval d: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
($subj$ is R|C|) -> {
|
||||
Int(1)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
}
|
||||
Reference in New Issue
Block a user