[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
// See KT-6293: Smart cast doesn't work after object literal
|
||||
abstract class Runnable {
|
||||
abstract fun run()
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
if (c is Int) {
|
||||
var k: Runnable
|
||||
val d: Int = c
|
||||
k = object: Runnable() {
|
||||
override fun run() = Unit
|
||||
}
|
||||
// Unnecessary but not important smart cast
|
||||
k.run()
|
||||
return c + d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// See KT-6293: Smart cast doesn't work after object literal
|
||||
abstract class Runnable {
|
||||
abstract fun run()
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
if (c is Int) {
|
||||
val d: Int = c
|
||||
// This object breaks data flow info propagation
|
||||
val k = object: Runnable() {
|
||||
override fun run() = Unit
|
||||
}
|
||||
k.run()
|
||||
// Smart cast should work but error is reported
|
||||
return c + d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
abstract class Runnable {
|
||||
abstract fun run()
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
var a: Int?
|
||||
if (c is Int) {
|
||||
a = 2
|
||||
val k = object: Runnable() {
|
||||
init {
|
||||
a = null
|
||||
}
|
||||
override fun run() = Unit
|
||||
}
|
||||
k.run()
|
||||
val d: Int = c
|
||||
// a is captured so smart cast is not possible
|
||||
return d + a
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
abstract class Runnable {
|
||||
abstract fun run()
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
val a: Int? = 1
|
||||
if (c is Int) {
|
||||
val k = object: Runnable() {
|
||||
init {
|
||||
a!!.toInt()
|
||||
}
|
||||
override fun run() = Unit
|
||||
}
|
||||
k.run()
|
||||
val d: Int = c
|
||||
// a is not null because of k constructor, but we do not know it
|
||||
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
abstract class Runnable(val arg: Int) {
|
||||
abstract fun run(): Int
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
val a: Int? = 1
|
||||
if (c is Int) {
|
||||
val k = object: Runnable(a!!) {
|
||||
override fun run() = arg
|
||||
}
|
||||
k.run()
|
||||
val d: Int = c
|
||||
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
abstract class Runnable(val arg: Int) {
|
||||
abstract fun run(): Int
|
||||
}
|
||||
|
||||
interface Wrapper {
|
||||
fun run(): Int
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
val a: Int? = 1
|
||||
if (c is Int) {
|
||||
val k = object: Wrapper, Runnable(a!!) {
|
||||
override fun run() = arg
|
||||
}
|
||||
k.run()
|
||||
val d: Int = c
|
||||
return a <!INAPPLICABLE_CANDIDATE!>+<!> d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Anonymous object's initialization does not affect smart casts
|
||||
|
||||
abstract class A(val s: String) {
|
||||
fun bar(): String = s
|
||||
}
|
||||
|
||||
fun foo(o: String?): Int {
|
||||
val a = object : A(o!!){}
|
||||
a.bar()
|
||||
return o.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// See KT-6293: Smart cast doesn't work after object literal
|
||||
abstract class Runnable {
|
||||
abstract fun run()
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
val c: Int? = null
|
||||
if (c is Int) {
|
||||
val d: Int = c
|
||||
object: Runnable() {
|
||||
override fun run() = Unit
|
||||
}.run()
|
||||
return c + d
|
||||
}
|
||||
else return -1
|
||||
}
|
||||
Reference in New Issue
Block a user