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,9 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
// It's ALLOWED to inherit Sealed also here
object Fourth: Sealed(78)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,16 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
}
fun foo(s: Sealed): Int {
return when(s) {
is Sealed.First -> 1
is Sealed.NonFirst -> 0
// no else required
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,16 +0,0 @@
sealed class Sealed() {
object First: Sealed()
open class NonFirst: Sealed() {
object Second: NonFirst()
object Third: NonFirst()
// It's ALLOWED to inherit Sealed also from here
object Fourth: Sealed()
}
}
fun foo(s: Sealed) = when(s) {
Sealed.First -> 1
is Sealed.NonFirst -> 2
Sealed.NonFirst.Fourth -> 4
// no else required
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed() {
object First: Sealed()
open class NonFirst: Sealed() {
@@ -1,16 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
}
fun foo(s: Sealed): Int {
return when(s) {
is Sealed.First -> 1
!is Sealed.First -> 0
// no else required
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,17 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
object Last: Sealed(78)
}
fun foo(s: Sealed): Int {
return when(s) {
!is Sealed.First -> 1
!is Sealed.Last -> 0
// no else required
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,17 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
}
fun foo(s: Sealed?): Int {
return when(s) {
is Sealed.First -> 1
is Sealed.NonFirst -> 0
null -> -1
// no else required
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,18 +0,0 @@
sealed class Sealed(val x: Int) {
data class Tuple(val x: Int, val y: Int)
object First: Sealed(12)
open class NonFirst(tuple: Tuple): Sealed(tuple.x) {
val y: Int = tuple.y
object Second: NonFirst(Tuple(34, 2))
object Third: NonFirst(Tuple(56, 3))
}
}
fun foo(s: Sealed): Int {
return when(s) {
is Sealed.First -> 1
is Sealed.NonFirst -> 0
// no else required
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
data class Tuple(val x: Int, val y: Int)
object First: Sealed(12)
@@ -1,15 +0,0 @@
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
}
fun foo(s: Sealed): Int {
return when(s) {
is Sealed.NonFirst -> 0
else -> -1
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
@@ -1,10 +0,0 @@
// See KT-9244
sealed class Foo {
class Bar : Foo()
class Baz : Foo()
}
// The following warning seems incorrect here
// "Foo is a final type, and thus a value of the type parameter is predetermined"
fun <T : Foo> doit(arg: T): T = arg
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// See KT-9244
sealed class Foo {
@@ -1,20 +0,0 @@
sealed class Operation(val left: Int, val right: Int) {
abstract fun exec(): Int
class Plus(left: Int, right: Int): Operation(left, right) {
override fun exec(): Int = left + right
}
class Minus(left: Int, right: Int): Operation(left, right) {
override fun exec(): Int = left - right
}
class Times(left: Int, right: Int): Operation(left, right) {
override fun exec(): Int = left * right
}
class Slash(left: Int, right: Int): Operation(left, right) {
override fun exec(): Int = left / right
}
}
fun priority(op: Operation) = when(op) {
is Operation.Plus, is Operation.Minus -> 1
is Operation.Times, is Operation.Slash -> 2
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
sealed class Operation(val left: Int, val right: Int) {
abstract fun exec(): Int
class Plus(left: Int, right: Int): Operation(left, right) {
@@ -1,10 +0,0 @@
interface Parent
interface Child : Parent
sealed class Page : Parent {
object One : Page(), Child
object Two : Page(), Child
}
// Ok: page is a Parent so it can be easily a Child
fun test(page: Page): Boolean = page is Child
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface Parent
interface Child : Parent