Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed
This commit is contained in:
-17
@@ -1,17 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(bal: Array<Int>) {
|
||||
var bar = 4
|
||||
|
||||
val a = { bar += 4 }
|
||||
checkSubtype<() -> Unit>(a)
|
||||
|
||||
val b = { bar = 4 }
|
||||
checkSubtype<() -> Unit>(b)
|
||||
|
||||
val c = { bal[2] = 3 }
|
||||
checkSubtype<() -> Unit>(c)
|
||||
|
||||
val d = run { bar += 4 }
|
||||
checkSubtype<Unit>(d)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(bal: Array<Int>) {
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A
|
||||
|
||||
operator fun A.component1() = 1
|
||||
operator fun A.component2() = ""
|
||||
|
||||
class B
|
||||
|
||||
class D {
|
||||
operator fun A.component1() = 1.0
|
||||
operator fun A.component2() = ' '
|
||||
|
||||
operator fun B.component1() = 1.0
|
||||
operator fun B.component2() = ' '
|
||||
}
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobaz(block: D.(B) -> Unit) { }
|
||||
fun foobar(block: D.(A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the same scope as the first statement of the lambda
|
||||
foobaz { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the same scope as the first statement of the lambda
|
||||
// So `component1`/`component2` for lambda parameters were resolved to member extensions
|
||||
foobar { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// the following code fails with exception, see KT-13873
|
||||
// foobarbaz {
|
||||
// component1: B.() -> Int,
|
||||
// component2: B.() -> String,
|
||||
// (a, b): B ->
|
||||
//
|
||||
// }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A
|
||||
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar(a: Double) {
|
||||
val b = 1.toShort()
|
||||
// Do not report NAME_SHADOWING on lambda destructured parameter, the same way as for common parameters
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (c, d) ->
|
||||
c checkType { _<Int>() }
|
||||
d checkType { _<String>() }
|
||||
|
||||
foo { (a, c) ->
|
||||
a checkType { _<Int>() }
|
||||
c checkType { _<String>() }
|
||||
d checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
fun test123() {
|
||||
val g: (Int) -> Unit = if (true) {
|
||||
val set = HashSet<Int>()
|
||||
fun (i: Int) {
|
||||
set.add(i)
|
||||
}
|
||||
}
|
||||
else {
|
||||
{ it -> it }
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
fun test123() {
|
||||
val g: (Int) -> Unit = if (true) {
|
||||
val set = HashSet<Int>();
|
||||
{ i ->
|
||||
set.add(i)
|
||||
}
|
||||
}
|
||||
else {
|
||||
{ it -> it }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> = TODO()
|
||||
operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> = TODO()
|
||||
|
||||
fun stringCollection(): Collection<String> = TODO()
|
||||
|
||||
fun <K> test(c: Collection<K>) {
|
||||
var variants = stringCollection()
|
||||
variants += variants.filter { true }
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> = TODO()
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
//KT-2906 If function parameter/variable is invoked in closure using parenthesis syntax, in IDEA it is not highlighted as captured in closure
|
||||
|
||||
package bug
|
||||
|
||||
public fun foo1(bar: () -> Unit) {
|
||||
run {
|
||||
bar() // ERROR: not highlighted as "captured in closure"
|
||||
}
|
||||
}
|
||||
|
||||
public fun foo2(bar: () -> Unit) {
|
||||
run {
|
||||
bar.invoke() // CORRECT: highlighted as "captured in closure"
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
foo1 { println ("foo1")} // prints "foo1"
|
||||
foo2 { println ("foo2")} // prints "foo2"
|
||||
}
|
||||
|
||||
fun println(s: String) = s
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-2906 If function parameter/variable is invoked in closure using parenthesis syntax, in IDEA it is not highlighted as captured in closure
|
||||
|
||||
package bug
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
// Issue: KT-35168
|
||||
|
||||
class Inv<T>
|
||||
|
||||
// Before the fix, here we had an exception while fixing a type variable for Inv due to prematurely analyzing a lambda
|
||||
// The exception was: "UninitializedPropertyAccessException: lateinit property subResolvedAtoms has not been initialized"
|
||||
class Foo<T>(x: (T) -> T, y: Inv<Any>)
|
||||
|
||||
fun bar() {
|
||||
Foo<Any>({}, Inv())
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
val flag = true
|
||||
|
||||
interface I
|
||||
class A(): I
|
||||
class B(): I
|
||||
|
||||
val a = l@ {
|
||||
return@l if (flag) A() else B()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
val flag = true
|
||||
|
||||
interface I
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
val flag = true
|
||||
|
||||
val a /*: (Int) -> String */ = l@ {
|
||||
i: Int ->
|
||||
if (i == 0) return@l i.toString()
|
||||
|
||||
"Ok"
|
||||
}
|
||||
|
||||
fun <T> foo(f: (Int) -> T): T = f(0)
|
||||
|
||||
val b /*:String */ = foo {
|
||||
i ->
|
||||
if (i == 0) return@foo i.toString()
|
||||
|
||||
"Ok"
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
val flag = true
|
||||
|
||||
val a /*: (Int) -> String */ = l@ {
|
||||
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test2() {
|
||||
val x = run f@{return@f 1}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test2() {
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run(f@{return@f 1})
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
|
||||
|
||||
fun test1() {
|
||||
val x = run(l@{return@l 1})
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run f@{
|
||||
fun local(a: Int): String {
|
||||
if (a > 0) return "2"
|
||||
return@local "3"
|
||||
}
|
||||
return@f 1
|
||||
}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
val x = run f@{
|
||||
run ff@ {
|
||||
return@ff "2"
|
||||
}
|
||||
return@f 1
|
||||
}
|
||||
checkSubtype<Int>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test() {
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
class A
|
||||
val flag = true
|
||||
|
||||
val a /*: () -> A?*/ = l@ {
|
||||
if (flag) return@l null
|
||||
|
||||
A()
|
||||
}
|
||||
|
||||
val b /*: () -> A?*/ = l@ {
|
||||
if (flag) return@l null
|
||||
|
||||
return@l A()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class A
|
||||
val flag = true
|
||||
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(a: Int) {
|
||||
val x = run f@{
|
||||
if (a > 0) return@f
|
||||
else return@f Unit
|
||||
}
|
||||
checkSubtype<Unit>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun test(a: Int) {
|
||||
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
val flag = true
|
||||
|
||||
// type of lambda was checked by txt
|
||||
val a = l@ { // () -> Any
|
||||
if (flag) return@l 4
|
||||
return@l Unit
|
||||
}
|
||||
|
||||
val b = l@ { // () -> Any
|
||||
if (flag) return@l Unit
|
||||
5
|
||||
}
|
||||
|
||||
val c = l@ { // () -> Unit
|
||||
if (flag) return@l Unit
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
val flag = true
|
||||
|
||||
// type of lambda was checked by txt
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface A
|
||||
interface B: A
|
||||
interface C: A
|
||||
|
||||
|
||||
fun test(a: C, b: B) {
|
||||
val x = run f@{
|
||||
if (a != b) return@f a
|
||||
b
|
||||
}
|
||||
checkSubtype<A>(x)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface A
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package m
|
||||
|
||||
interface Element
|
||||
|
||||
fun test(handlers: Map<String, Element.()->Unit>) {
|
||||
|
||||
handlers.getOrElse("name", { null })
|
||||
}
|
||||
|
||||
fun <K,V> Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue")
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
package m
|
||||
|
||||
interface Element
|
||||
|
||||
Reference in New Issue
Block a user