Test data fixed
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<info>open</info> class A() {
|
<info descr="null">open</info> class A() {
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,25 +9,25 @@ class B() : A() {
|
|||||||
fun f9() {
|
fun f9() {
|
||||||
val a : A?
|
val a : A?
|
||||||
a?.foo()
|
a?.foo()
|
||||||
a?.<error>bar</error>()
|
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
if (a is B) {
|
if (a is B) {
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
a.foo()
|
<info descr="Automatically cast to A">a</info>.foo()
|
||||||
}
|
}
|
||||||
a?.foo()
|
a?.foo()
|
||||||
a?.<error>bar</error>()
|
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
if (!(a is B)) {
|
if (!(a is B)) {
|
||||||
a?.<error>bar</error>()
|
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
a?.foo()
|
a?.foo()
|
||||||
}
|
}
|
||||||
if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == ()) {
|
if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == ()) {
|
||||||
a?.<error>bar</error>()
|
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
}
|
}
|
||||||
if (!(a is B)) {
|
if (!(a is B)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
a.foo()
|
<info descr="Automatically cast to A">a</info>.foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f10() {
|
fun f10() {
|
||||||
@@ -47,19 +47,17 @@ class C() : A() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun f10(a : A?) {
|
fun f10(a : A?) {
|
||||||
if (a is B) {
|
|
||||||
if (a is C) {
|
if (a is C) {
|
||||||
<info descr="Automatically cast to C">a</info>.bar();
|
<info descr="Automatically cast to C">a</info>.bar();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f11(a : A?) {
|
fun f11(a : A?) {
|
||||||
when (a) {
|
when (a) {
|
||||||
is B => <info descr="Automatically cast to B">a</info>.bar()
|
is B => <info descr="Automatically cast to B">a</info>.bar()
|
||||||
is A => a.foo()
|
is A => <info descr="Automatically cast to A">a</info>.foo()
|
||||||
is Any => a.foo()
|
is Any => <info descr="Automatically cast to A">a</info>.foo()
|
||||||
is Any? => a.<error>bar</error>()
|
is Any? => a.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
else => a?.foo()
|
else => a?.foo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,21 +65,21 @@ fun f11(a : A?) {
|
|||||||
fun f12(a : A?) {
|
fun f12(a : A?) {
|
||||||
when (a) {
|
when (a) {
|
||||||
is B => <info descr="Automatically cast to B">a</info>.bar()
|
is B => <info descr="Automatically cast to B">a</info>.bar()
|
||||||
is A => a.foo()
|
is A => <info descr="Automatically cast to A">a</info>.foo()
|
||||||
is Any => a.foo();
|
is Any => <info descr="Automatically cast to A">a</info>.foo();
|
||||||
is Any? => a.<error>bar</error>()
|
is Any? => a.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
is val c : <error>B</error> => c.foo()
|
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> => c.foo()
|
||||||
is val c is C => <info descr="Automatically cast to C">c</info>.bar()
|
is val c is C => <info descr="Automatically cast to C">c</info>.bar()
|
||||||
is val c is C => <info descr="Automatically cast to C">a</info>.bar()
|
is val c is C => <info descr="Automatically cast to C">a</info>.bar()
|
||||||
else => a?.foo()
|
else => a?.foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a is val b) {
|
if (a is val b) {
|
||||||
a?.<error>bar</error>()
|
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||||
b?.foo()
|
b?.foo()
|
||||||
}
|
}
|
||||||
if (a is val b is B) {
|
if (a is val b is B) {
|
||||||
b.foo()
|
<info descr="Automatically cast to A">b</info>.foo()
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
<info descr="Automatically cast to B">b</info>.bar()
|
<info descr="Automatically cast to B">b</info>.bar()
|
||||||
}
|
}
|
||||||
@@ -89,41 +87,41 @@ fun f12(a : A?) {
|
|||||||
|
|
||||||
fun f13(a : A?) {
|
fun f13(a : A?) {
|
||||||
if (a is val c is B) {
|
if (a is val c is B) {
|
||||||
c.foo()
|
<info descr="Automatically cast to A">c</info>.foo()
|
||||||
<info descr="Automatically cast to B">c</info>.bar()
|
<info descr="Automatically cast to B">c</info>.bar()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a?.foo()
|
a?.foo()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
a?.foo()
|
a?.foo()
|
||||||
if (!(a is val c is B)) {
|
if (!(a is val c is B)) {
|
||||||
a?.foo()
|
a?.foo()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a.foo()
|
<info descr="Automatically cast to A">a</info>.foo()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
a?.foo()
|
a?.foo()
|
||||||
if (a is val c is B && a.foo() == () && <info descr="Automatically cast to B">c</info>.bar() == ()) {
|
if (a is val c is B && <info descr="Automatically cast to A">a</info>.foo() == () && <info descr="Automatically cast to B">c</info>.bar() == ()) {
|
||||||
c.foo()
|
<info descr="Automatically cast to A">c</info>.foo()
|
||||||
<info descr="Automatically cast to B">c</info>.bar()
|
<info descr="Automatically cast to B">c</info>.bar()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a?.foo()
|
a?.foo()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a is val c is B) || !(a is val x is C)) {
|
if (!(a is val c is B) || !(a is val x is C)) {
|
||||||
<error>x</error>
|
<error descr="Unresolved reference: x">x</error>
|
||||||
<error>c</error>
|
<error descr="Unresolved reference: c">c</error>
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
<error>x</error>
|
<error descr="Unresolved reference: x">x</error>
|
||||||
<error>c</error>
|
<error descr="Unresolved reference: c">c</error>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a is val c is B) || !(a is val c is C)) {
|
if (!(a is val c is B) || !(a is val c is C)) {
|
||||||
@@ -131,38 +129,38 @@ fun f13(a : A?) {
|
|||||||
|
|
||||||
if (!(a is val c is B)) return
|
if (!(a is val c is B)) return
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
<error>c</error>.foo()
|
<error descr="Unresolved reference: c">c</error>.foo()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f14(a : A?) {
|
fun f14(a : A?) {
|
||||||
while (!(a is val c is B)) {
|
while (!(a is val c is B)) {
|
||||||
}
|
}
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
fun f15(a : A?) {
|
fun f15(a : A?) {
|
||||||
do {
|
do {
|
||||||
} while (!(a is val c is B))
|
} while (!(a is val c is B))
|
||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
<error>c</error>.bar()
|
<error descr="Unresolved reference: c">c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStringLength(obj : Any) : Char? {
|
fun getStringLength(obj : Any) : Char? {
|
||||||
if (obj !is String)
|
if (obj !is String)
|
||||||
return null
|
return null
|
||||||
return <info>obj</info>.get(0) // no cast to String is needed
|
return <info descr="Automatically cast to String">obj</info>.get(0) // no cast to String is needed
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to Int">i</info> else 0
|
fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to Int">i</info> else 0
|
||||||
fun illegalWhenBody(a: Any): Int = when(a) {
|
fun illegalWhenBody(a: Any): Int = when(a) {
|
||||||
is Int => <info descr="Automatically cast to Int">a</info>
|
is Int => <info descr="Automatically cast to Int">a</info>
|
||||||
is String => <error>a</error>
|
is String => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
|
||||||
}
|
}
|
||||||
fun illegalWhenBlock(a: Any): Int {
|
fun illegalWhenBlock(a: Any): Int {
|
||||||
when(a) {
|
when(a) {
|
||||||
is Int => return <info descr="Automatically cast to Int">a</info>
|
is Int => return <info descr="Automatically cast to Int">a</info>
|
||||||
is String => return <error>a</error>
|
is String => return <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun declarations(a: Any?) {
|
fun declarations(a: Any?) {
|
||||||
@@ -188,17 +186,17 @@ fun vars(a: Any?) {
|
|||||||
}
|
}
|
||||||
fun tuples(a: Any?) {
|
fun tuples(a: Any?) {
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
val s: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <error>a</error>)
|
val s: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
|
||||||
}
|
}
|
||||||
if (a is String) {
|
if (a is String) {
|
||||||
val s: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
|
val s: (Any, String) = (<info descr="Automatically cast to String">a</info>, <info descr="Automatically cast to String">a</info>)
|
||||||
}
|
}
|
||||||
fun illegalTupleReturnType(): (Any, String) = (<error>a</error>, <error>a</error>)
|
fun illegalTupleReturnType(): (Any, String) = (<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Any was expected">a</error>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
|
||||||
if (a is String) {
|
if (a is String) {
|
||||||
fun legalTupleReturnType(): (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
|
fun legalTupleReturnType(): (Any, String) = (<info descr="Automatically cast to String">a</info>, <info descr="Automatically cast to String">a</info>)
|
||||||
}
|
}
|
||||||
val illegalFunctionLiteral: Function0<Int> = <error>{ <error>a</error> }</error>
|
val illegalFunctionLiteral: Function0<Int> = <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Function0<Any?> but Function0<Int> was expected">{ <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }</error>
|
||||||
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <error>a</error> }
|
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }
|
||||||
|
|
||||||
if (a is Int) {
|
if (a is Int) {
|
||||||
val legalFunctionLiteral: Function0<Int> = { <info descr="Automatically cast to Int">a</info> }
|
val legalFunctionLiteral: Function0<Int> = { <info descr="Automatically cast to Int">a</info> }
|
||||||
@@ -213,43 +211,43 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
|||||||
if (a is Int) { (): Int => <info descr="Automatically cast to Int">a</info> }
|
if (a is Int) { (): Int => <info descr="Automatically cast to Int">a</info> }
|
||||||
else { () => 1 }
|
else { () => 1 }
|
||||||
|
|
||||||
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error>a</error>)
|
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but String was expected">a</error>)
|
||||||
|
|
||||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
|
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
|
||||||
|
|
||||||
fun mergeAutocasts(a: Any?) {
|
fun mergeAutocasts(a: Any?) {
|
||||||
if (a is String || a is Int) {
|
if (a is String || a is Int) {
|
||||||
a.<error>compareTo</error>("")
|
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||||
a.toString()
|
a.toString()
|
||||||
}
|
}
|
||||||
if (a is Int || a is String) {
|
if (a is Int || a is String) {
|
||||||
a.<error>compareTo</error>("")
|
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||||
}
|
}
|
||||||
when (a) {
|
when (a) {
|
||||||
is String, is Any => a.<error>compareTo</error>("")
|
is String, is Any => a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||||
}
|
}
|
||||||
if (a is String && a is Any) {
|
if (a is String && a is Any) {
|
||||||
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
|
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
|
||||||
}
|
}
|
||||||
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
|
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
|
||||||
if (a is String || a.<error>compareTo</error>("") == 0) {}
|
if (a is String || a.<error descr="Unresolved reference: compareTo">compareTo</error>("") == 0) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mutability
|
//mutability
|
||||||
fun f(): String {
|
fun f(): String {
|
||||||
var a: Any = 11
|
var a: Any = 11
|
||||||
if (a is String) {
|
if (a is String) {
|
||||||
val i: String = <error>a</error>
|
val i: String = <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>
|
||||||
<error>a</error>.compareTo("f")
|
<error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>.compareTo("f")
|
||||||
val f: Function0<String> = { <error>a</error> }
|
val f: Function0<String> = { <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error> }
|
||||||
return <error>a</error>
|
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo(var a: Any): Int {
|
fun foo(var a: Any): Int {
|
||||||
if (a is Int) {
|
if (a is Int) {
|
||||||
return <error>a</error>
|
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to Int is impossible, because a could have changed since the is-check">a</error>
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
fun Int.foo() : Boolean = true
|
||||||
|
|
||||||
fun foo() : Int {
|
fun foo() : Int {
|
||||||
val s = ""
|
val s = ""
|
||||||
val x = 1
|
val x = 1
|
||||||
@@ -17,7 +19,8 @@ fun foo() : Int {
|
|||||||
else => 1
|
else => 1
|
||||||
}
|
}
|
||||||
return when (<!USELESS_ELVIS!>x<!>?:null) {
|
return when (<!USELESS_ELVIS!>x<!>?:null) {
|
||||||
<!UNSAFE_CALL!>.<!>equals(1) => 1
|
<!UNSAFE_CALL!>.<!>foo() => 1
|
||||||
|
.equals(1) => 1
|
||||||
?.equals(1).equals(2) => 1
|
?.equals(1).equals(2) => 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,9 @@ class C() : A() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun f10(a : A?) {
|
fun f10(a : A?) {
|
||||||
if (a is B) {
|
|
||||||
if (a is C) {
|
if (a is C) {
|
||||||
a.bar();
|
a.bar();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f11(a : A?) {
|
fun f11(a : A?) {
|
||||||
|
|||||||
Reference in New Issue
Block a user