Introduce FIR_IDENTICAL for FIR vs old frontend tests #KT-36879 Fixed
This commit is contained in:
-24
@@ -1,24 +0,0 @@
|
||||
interface IFoo {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface IBar
|
||||
|
||||
private fun createAnonObject() =
|
||||
object : IFoo, IBar {
|
||||
override fun foo() {}
|
||||
fun qux() {}
|
||||
}
|
||||
|
||||
private val propOfAnonObject = object : IFoo, IBar {
|
||||
override fun foo() {}
|
||||
fun qux() {}
|
||||
}
|
||||
|
||||
fun useAnonObject() {
|
||||
createAnonObject().foo()
|
||||
createAnonObject().qux()
|
||||
|
||||
propOfAnonObject.foo()
|
||||
propOfAnonObject.qux()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
interface IFoo {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
@DslMarker
|
||||
annotation class MyDsl
|
||||
|
||||
@MyDsl
|
||||
interface Foo<T> {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
val Foo<*>.bad: Int get() = x
|
||||
|
||||
fun Foo<*>.badFun(): Int = x
|
||||
|
||||
val Foo<Int>.good: Int get() = x
|
||||
|
||||
fun test(foo: Foo<*>) {
|
||||
foo.apply {
|
||||
x
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
@DslMarker
|
||||
annotation class MyDsl
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@DslMarker
|
||||
annotation class MyDsl
|
||||
|
||||
@MyDsl
|
||||
interface Scope<A, B> {
|
||||
val something: A
|
||||
val value: B
|
||||
}
|
||||
fun scoped1(block: Scope<Int, String>.() -> Unit) {}
|
||||
fun scoped2(block: Scope<*, String>.() -> Unit) {}
|
||||
|
||||
val <T> Scope<*, T>.property: T get() = value
|
||||
|
||||
fun f() {
|
||||
scoped1 {
|
||||
value
|
||||
property
|
||||
}
|
||||
scoped2 {
|
||||
value
|
||||
property
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@DslMarker
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
@DslMarker
|
||||
annotation class AnnMarker
|
||||
|
||||
@AnnMarker
|
||||
class Inv<T> {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun Inv<*>.foo() {
|
||||
bar()
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
@DslMarker
|
||||
annotation class AnnMarker
|
||||
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
// !LANGUAGE: -DslMarkersSupport
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
annotation class Ann
|
||||
|
||||
@Ann
|
||||
class A {
|
||||
fun a() = 1
|
||||
}
|
||||
|
||||
@Ann
|
||||
class B {
|
||||
fun b() = 2
|
||||
}
|
||||
|
||||
fun foo(x: A.() -> Unit) {}
|
||||
fun bar(x: B.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
a()
|
||||
bar {
|
||||
a()
|
||||
this@foo.a()
|
||||
b()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: -DslMarkersSupport
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@DslMarker
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
class A(val b: String) {
|
||||
companion object {
|
||||
val c: String = ""
|
||||
}
|
||||
|
||||
fun mtd() = c.length
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
package b
|
||||
|
||||
// FILE: c.kt
|
||||
package c
|
||||
|
||||
// FILE: test.kt
|
||||
package test
|
||||
|
||||
import a.A
|
||||
|
||||
fun <T, R> T.with(f: T.() -> R) = f()
|
||||
|
||||
fun A.extFun1() = b.length
|
||||
|
||||
// fun A.extFun2() = c.length // TODO fix KT-9953
|
||||
|
||||
val x1 = A("").with { b.length }
|
||||
|
||||
// val x2 = A("").with { c.length } // TODO fix KT-9953
|
||||
|
||||
val x3 = A.with { c.length }
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> foo(f: () -> Collection<T>, p: (T) -> Boolean): Collection<T> = throw Exception()
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun test(): Collection<Int> = foo({ emptyList<Int>() }, { x -> x > 0 })
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T> foo(f: () -> Collection<T>, p: (T) -> Boolean): Collection<T> = throw Exception()
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
class B
|
||||
|
||||
class A {
|
||||
operator fun B.invoke() = 4
|
||||
}
|
||||
|
||||
class X {
|
||||
operator fun invoke() = 3
|
||||
}
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
with (a) {
|
||||
b()
|
||||
(b)()
|
||||
}
|
||||
|
||||
X()()
|
||||
val x = X()
|
||||
x()
|
||||
(x)()
|
||||
}
|
||||
|
||||
fun test(c: () -> String, e: Int.() -> String) {
|
||||
c()
|
||||
(c)()
|
||||
|
||||
3.e()
|
||||
3.(e)()
|
||||
with(3) {
|
||||
e()
|
||||
(e)()
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class B
|
||||
|
||||
class A {
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
class Foo {}
|
||||
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
//no variable
|
||||
fun test(foo: Foo) {
|
||||
foo()
|
||||
}
|
||||
|
||||
//variable as member
|
||||
interface A {
|
||||
val foo: Foo
|
||||
}
|
||||
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo()
|
||||
|
||||
with (a) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
//variable as extension
|
||||
interface B {
|
||||
}
|
||||
val B.foo: Foo
|
||||
get() = Foo()
|
||||
|
||||
fun test(b: B) {
|
||||
b.foo()
|
||||
|
||||
with (b) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
//variable as member extension
|
||||
interface C
|
||||
|
||||
interface D {
|
||||
val C.foo: Foo
|
||||
|
||||
fun test(c: C) {
|
||||
c.foo()
|
||||
|
||||
with (c) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(d: D, c: C) {
|
||||
with (d) {
|
||||
c.foo()
|
||||
|
||||
with (c) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo {}
|
||||
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
class Foo {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
|
||||
//no variable
|
||||
fun test(foo: Foo) {
|
||||
foo()
|
||||
}
|
||||
|
||||
//variable as member
|
||||
interface A {
|
||||
val foo: Foo
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.foo()
|
||||
|
||||
with (a) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
//variable as extension
|
||||
interface B {}
|
||||
val B.foo: Foo
|
||||
get() = Foo()
|
||||
|
||||
|
||||
fun test(b: B) {
|
||||
b.foo()
|
||||
|
||||
with (b) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
//variable as member extension
|
||||
interface C
|
||||
|
||||
interface D {
|
||||
val C.foo: Foo
|
||||
|
||||
fun test(c: C) {
|
||||
c.foo()
|
||||
|
||||
with (c) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(d: D, c: C) {
|
||||
with (d) {
|
||||
c.foo()
|
||||
|
||||
with (c) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
class Foo
|
||||
|
||||
//no variable
|
||||
interface A {
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
fun test(foo: Foo) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
//variable as member
|
||||
interface B {
|
||||
val foo: Foo
|
||||
}
|
||||
|
||||
class C {
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
fun test(b: B) {
|
||||
b.foo()
|
||||
|
||||
with (b) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(c: C, b: B) {
|
||||
with (c) {
|
||||
b.foo()
|
||||
|
||||
with (b) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//variable as extension,
|
||||
interface D {
|
||||
}
|
||||
val D.foo: Foo
|
||||
get() = Foo()
|
||||
|
||||
class E {
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
fun test(d: D) {
|
||||
d.foo()
|
||||
|
||||
with (d) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(e: E, d: D) {
|
||||
with (e) {
|
||||
d.foo()
|
||||
|
||||
with (d) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//variable as member extension
|
||||
interface F
|
||||
|
||||
interface G {
|
||||
val F.foo: Foo
|
||||
operator fun Foo.invoke()
|
||||
|
||||
fun test(f: F) {
|
||||
f.foo()
|
||||
|
||||
with (f) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(g: G, f: F) {
|
||||
with (g) {
|
||||
f.foo()
|
||||
|
||||
with (f) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//variable as member extension (2)
|
||||
interface X
|
||||
|
||||
interface U {
|
||||
val X.foo: Foo
|
||||
}
|
||||
|
||||
interface V {
|
||||
operator fun Foo.invoke() {}
|
||||
|
||||
fun U.test(x: X) {
|
||||
x.foo()
|
||||
|
||||
with (x) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test(u: U, v: V, x: X) {
|
||||
with (v) {
|
||||
with (u) {
|
||||
x.foo()
|
||||
|
||||
with (x) {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class Foo
|
||||
|
||||
//no variable
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||
|
||||
class C {
|
||||
fun f() {}
|
||||
}
|
||||
|
||||
fun C.g(f: (String) -> Unit = { s -> f() }) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||
|
||||
class C {
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
//KT-3833 Invoke method not working inside companion object?
|
||||
package m
|
||||
|
||||
class Either1 {
|
||||
class Left() {
|
||||
fun match(left: () -> Unit) {
|
||||
left()
|
||||
}
|
||||
}
|
||||
|
||||
inner class Right() {
|
||||
fun match(right: () -> Unit) {
|
||||
right()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class X {
|
||||
operator fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object Foo{
|
||||
val v : X = X()
|
||||
}
|
||||
|
||||
class C{
|
||||
companion object {
|
||||
fun f(){
|
||||
Foo.v()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-3833 Invoke method not working inside companion object?
|
||||
package m
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
//KT-4321 invoke() on enum doesn't work
|
||||
|
||||
import DOMElementTestClasses.cls2
|
||||
|
||||
// use case 1
|
||||
enum class DOMElementTestClasses {
|
||||
cls1, cls2;
|
||||
|
||||
operator fun invoke() {}
|
||||
}
|
||||
|
||||
|
||||
// use case 2
|
||||
interface EnumStyleClass {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
enum class TestClasses : EnumStyleClass {
|
||||
cls
|
||||
}
|
||||
|
||||
// example
|
||||
fun main() {
|
||||
// Kotlin: Expression 'cls1' of type 'DOMElementTestClasses' cannot be invoked as a function
|
||||
DOMElementTestClasses.cls1()
|
||||
|
||||
// Kotlin: Expression 'cls2' of type 'DOMElementTestClasses' cannot be invoked as a function
|
||||
cls2()
|
||||
|
||||
// Kotlin: Expression 'cls' of type 'TestClasses' cannot be invoked as a function
|
||||
TestClasses.cls()
|
||||
|
||||
// All ok
|
||||
val cls = DOMElementTestClasses.cls2
|
||||
cls()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-4321 invoke() on enum doesn't work
|
||||
|
||||
import DOMElementTestClasses.cls2
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
interface A
|
||||
|
||||
fun foo(invoke: A.()->Unit, a: A) {
|
||||
a.invoke()
|
||||
}
|
||||
|
||||
fun bar(invoke: Any.()->Any, a: Any) {
|
||||
a.invoke()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
interface A
|
||||
|
||||
fun foo(invoke: A.()->Unit, a: A) {
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
class A {
|
||||
companion object {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
fun test() {
|
||||
use(use(A, null).toString())
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class A {
|
||||
companion object {
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
interface Inv<I>
|
||||
|
||||
fun <S, T: S> Inv<T>.reduce2(): S = null!!
|
||||
|
||||
fun test(a: Inv<Int>): Int {
|
||||
val b = 1 + a.reduce2()
|
||||
return b
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
interface Inv<I>
|
||||
|
||||
fun <S, T: S> Inv<T>.reduce2(): S = null!!
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
interface Base {
|
||||
val parent: Base
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
override val parent: Base
|
||||
get() = TODO()
|
||||
}
|
||||
|
||||
fun test(d: Derived) {
|
||||
when {
|
||||
d.parent is Derived -> d.parent.parent
|
||||
}
|
||||
}
|
||||
|
||||
fun Any?.take() {}
|
||||
class Something {
|
||||
var prop: String? = null
|
||||
|
||||
fun String.take() {}
|
||||
|
||||
fun test() {
|
||||
if (prop is String) {
|
||||
prop.take()
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
interface Base {
|
||||
val parent: Base
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//If this test hangs, it means something is broken.
|
||||
object A {
|
||||
val iii = 42
|
||||
}
|
||||
|
||||
//inappropriate but participating in resolve functions
|
||||
fun foo(s: String, a: Any) = s + a
|
||||
|
||||
fun foo(a: Any, s: String) = s + a
|
||||
fun foo(i: Int, j: Int) = i + j
|
||||
fun foo(a: Any, i: Int) = "$a$i"
|
||||
fun foo(f: (Int) -> Int, i: Int) = f(i)
|
||||
fun foo(f: (String) -> Int, s: String) = f(s)
|
||||
fun foo(f: (Any) -> Int, a: Any) = f(a)
|
||||
fun foo(s: String, f: (String) -> Int) = f(s)
|
||||
fun foo(a: Any, f: (Any) -> Int) = f(a)
|
||||
//appropriate function
|
||||
fun foo(i: Int, f: (Int) -> Int) = f(i)
|
||||
|
||||
fun test() {
|
||||
foo(1, object : (Int) -> Int {
|
||||
override fun invoke(x1: Int) = foo(
|
||||
2, object : (Int) -> Int {
|
||||
override fun invoke(x2: Int) = foo(
|
||||
3, object : (Int) -> Int {
|
||||
override fun invoke(x3: Int): Int = foo(
|
||||
4, object : (Int) -> Int {
|
||||
override fun invoke(x4: Int): Int = foo(
|
||||
5, object : (Int) -> Int {
|
||||
override fun invoke(x5: Int): Int = x1 + x2 + x3 + x4 + x5 + A.iii
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//If this test hangs, it means something is broken.
|
||||
object A {
|
||||
val iii = 42
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
object Wrong
|
||||
|
||||
interface IA
|
||||
interface IB : IA
|
||||
fun IA.foo(vararg x: Int) = Wrong
|
||||
fun IB.foo(vararg x: Int) = Right
|
||||
class CC : IB
|
||||
|
||||
val test7 = CC().foo(1, 2, 3)
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
object Wrong
|
||||
|
||||
interface A<T>
|
||||
interface B<T> : A<T>
|
||||
|
||||
fun <T> foo(vararg t: T) = Wrong
|
||||
fun <T> foo(t: A<T>) = Wrong
|
||||
fun <T> foo(t: B<T>) = Right
|
||||
|
||||
fun test(b: B<Int>): Right = foo(b)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
object Wrong
|
||||
|
||||
fun overloadedFun(c: Any = "", b: String = "", f: Any = "") = Right
|
||||
fun overloadedFun(b: Any = "", c: Any = "", e: String = "", x: String = "", y: String = "") = Wrong
|
||||
|
||||
val test: Right = overloadedFun(b = "")
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
|
||||
compiler/testData/diagnostics/tests/resolve/overloadConflicts/varargWithMoreSpecificSignature.fir.kt
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Foo1
|
||||
object Foo2
|
||||
|
||||
fun foo(vararg ss: String) = Foo1
|
||||
fun foo(x: Any) = Foo2
|
||||
|
||||
val test1: Foo1 = foo("")
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Foo1
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
object Wrong
|
||||
|
||||
fun overloadedFun6(s1: String) = Right
|
||||
fun overloadedFun6(s1: String, s2: String) = Wrong
|
||||
fun overloadedFun6(s1: String, s2: String, s3: String) = Wrong
|
||||
fun overloadedFun6(s: String, vararg ss: String) = Wrong
|
||||
|
||||
val test6: Right = overloadedFun6("")
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
object Right
|
||||
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: J.java
|
||||
import java.util.*;
|
||||
|
||||
public class J {
|
||||
public static <E1 extends Enum<E1>> String foo(E1 e) { return ""; }
|
||||
public static <E2 extends Enum<E2>> String foo(E2 e1, E2 e2) { return ""; }
|
||||
public static <E3 extends Enum<E3>> String foo(E3 s1, E3 s2, E3 s3) { return ""; }
|
||||
public static <E4 extends Enum<E4>> int foo(E4... ss) { return 0; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
enum class X { A }
|
||||
val a = X.A
|
||||
|
||||
val test0: Int = J.foo<X>()
|
||||
val test1: String = J.foo(a)
|
||||
val test2: String = J.foo(a, a)
|
||||
val test3: String = J.foo(a, a, a)
|
||||
val test4: Int = J.foo(a, a, a, a)
|
||||
val test5: Int = J.foo(a, a, a, a, a)
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: J.java
|
||||
import java.util.*;
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
class A
|
||||
|
||||
class B {
|
||||
fun foo() = this
|
||||
}
|
||||
|
||||
fun test(foo: A.() -> Int) {
|
||||
with(A()) {
|
||||
foo() checkType { _<Int>() }
|
||||
with(B()) {
|
||||
foo() checkType { _<B>() }
|
||||
this.foo() checkType { _<B>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
class A {
|
||||
fun foo() = this
|
||||
}
|
||||
|
||||
fun test(foo: A.() -> Int) {
|
||||
with(A()) {
|
||||
foo() checkType { _<A>() }
|
||||
this.foo() checkType { _<A>() }
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// KT-9810 Local variable vs property from implicit receiver
|
||||
|
||||
class A {
|
||||
val foo = 2
|
||||
}
|
||||
|
||||
fun test(foo: String) {
|
||||
with(A()) {
|
||||
val g: String = foo // locals win
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// KT-9810 Local variable vs property from implicit receiver
|
||||
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public A getFoo() { return 3; }
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B {
|
||||
public B getFoo() { return ""; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
class C(val foo: C)
|
||||
|
||||
fun test(a: A, b: B, c: C) {
|
||||
with(a) {
|
||||
with(b) {
|
||||
foo checkType { _<B>() }
|
||||
}
|
||||
foo checkType { _<A>() }
|
||||
}
|
||||
|
||||
with(a) {
|
||||
with(c) {
|
||||
foo checkType { _<C>() }
|
||||
}
|
||||
}
|
||||
|
||||
with(c) {
|
||||
with(a) {
|
||||
foo checkType { _<A>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Repeatable
|
||||
annotation class Ann
|
||||
|
||||
fun <T> bar(block: (T) -> Int) {}
|
||||
|
||||
fun foo() {
|
||||
bar<Int> @Ann @[Ann] { x -> x }
|
||||
bar<Int> @Ann @[Ann] label@{ x -> x }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
object A {
|
||||
val iii = 42
|
||||
}
|
||||
|
||||
//inappropriate but participating in resolve functions
|
||||
//fun foo(s: String, a: Any) = s + a
|
||||
//fun foo(a: Any, s: String) = s + a
|
||||
//fun foo(i: Int, j: Int) = i + j
|
||||
//fun foo(a: Any, i: Int) = "$a$i"
|
||||
//fun foo(f: (Int)->Int, i: Int) = f(i)
|
||||
//fun foo(f: (String)->Int, s: String) = f(s)
|
||||
//fun foo(f: (Any)->Int, a: Any) = f(a)
|
||||
//fun foo(s: String, f: (String)->Int) = f(s)
|
||||
//fun foo(a: Any, f: (Any)->Int) = f(a)
|
||||
//appropriate function
|
||||
fun foo(i: Int, f: (Int)->Int) = f(i)
|
||||
|
||||
fun test() {
|
||||
foo(1) { x1: Int ->
|
||||
foo(2) { x2: Int ->
|
||||
foo(3) { x3: Int ->
|
||||
foo(4) { x4: Int ->
|
||||
foo(5) { x5: Int ->
|
||||
x1 + x2 + x3 + x4 + x5 + A.iii
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
object A {
|
||||
val iii = 42
|
||||
}
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
//If this test hangs, it means something is broken.
|
||||
object A {
|
||||
val iii = 42
|
||||
}
|
||||
|
||||
//inappropriate but participating in resolve functions
|
||||
fun foo(s: String, a: Any) = s + a
|
||||
fun foo(a: Any, s: String) = s + a
|
||||
fun foo(i: Int, j: Int) = i + j
|
||||
fun foo(a: Any, i: Int) = "$a$i"
|
||||
fun foo(f: (Int)->Int, i: Int) = f(i)
|
||||
fun foo(f: (String)->Int, s: String) = f(s)
|
||||
fun foo(f: (Any)->Int, a: Any) = f(a)
|
||||
fun foo(s: String, f: (String)->Int) = f(s)
|
||||
fun foo(a: Any, f: (Any)->Int) = f(a)
|
||||
//appropriate function
|
||||
fun foo(i: Int, f: (Int)->Int) = f(i)
|
||||
|
||||
fun test() {
|
||||
foo(1) { x1: Int ->
|
||||
foo(2) { x2: Int ->
|
||||
foo(3) { x3: Int ->
|
||||
foo(4) { x4: Int ->
|
||||
foo(5) { x5: Int ->
|
||||
x1 + x2 + x3 + x4 + x5 + A.iii
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//If this test hangs, it means something is broken.
|
||||
object A {
|
||||
val iii = 42
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {
|
||||
fun <T> bar(x: List<T> = listOf<T>()) {}
|
||||
}
|
||||
|
||||
fun <T> listOf(): List<T> = TODO()
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {
|
||||
|
||||
Reference in New Issue
Block a user