[FIR] Add regression tests for number of issues fixed in K2
List of issues: KT-4113, KT-6822, KT-7389, KT-17817, KT-20223 KT-21463, KT-24503, KT-24737, KT-24779, KT-24901 KT-27261, KT-28668, KT-30497, KT-30756, KT-36958 KT-37365, KT-37490, KT-38288, KT-41038, KT-41721 KT-42136, KT-42169, KT-42449, KT-42715, KT-43553 KT-43603, KT-43846, KT-43936, KT-46288, KT-46301 KT-47373, KT-47484, KT-47490, KT-47495, KT-47750 KT-47815, KT-47870, KT-48975, KT-49024, KT-49045 KT-50134, KT-50160, KT-50550, KT-51045, KT-51143 KT-51796, KT-52262, KT-52424, KT-52860, KT-52934 KT-53086, KT-53494, KT-53671, KT-53752, KT-53819 KT-54478, KT-54518, KT-54931, KT-54990, KT-55138 KT-55379, KT-55555, KT-56243
This commit is contained in:
committed by
Space Team
parent
8ae5213155
commit
aef9b129d2
+23
@@ -0,0 +1,23 @@
|
||||
FILE: assignToBoundSmartcastedVariable.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface B : R|kotlin/Any| {
|
||||
public abstract fun fooB(x: R|kotlin/Int|): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(ab: R|A|): R|kotlin/Unit| {
|
||||
when () {
|
||||
(R|<local>/ab| is R|B|) -> {
|
||||
lvar z: R|it(B & A)| = R|/id|<R|it(B & A)|>(R|<local>/ab|)
|
||||
R|<local>/z| = R|/Foo.Foo<CS errors: /Foo.Foo>#|()
|
||||
R|<local>/z|.R|/B.fooB|(Int(1))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-53752
|
||||
// INFERENCE_HELPERS
|
||||
|
||||
interface A
|
||||
interface B {
|
||||
fun fooB(x: Int): String
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
fun test(ab: A) {
|
||||
if (ab is B) {
|
||||
var z = id(ab) // materialize smartcast
|
||||
z = <!ASSIGNMENT_TYPE_MISMATCH!>Foo()<!> // unsafe assignment
|
||||
z.fooB(1)
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE: boundSmartcastWithProjection.kt
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(data: R|T|): R|Inv<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val data: R|T| = R|<local>/data|
|
||||
public get(): R|T|
|
||||
|
||||
}
|
||||
public final fun test1(x: R|Inv<out kotlin/String?>|): R|kotlin/Unit| {
|
||||
lval y: R|kotlin/String?| = R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/String?)|>|
|
||||
when (R|<local>/y|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/String?)|>|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test2(x: R|Inv<out kotlin/Any?>|): R|kotlin/Unit| {
|
||||
lval y: R|kotlin/Any?| = R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/Any?)|>|
|
||||
when (R|<local>/y|) {
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
R|<local>/x|.R|SubstitutionOverride</Inv.data: R|CapturedType(out kotlin/Any?)|>|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-24779
|
||||
|
||||
class Inv<T>(val data: T)
|
||||
|
||||
fun test1(x: Inv<out String?>) {
|
||||
val y = x.data
|
||||
when (y) {
|
||||
is String -> x.data.length // Smart cast: x.data is String
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Inv<out Any?>) {
|
||||
val y = x.data
|
||||
when (y) {
|
||||
is String -> x.data.length // No smart cast, UNRESOLVED_REFERENCE: length
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user