Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed

This commit is contained in:
Mikhail Glukhikh
2020-03-04 17:54:33 +03:00
parent 186e0b0cba
commit 8884cbe415
2268 changed files with 1175 additions and 19754 deletions
@@ -1,12 +0,0 @@
fun x(): Boolean { return true }
public fun foo(pp: Any): Int {
var p = pp
do {
(p as String).length
if (p == "abc") break
p = 42
} while (!x())
// Smart cast is NOT possible here
return p.<!UNRESOLVED_REFERENCE!>length<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun x(): Boolean { return true }
public fun foo(pp: Any): Int {
@@ -1,8 +0,0 @@
fun foo() {
var v: Any = "xyz"
// It is possible in principle to provide smart cast here
// but now we decide that v is Any
v.<!UNRESOLVED_REFERENCE!>length<!>()
v = 42
v.<!UNRESOLVED_REFERENCE!>length<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun foo() {
var v: Any = "xyz"
// It is possible in principle to provide smart cast here
@@ -1,23 +0,0 @@
interface A {
fun ok(): Boolean
}
class B: A {
override fun ok(): Boolean { return true }
}
class C: A {
override fun ok(): Boolean { return false }
}
fun foo(): Boolean {
var v: A
v = B()
// No smart cast needed, but not a problem if ever
if (v.ok()) {
v = C()
}
// No smart cast needed, and no smart cast possible!
// We cannot choose between B and C
return v.ok()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface A {
fun ok(): Boolean
}
@@ -1,10 +0,0 @@
class MyClass(var p: String?)
fun bar(s: String?): Int {
return s?.length ?: -1
}
fun foo(m: MyClass): Int {
m.p = "xyz"
return bar(m.p)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class MyClass(var p: String?)
fun bar(s: String?): Int {
@@ -1,10 +0,0 @@
class MyClass(var p: Any)
fun bar(s: Any): Int {
return s.hashCode()
}
fun foo(m: MyClass): Int {
m.p = "xyz"
return bar(m.p)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class MyClass(var p: Any)
fun bar(s: Any): Int {
@@ -1,10 +0,0 @@
fun bar(s: Any): Int {
return s.hashCode()
}
class MyClass(var p: Any) {
fun foo(): Int {
p = "xyz"
return bar(p)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun bar(s: Any): Int {
return s.hashCode()
}
@@ -1,13 +0,0 @@
fun bar(s: Any): Int {
return s.hashCode()
}
class MyClass(var p: Any) {
fun foo(): Int {
p = "xyz"
if (p is String) {
return bar(p)
}
return -1
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun bar(s: Any): Int {
return s.hashCode()
}
@@ -1,13 +0,0 @@
fun x(): Boolean { return true }
public fun foo(pp: Any): Int {
var p = pp
while(true) {
(p as String).length
if (x()) break
p = 42
}
// Smart cast is NOT possible here
// (we could provide it but p = 42 makes it difficult to understand)
return p.<!UNRESOLVED_REFERENCE!>length<!>()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun x(): Boolean { return true }
public fun foo(pp: Any): Int {