[Test] Add regression tests for issues which are fixed in K2

Related issues:
KT-10879, KT-18055, KT-20617, KT-23873
KT-25668, KT-31191, KT-33108, KT-41013
KT-51827, KT-53886, KT-56624, KT-58447
KT-58458, KT-58751, KT-58814, KT-60597
KT-62806, KT-63258, KT-63444, KT-65101
KT-65408, KT-65844, KT-66186

^KT-65926 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-02-28 12:13:45 +02:00
committed by Space Team
parent b875ae774e
commit 4b5eac7816
79 changed files with 1719 additions and 0 deletions
@@ -0,0 +1,16 @@
// FULL_JDK
// WITH_REFLECT
// ISSUE: KT-58814
open class A
class B : A()
class C : A()
fun <T : A> createObj(implementedBy: Class<T>): T {
val obj = when (implementedBy) {
B::class.java -> B()
else -> throw Exception("unsupported class")
}
val castObj = implementedBy.cast(obj)
return castObj // should be OK
}
@@ -0,0 +1,16 @@
// FULL_JDK
// WITH_REFLECT
// ISSUE: KT-58814
open class A
class B : A()
class C : A()
fun <T : A> createObj(implementedBy: Class<T>): T {
val obj = when (implementedBy) {
B::class.java -> B()
else -> throw Exception("unsupported class")
}
val castObj = <!DEBUG_INFO_SMARTCAST!>implementedBy<!>.cast(obj)
return <!TYPE_MISMATCH!>castObj<!> // should be OK
}
@@ -0,0 +1,17 @@
// ISSUE: KT-10879
// FILE: A.java
public interface A {
A getFoo();
}
// FILE: main.kt
interface B : A
interface C : A
fun test(x: A) {
if (x !is C) return
if (x is B) {
x.foo.foo
x.getFoo().foo
}
}
@@ -0,0 +1,17 @@
// ISSUE: KT-10879
// FILE: A.java
public interface A {
A getFoo();
}
// FILE: main.kt
interface B : A
interface C : A
fun test(x: A) {
if (x !is C) return
if (x is B) {
x.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
x.getFoo().foo
}
}
@@ -0,0 +1,13 @@
// ISSUE: KT-18055
fun main() {
data class Stat(val link: String? = null)
var stat = Stat()
if (stat.link != null) {
takeString(stat.link)
}
}
fun takeString(link: String) {}
@@ -0,0 +1,13 @@
// ISSUE: KT-18055
fun main() {
data class Stat(val link: String? = null)
var stat = Stat()
if (stat.link != null) {
takeString(<!SMARTCAST_IMPOSSIBLE!>stat.link<!>)
}
}
fun takeString(link: String) {}