[FIR] Add test with potential recursive call in compiler FE on when with sealed class inside it (KT-18583)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d1d6b8b77a
commit
3636046e2d
@@ -0,0 +1,11 @@
|
||||
// Issue: KT-18583
|
||||
|
||||
sealed class Maybe<T> {
|
||||
class Nope<T>(val reasonForLog: String, val reasonForUI: String) : Maybe<T>()
|
||||
class Yeah<T>(val meat: T) : Maybe<T>()
|
||||
|
||||
fun unwrap() = when (this) {
|
||||
is Nope -> throw Exception("")
|
||||
is Yeah -> meat
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
FILE: recursiveCallOnWhenWithSealedClass.kt
|
||||
public sealed class Maybe<T> : R|kotlin/Any| {
|
||||
private constructor<T>(): R|Maybe<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final class Nope<T> : R|Maybe<T>| {
|
||||
public constructor<T>(reasonForLog: R|kotlin/String|, reasonForUI: R|kotlin/String|): R|Maybe.Nope<T>| {
|
||||
super<R|Maybe<T>|>()
|
||||
}
|
||||
|
||||
public final val reasonForLog: R|kotlin/String| = R|<local>/reasonForLog|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final val reasonForUI: R|kotlin/String| = R|<local>/reasonForUI|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
|
||||
public final class Yeah<T> : R|Maybe<T>| {
|
||||
public constructor<T>(meat: R|T|): R|Maybe.Yeah<T>| {
|
||||
super<R|Maybe<T>|>()
|
||||
}
|
||||
|
||||
public final val meat: R|T| = R|<local>/meat|
|
||||
public get(): R|T|
|
||||
|
||||
}
|
||||
|
||||
public final fun unwrap(): R|class error: Unresolved name: meat| {
|
||||
^unwrap when (this#) {
|
||||
($subj$ is R|Maybe.Nope|) -> {
|
||||
throw R|java/lang/Exception.Exception|(String())
|
||||
}
|
||||
($subj$ is R|Maybe.Yeah|) -> {
|
||||
<Unresolved name: meat>#
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -94,6 +94,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
runTest("compiler/fir/resolve/testData/resolve/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveCallOnWhenWithSealedClass.kt")
|
||||
public void testRecursiveCallOnWhenWithSealedClass() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/recursiveCallOnWhenWithSealedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/simpleClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user