[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class C(val f : () -> Unit)
|
||||
|
||||
fun test(e : Any) {
|
||||
if (e is C) {
|
||||
(e.f)()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun f1(s: String?) {
|
||||
if (s!! == "");
|
||||
checkSubtype<String>(s)
|
||||
}
|
||||
|
||||
fun f2(s: Number?) {
|
||||
if (s is Int);
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(s)
|
||||
if (s as Int == 42);
|
||||
checkSubtype<Int>(s)
|
||||
}
|
||||
|
||||
fun f3(s: Number?) {
|
||||
if (s is Int && s as Int == 42);
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(s)
|
||||
}
|
||||
|
||||
fun f4(s: Int?) {
|
||||
var u = if (s!! == 42);
|
||||
if (u == Unit) u = if (s == 239);
|
||||
return u
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun f(a: Boolean, b: Int) {}
|
||||
|
||||
fun foo(a: Any) {
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(a is Int, a)
|
||||
1 <!INAPPLICABLE_CANDIDATE!>+<!> a
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
interface Expr
|
||||
class BinOp(val operator : String) : Expr
|
||||
|
||||
fun test(e : Expr) {
|
||||
if (e is BinOp) {
|
||||
when (e.operator) {
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fun test(a: Any?) {
|
||||
if (a == null) return
|
||||
a.hashCode()
|
||||
|
||||
val b = a
|
||||
b.hashCode()
|
||||
|
||||
val c: Any? = a
|
||||
c.hashCode()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// KT-6118 Redundant type cast can be not redundant?
|
||||
|
||||
fun foo(o: Any) {
|
||||
if (o is String) {
|
||||
val s = o as String
|
||||
s.length
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(o: Any) {
|
||||
if (o is String) {
|
||||
o.length
|
||||
val s = o
|
||||
s.length
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(a: Any?, flag: Boolean, x: Any?) {
|
||||
if (a !is String) return
|
||||
a.length
|
||||
|
||||
val b: Any?
|
||||
|
||||
if (flag) {
|
||||
b = a
|
||||
b.length
|
||||
}
|
||||
else {
|
||||
b = x
|
||||
b.<!UNRESOLVED_REFERENCE!>length<!>()
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(a: Any?, flag: Boolean, x: Any?) {
|
||||
if (a == null) return
|
||||
a.hashCode()
|
||||
|
||||
val b: Any?
|
||||
|
||||
if (flag) {
|
||||
b = a
|
||||
b.hashCode()
|
||||
}
|
||||
else {
|
||||
b = x
|
||||
b.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test(a: Any?) {
|
||||
when (a) {
|
||||
is String -> {
|
||||
val s = a
|
||||
s.length
|
||||
}
|
||||
"" -> {
|
||||
val s = a
|
||||
s.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
open class Base(x: String, y: Int)
|
||||
|
||||
fun test(x: Any, y: Int?) {
|
||||
if (x !is String) return
|
||||
if (y == null) return
|
||||
|
||||
class Local: Base(x, y) {
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class Local(s: String = x) {
|
||||
fun foo(s: String = x): String = s
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class Del {
|
||||
operator fun getValue(_this: Any?, p: KProperty<*>): Int = 0
|
||||
}
|
||||
|
||||
fun df(del: Del): Del = del
|
||||
|
||||
|
||||
fun test(del: Any?) {
|
||||
if (del !is Del) return
|
||||
|
||||
class Local {
|
||||
val delegatedVal by <!INAPPLICABLE_CANDIDATE!>df<!>(del)
|
||||
val delegatedVal1: Int by <!INAPPLICABLE_CANDIDATE!>df<!>(del)
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface D {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local : D by d {
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
interface D {
|
||||
fun foo(): String = ""
|
||||
}
|
||||
|
||||
fun test(d: Any?) {
|
||||
if (d !is D) return
|
||||
|
||||
class Local {
|
||||
fun f() {
|
||||
d.foo()
|
||||
}
|
||||
|
||||
fun f1() = d.foo()
|
||||
|
||||
fun f2(): String = d.foo()
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
fun foo(y: Any) {
|
||||
if (y !is String) return
|
||||
class Local {
|
||||
init {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// KT-338 Support.smartcasts in nested declarations
|
||||
|
||||
fun f(a: Any?) {
|
||||
if (a is B) {
|
||||
class C : X(a) {
|
||||
init {
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface B {
|
||||
fun foo() {}
|
||||
}
|
||||
open class X(b: B)
|
||||
@@ -0,0 +1,12 @@
|
||||
fun test(x: Any?) {
|
||||
if (x !is String) return
|
||||
|
||||
class C {
|
||||
val v = x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
|
||||
val vGet: Int
|
||||
get() = x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
|
||||
val s: String = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo(x: Any?) {
|
||||
if (x is String) {
|
||||
object : Base(x) {
|
||||
fun bar() = x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class Base(s: String)
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// KT-2225 Object expression delegation parameter should be checked with data flow info
|
||||
|
||||
interface A {
|
||||
fun foo() : Int
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun foo() = 10
|
||||
}
|
||||
fun foo(b: B?) : Int {
|
||||
if (b == null) return 0
|
||||
val o = object : A by b { //no info about b not null check
|
||||
}
|
||||
return o.foo()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fun test(x: Any) {
|
||||
if (x !is String) return
|
||||
|
||||
class LocalOuter {
|
||||
inner class Local {
|
||||
init {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
open class X(val s: String)
|
||||
|
||||
fun f(a: String?) {
|
||||
if (a != null) {
|
||||
object : X(a) { // Type mismatch: inferred type is kotlin.String? but kotlin.String was expected
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user