[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,9 @@
// !WITH_NEW_INFERENCE
class A {
operator fun component1() : Int = 1
operator fun component2() : Int = 2
}
fun a(aa : A) {
val (a: String, b1: String) = aa
}
@@ -0,0 +1,20 @@
class In<in T>
class Out<out T>
class Inv<T>
class X
fun f1(p: In<in X>) {}
fun f2(p: In<out X>) {}
fun f3(p: In<X>) {}
fun f4(p: Out<out X>) {}
fun f5(p: Out<in X>) {}
fun f6(p: Out<X>) {}
fun f6(p: Inv<X>) {}
fun f7(p: Inv<in X>) {}
fun f8(p: Inv<out X>) {}
fun f9(p: In<*>) {}
fun f10(p: Out<*>) {}
fun f11(p: Inv<*>) {}
@@ -0,0 +1,15 @@
// KT-2667 Support multi-declarations in for-loops in control flow analysis
package d
class A {
operator fun component1() = 1
operator fun component2() = 2
operator fun component3() = 3
}
fun foo(list: List<A>) {
for (var (c1, c2, c3) in list) {
c1 = 1
c3 + 1
}
}
@@ -0,0 +1,14 @@
class A {
operator fun component1() : Int = 1
operator fun component2() : Int = 2
}
fun a(aa : A?, b : Any) {
if (aa != null) {
val (a1, b1) = aa;
}
if (b is A) {
val (a1, b1) = b;
}
}
@@ -0,0 +1,26 @@
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
annotation class a
interface A
interface B
fun () {}
fun A.() {}
@a fun () {}
fun @a A.() {}
class Outer {
fun () {}
fun B.() {}
@a fun () {}
fun @a A.() {}
}
fun outerFun() {
fun () {}
fun B.() {}
@a fun () {}
fun @a A.() {}
}
@@ -0,0 +1,3 @@
fun test() {
val a
}
@@ -0,0 +1,21 @@
// !WITH_NEW_INFERENCE
package a
class MyClass {
fun component1(i: Int) {}
}
class MyClass2 {}
fun MyClass2.component1() = 1.2
fun MyClass2.component1() = 1.3
fun test(mc1: MyClass, mc2: MyClass2) {
val (<!INAPPLICABLE_CANDIDATE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>) = mc1
val (c) = mc2
//a,b,c are error types
use(a, b, c)
}
fun use(vararg a: Any?) = a
@@ -0,0 +1,15 @@
class A {
operator fun component1() : Int = 1
operator fun component2() : Int = 2
}
fun a() {
val (a, a) = A()
val (x, y) = A();
val b = 1
use(b)
val (b, y) = A();
}
fun use(a: Any): Any = a
@@ -0,0 +1,36 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// KT-5068 Add special error for scala-like syntax 'fun foo(): Int = { 1 }'
fun test1(): Int = { return 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
fun outer() {
fun test1(): Int = { return 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
}
class Outer {
fun test1(): Int = { return 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
class Nested {
fun test1(): Int = { return 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
}
}
@@ -0,0 +1,17 @@
fun <in T> f() {
}
fun <out T> g() {
}
fun <out T, in X, Y> h() {
}
val <out T> T.x: Int
get() = 1
val <in T> T.y: Int
get() = 1
@@ -0,0 +1,120 @@
interface MyTrait {
fun f1() {}
}
open class MyClass {
fun f2() {}
}
class Foo {
private val privateProperty = object : MyClass(), MyTrait {}
init {
privateProperty.f1()
privateProperty.f2()
}
protected val protectedProperty = object : MyClass(), MyTrait {}
val internalProperty = object : MyClass(), MyTrait {}
internal val internal2Property = object : MyClass(), MyTrait {}
public val publicProperty = object : MyClass(), MyTrait {}
val propertyWithGetter
get() = object: MyClass(), MyTrait {}
private fun privateFunction() = object : MyClass(), MyTrait {}
init {
privateFunction().f1()
privateFunction().f2()
}
protected fun protectedFunction() = object : MyClass(), MyTrait {}
fun internalFunction() = object : MyClass(), MyTrait {}
internal fun internal2Function() = object : MyClass(), MyTrait {}
public fun publicFunction() = object : MyClass(), MyTrait {}
class FooInner {
private val privatePropertyInner = object : MyClass(), MyTrait {}
init {
privatePropertyInner.f1()
privatePropertyInner.f2()
}
protected val protectedProperty = object : MyClass(), MyTrait {}
val internalProperty = object : MyClass(), MyTrait {}
internal val internal2Property = object : MyClass(), MyTrait {}
public val publicProperty = object : MyClass(), MyTrait {}
private fun privateFunctionInner() = object : MyClass(), MyTrait {}
init {
privateFunctionInner().f1()
privateFunctionInner().f2()
}
protected fun protectedFunction() = object : MyClass(), MyTrait {}
fun internalFunction() = object : MyClass(), MyTrait {}
internal fun internal2Function() = object : MyClass(), MyTrait {}
public fun publicFunction() = object : MyClass(), MyTrait {}
}
fun foo() {
val localVar = object : MyClass(), MyTrait {}
localVar.f1()
localVar.f2()
fun foo2() = object : MyClass(), MyTrait {}
foo2().f1()
foo2().f2()
}
}
private val packagePrivateProperty = object : MyClass(), MyTrait {}
protected val packageProtectedProperty = object : MyClass(), MyTrait {}
val packageInternalProperty = object : MyClass(), MyTrait {}
internal val packageInternal2Property = object : MyClass(), MyTrait {}
public val packagePublicProperty = object : MyClass(), MyTrait {}
protected fun packageProtectedFunction() = object : MyClass(), MyTrait {}
fun packageInternalFunction() = object : MyClass(), MyTrait {}
internal fun packageInternal2Function() = object : MyClass(), MyTrait {}
public fun packagePublicFunction() = object : MyClass(), MyTrait {}
fun fooPackage() {
val packageLocalVar = object : MyClass(), MyTrait {}
packageLocalVar.f1()
packageLocalVar.f2()
fun fooPackageLocal() = object : MyClass(), MyTrait {}
fooPackageLocal().f1()
fooPackageLocal().f2()
}
@@ -0,0 +1,43 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// !CHECK_TYPE
fun foo(block: () -> (() -> Int)) {}
fun test() {
foo { fun(): Int {return 1} }
foo({ fun() = 1 })
val x1 =
if (1 == 1)
fun(): Int {return 1}
else
fun() = 1
val x2 =
if (1 == 1) {
fun(): Int {
return 1
}
}
else
fun() = 1
val x3 = when (1) {
0 -> fun(): Int {return 1}
else -> fun() = 1
}
val x31 = when (1) {
0 -> {
fun(): Int {return 1}
}
else -> fun() = 1
}
val x4 = {
y: Int -> fun(): Int {return 1}
}
x4 checkType { <!UNRESOLVED_REFERENCE!>_<!><Function1<Int, Function0<Int>>>() }
{ y: Int -> fun(): Int {return 1} }
}
@@ -0,0 +1,21 @@
fun unusedExpressions() {
if (1 == 1)
fun(): Int {return 1}
else
fun() = 1
if (1 == 1) {
fun(): Int {
return 1
}
}
else
fun() = 1
when (1) {
0 -> fun(): Int {return 1}
else -> fun() = 1
}
fun() = 1
}
@@ -0,0 +1,14 @@
class A {
operator fun component1() = 1
operator fun component2() = 1
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x, y) in C()) {
}
}
@@ -0,0 +1,15 @@
// !WITH_NEW_INFERENCE
class A {
operator fun component1() = 1
operator fun component2() = 1.0
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x: Double, y: Int) in C()) {
}
}
@@ -0,0 +1,15 @@
class A {
operator fun component1() = 1
operator fun component1() = 1
operator fun component2() = 1
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((<!AMBIGUITY!>x<!>, y) in C()) {
}
}
@@ -0,0 +1,13 @@
class A {
operator fun component1() = 1
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x, <!UNRESOLVED_REFERENCE!>y<!>) in C()) {
}
}
@@ -0,0 +1,15 @@
// !WITH_NEW_INFERENCE
fun useDeclaredVariables() {
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for ((<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>)<!SYNTAX!><!>) {
a
b
}<!>
}
fun checkersShouldRun() {
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for ((<!UNRESOLVED_REFERENCE!>@A a<!>, <!UNRESOLVED_REFERENCE!>_<!>)<!SYNTAX!><!>) {
}<!>
}
annotation class A
@@ -0,0 +1,14 @@
class A {
}
operator fun A.component1() = 1
operator fun A.component2() = 1
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x, y) in C()) {
}
}
@@ -0,0 +1,14 @@
class A {
operator fun component1() = 1
operator fun component2() = 1.0
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x: Int, y: Double) in C()) {
}
}
@@ -0,0 +1,14 @@
class A {
operator fun component1() = 1
operator fun component2() = 1
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x, x) in C()) {
}
}
@@ -0,0 +1,13 @@
class A {
operator fun component1() = 1
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x) in C()) {
}
}
@@ -0,0 +1,11 @@
fun useDeclaredVariables() {
val (<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>) = <!UNRESOLVED_REFERENCE!>unresolved<!>
a
b
}
fun checkersShouldRun() {
val (<!UNRESOLVED_REFERENCE!>@A a<!>, <!UNRESOLVED_REFERENCE!>_<!>) = <!UNRESOLVED_REFERENCE!>unresolved<!>
}
annotation class A
@@ -0,0 +1,11 @@
fun useDeclaredVariables() {
val (<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>)
a
b
}
fun checkersShouldRun() {
val (<!UNRESOLVED_REFERENCE!>@A a<!>, <!UNRESOLVED_REFERENCE!>_<!>)
}
annotation class A
@@ -0,0 +1,16 @@
package test
fun a(s: String) { // <- ERROR
val (x, y) = Pair("", s)
println(x + y)
}
fun b(s: String) {
val x = Pair("", s)
println(x)
}
//from library
data class Pair<A, B>(val a: A, val b: B)
fun println(a: Any?) = a
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
fun test(list: A) {
if (true) {
val (c) = list
}
else {}
if (true) {
Unit
val (c) = list
}
else {}
when (1) {
1 -> {
val (c) = list
}
}
fn { it ->
val (a) = it
}
}
class A {
operator fun component1() = 1
}
fun fn(x: (A) -> Unit) {}
@@ -0,0 +1,51 @@
// !WITH_NEW_INFERENCE
class A {
operator fun component1() = 1
operator fun component2() = ""
}
class C {
operator fun iterator(): Iterator<A> = null!!
}
fun test() {
for ((x, _) in C()) {
foo(x, _)
}
for ((_, y) in C()) {
foo(_, y)
}
for ((_, _) in C()) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(_, _)
}
for ((_ : Int, _ : String) in C()) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(_, _)
}
for ((_ : String, _ : Int) in C()) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(_, _)
}
val (x, _) = A()
val (_, y) = A()
foo(x, y)
<!INAPPLICABLE_CANDIDATE!>foo<!>(x, _)
foo(_, y)
val (`_`, z) = A()
foo(_, z)
val (_, `_`) = A()
<!INAPPLICABLE_CANDIDATE!>foo<!>(_, y)
val (unused, _) = A()
}
fun foo(x: Int, y: String) {}
@@ -0,0 +1,17 @@
interface A0<T : A0<T>>
interface A1<T : A1<*>>
interface A2<T : A2<out T>>
// StackOverflowError
//interface A3<T : A3<in T>>
interface A4<T : A4<*>?>
interface B0<T : B1<*>>
interface B1<T : B0<*>>
interface AA<T: AA<*>>
interface BB<S : List<AA<*>>>
interface A<T: List<T, T, T>>
class X<Y>
class D<T : X<in X<out X<T>>>>
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
interface C0<T, S : C0<*, S>>
interface C1<T : C1<T, *>, S : C1<S, *>> // T -> S, S -> S
interface C2<T : C2<T, *>, S : C2<*, S>> // T -> S, S -> T
interface D1<T, U> where T : U, U: D1<*, U>
interface D2<T, U> where T : U?, U: D2<*, *>
interface D3<T, U, V> where T : U, U : V, V: D3<*, *, V>
interface A<T, U> where T : A<U, T>, U: A<T, A<in U, T>>
@@ -0,0 +1,5 @@
// FILE: A.java
public class A<T extends A> {}
// FILE: 1.kt
class B<S: A<*>>
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -MANY_COMPANION_OBJECTS -REDECLARATION -DUPLICATE_CLASS_NAMES
// KT-3464 Front-end shouldn't allow override modifier in class declaration
override class A {
override companion object {}
open companion object {}
abstract companion object {}
final companion object {}
}
override object B1 {}
open object B2 {}
abstract object B3 {}
final object B4 {}
override enum class C {}
override interface D {}
override annotation class E
@@ -0,0 +1,23 @@
// !DIAGNOSTICS: -TYPE_PARAMETER_AS_REIFIED -TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER -UNUSED_VARIABLE -UNUSED_PARAMETER
fun <T> test1() = <!OTHER_ERROR!>T<!>::class
fun <T : Any> test2() = <!OTHER_ERROR!>T<!>::class
val <T> test3 = <!OTHER_ERROR!>T<!>::class
val <T> test4 get() = <!OTHER_ERROR!>T<!>::class
fun <T> test5() = listOf(<!OTHER_ERROR!>T<!>::class)
fun <T> test6(): kotlin.reflect.KClass<T> = <!OTHER_ERROR!>T<!>::class
fun <T> test7(): kotlin.reflect.KClass<*> = <!OTHER_ERROR!>T<!>::class
fun test8() = String?::class
fun <T> listOf(e: T): List<T> = null!!
fun <L> locals() {
fun <T> test1() = <!OTHER_ERROR!>T<!>::class
fun <T : Any> test2() = <!OTHER_ERROR!>T<!>::class
val test3 = <!OTHER_ERROR!>L<!>::class
fun test4() = <!OTHER_ERROR!>L<!>::class
}
@@ -0,0 +1,21 @@
//KT-1141 No check that object in 'object expression' implements all abstract members of supertype
package kt1141
public interface SomeTrait {
fun foo()
}
fun foo() {
val x = object : SomeTrait {
}
x.foo()
}
object Rr : SomeTrait {}
class C : SomeTrait {}
fun foo2() {
val r = object : Runnable {} //no error
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
//KT-1193 Check enum entry supertype / initialization
package kt1193
enum class MyEnum(val i: Int) {
A(12),
B //no error
}
open class A(x: Int = 1)
val x: MyEnum = MyEnum.A
@@ -0,0 +1,7 @@
//KT-2096 Abstract property with no type specified causes compiler to crash
package c
abstract class Foo{
protected abstract val prop
}
@@ -0,0 +1,8 @@
//KT-2142 function local classes do not work
package a
fun foo() {
class Foo() {}
Foo() // Unresolved reference Foo
}
@@ -0,0 +1,17 @@
//KT-2397 Prohibit final methods in traits with no implementation
package a
interface T {
final fun foo()
final val b : Int
final fun bar() {}
final val c : Int
get() = 42
final val d = 1
}
class A {
final fun foo()
}
@@ -0,0 +1,27 @@
// !CHECK_TYPE
//KT-2631 Check multiple assignment
package a
class MyClass {
operator fun component1() = 1
operator fun component2() = "a"
}
class MyClass2 {}
operator fun MyClass2.component1() = 1.2
fun test(mc1: MyClass, mc2: MyClass2) {
val (a, b) = mc1
checkSubtype<Int>(a)
checkSubtype<String>(b)
val (c) = mc2
checkSubtype<Double>(c)
//check no error types
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(a)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(b)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(c)
}
@@ -0,0 +1,27 @@
//KT-2643 Support multi-declarations in Data-Flow analysis
package n
class C {
operator fun component1() = 1
operator fun component2() = 2
}
fun test1(c: C) {
val (a, b) = c
}
fun test2(c: C) {
val (a, b) = c
a + 3
}
fun test3(c: C) {
var (a, b) = c
a = 3
}
fun test4(c: C) {
var (a, b) = c
a = 3
a + 1
}
@@ -0,0 +1,30 @@
//KT-559 Forbid abstract method call through super
package kt559
abstract class A {
abstract val i : Int
abstract fun foo() : Int
fun fff() {}
}
abstract class D(): A() {
override val i : Int = 34
}
class C() : D() {
fun test() {
super.i
}
}
class B() : A() {
override fun foo(): Int {
super.i
super.fff() //everything is ok
return super.foo() //no error!!
}
}
@@ -0,0 +1,12 @@
package d
class T {
fun baz() = 1
}
fun foo() {
public val i = 11
abstract val j
override fun T.baz() = 2
private fun bar() = 2
}
@@ -0,0 +1,16 @@
package d
class T {
fun baz() = 1
}
override fun zzz() {}
fun foo(t: T) {
override fun T.baz() = 2
// was "Visibility is unknown yet exception"
t.baz()
zzz()
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !LANGUAGE: -ProhibitTypeParametersForLocalVariables
import kotlin.reflect.KProperty
fun test() {
val <T> a0 = 0
val <T : __UNRESOLVED__> a1 = ""
val <T : String> a2 = 0
const val <T> a3 = 0
lateinit val <T> a4 = 0
val <T> a5 by Delegate<Int>()
val <T> a6 by Delegate<T>()
}
class Delegate<F> {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ""
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {}
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !LANGUAGE: +ProhibitTypeParametersForLocalVariables
import kotlin.reflect.KProperty
fun test() {
val <T> a0 = 0
val <T : __UNRESOLVED__> a1 = ""
val <T : String> a2 = 0
const val <T> a3 = 0
lateinit val <T> a4 = 0
val <T> a5 by Delegate<Int>()
val <T> a6 by Delegate<T>()
}
class Delegate<F> {
operator fun getValue(thisRef: Any?, property: KProperty<*>): String = ""
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {}
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED
fun test(vararg x1: Int, vararg x2: Int) {
fun test2(vararg x1: Int, vararg x2: Int) {
class LocalClass(vararg x1: Int, vararg x2: Int) {
constructor(vararg x1: Int, vararg x2: Int, xx: Int) {}
}
fun test3(vararg x1: Int, vararg x2: Int) {}
}
}
fun Any.test(vararg x1: Int, vararg x2: Int, vararg x3: Int) {}
interface I {
fun test(vararg x1: Int, vararg x2: Int)
}
abstract class C(vararg x1: Int, vararg x2: Int, b: Boolean) {
fun test(vararg x1: Int, vararg x2: Int) {}
abstract fun test2(vararg x1: Int, vararg x2: Int)
class CC(vararg x1: Int, vararg x2: Int, b: Boolean) {
constructor(vararg x1: Int, vararg x2: Int) {}
fun test(vararg x1: Int, vararg x2: Int) {}
}
}
object O {
fun test(vararg x1: Int, vararg x2: Int) {}
class CC(vararg x1: Int, vararg x2: Int, b: Boolean) {
constructor(vararg x1: Int, vararg x2: Int) {}
fun test(vararg x1: Int, vararg x2: Int) {}
}
}
@@ -0,0 +1,75 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// !CHECK_TYPE
fun foo(block: () -> (() -> Int)) {}
fun test() {
val x = <!INFERENCE_ERROR, INFERENCE_ERROR, INFERENCE_ERROR!>fun named1(x: Int): Int { return 1 }<!>
x <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Function1<Int, Int>>() }
foo { fun named2(): Int {return 1} }
foo({ fun named3() = 1 })
val x1 =
if (1 == 1)
// TODO: Diagnostic content could be better
<!SYNTAX!><!>fun named4(): Int {return 1}
<!SYNTAX!>else<!>
fun named5() = 1
val x2 =
if (1 == 1) {
fun named6(): Int {
return 1
}
}
else
<!SYNTAX!><!>fun named7() = 1
val x3 = when (1) {
0 -> fun named8(): Int {return 1}
else -> fun named9() = 1
}
val x31 = when (1) {
0 -> {
fun named10(): Int {return 1}
}
else -> fun named11() = 1
}
val x4 = {
y: Int -> fun named12(): Int {return 1}
}
x4 checkType { <!UNRESOLVED_REFERENCE!>_<!><Function1<Int, Unit>>() }
{ y: Int -> fun named14(): Int {return 1} }
val b = <!UNRESOLVED_REFERENCE!><!INFERENCE_ERROR!>(fun named15(): Boolean { return true })<!>()<!>
baz(<!INFERENCE_ERROR!>fun named16(){}<!>)
}
fun bar() = <!INFERENCE_ERROR, INFERENCE_ERROR, INFERENCE_ERROR!>fun named() {}<!>
fun <T> run(block: () -> T): T = null!!
fun run2(block: () -> Unit): Unit = null!!
fun baz(obj: Any?) {}
fun success() {
run { fun named1() = 1 }
run2 { fun named2() = 1 }
val x = run { fun named3() = 1 }
x checkType { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
val y = when (1) {
0 -> {
fun named4(): Int {return 1}
}
else -> {
fun named5(): Int {return 1}
}
}
y checkType { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
//// FILE: D.java
public interface D<W> {}
// FILE: Q.java
public interface Q<Z1, Z2> {}
// FILE: C.java
public interface C<X> extends D<P<X,X>> {}
// FILE: 1.kt
interface P<Y1, Y2> : Q<C<Y1>, C<D<Y2>>>
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
//// FILE: D.java
public interface D<W> {}
// FILE: Q.java
public interface Q<Z1, Z2> {}
// FILE: C.java
public interface C<X> extends D<P<X,X>> {}
// FILE: P.java
public interface P<Y1, Y2> extends Q<C<Y1>, C<D<Y2>>> {}
// FILE: 1.kt
interface P1<YY1, YY2> : P<YY1, YY2>
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UPPER_BOUND_VIOLATED
interface A<T>
interface B<T> : A<A<*>>
interface N0<in T>
interface C0<X> : N0<N0<C0<C0<X>>>>
interface N1<in T>
interface C1<X> : N1<N1<C1<C1<X?>>>>
interface C2<T> : C1<C1<T>>
interface C<X> : D<P<X, X>>
interface P<Y1, Y2> : Q<C<Y1>, C<D<Y2>>>
interface Q<Z1, Z2>
interface D<W>
interface E0<T>
interface E1<T : E2>
interface E2 : E0<E1<out E2>>
interface F0<T>
interface F1<T : F2<*>, U : F2<*>>
interface F2<T> : F0<F1<out F2<*>, T>>
interface G0<T>
interface G1<T : U, U : G2<*>>
interface G2<T> : G0<G1<out G2<*>, T>>
@@ -0,0 +1,12 @@
package d
abstract val a : Int = 1
override val c : Int = 1
final fun foo() = 2
abstract fun baz() = 2
class T {}
override fun T.bar() = 2
@@ -0,0 +1,10 @@
package d
override val f : ()-> Int = { 12 }
fun test() {
f()
}
var g: Int = 1
protected set(i: Int) {}
@@ -0,0 +1,18 @@
interface A {
sealed fun foo()
sealed var bar: Unit
}
interface B {
abstract fun foo()
abstract var bar: Unit
}
interface C : A, B
abstract class D(sealed var x: Int) {
abstract var y: Unit
sealed set
}
abstract class E : D(42)
@@ -0,0 +1,175 @@
open class MyClass {
fun f1() {}
}
class Foo {
protected val protectedProperty = object : MyClass() {}
public val publicProperty = object : MyClass() {}
protected val protected2Property : MyClass = object : MyClass() {fun invisible() {}}
public val public2Property : MyClass = object : MyClass() {fun invisible() {}}
private val privateProperty = object : MyClass() {fun visible() {}}
internal val internalProperty = object : MyClass() { fun invisible() {}}
fun testProperties() {
privateProperty.f1()
internalProperty.f1()
protected2Property.f1()
public2Property.f1()
privateProperty.visible()
protected2Property.<!UNRESOLVED_REFERENCE!>invisible<!>()
public2Property.<!UNRESOLVED_REFERENCE!>invisible<!>()
internalProperty.invisible()
}
protected fun protectedFunction() = object : MyClass() {}
public fun publicFunction() = object : MyClass() {}
protected fun protected2Function(): MyClass = object : MyClass() {fun visible() {}}
public fun public2Function(): MyClass = object : MyClass() {fun visible() {}}
private fun privateFunction() = object : MyClass() {fun visible() {}}
internal fun internalFunction() = object : MyClass() {fun invisible() {}}
fun testFunctions() {
privateFunction().f1()
internalFunction().f1()
public2Function().f1()
protected2Function().f1()
privateFunction().visible()
internalFunction().invisible()
public2Function().<!UNRESOLVED_REFERENCE!>invisible<!>()
protected2Function().<!UNRESOLVED_REFERENCE!>invisible<!>()
}
class FooInner {
public val publicProperty = object : MyClass() {}
protected val protectedProperty = object : MyClass() {}
protected val protected2Property : MyClass = object : MyClass() {fun invisible() {}}
public val public2Property : MyClass = object : MyClass() {fun invisible() {}}
private val privateProperty = object : MyClass() {fun visible() {}}
internal val internalProperty = object : MyClass() { fun invisible() {}}
fun testProperties() {
privateProperty.f1()
internalProperty.f1()
protected2Property.f1()
public2Property.f1()
privateProperty.visible()
protected2Property.<!UNRESOLVED_REFERENCE!>invisible<!>()
public2Property.<!UNRESOLVED_REFERENCE!>invisible<!>()
internalProperty.invisible()
}
protected fun protectedFunction() = object : MyClass() {}
public fun publicFunction() = object : MyClass() {}
protected fun protected2Function(): MyClass = object : MyClass() {fun visible() {}}
public fun public2Function(): MyClass = object : MyClass() {fun visible() {}}
private fun privateFunction() = object : MyClass() {fun visible() {}}
internal fun internalFunction() = object : MyClass() {fun invisible() {}}
fun testFunctions() {
privateFunction().f1()
internalFunction().f1()
public2Function().f1()
protected2Function().f1()
privateFunction().visible()
internalFunction().invisible()
public2Function().<!UNRESOLVED_REFERENCE!>invisible<!>()
protected2Function().<!UNRESOLVED_REFERENCE!>invisible<!>()
}
}
fun foo() {
val localVar = object : MyClass() {}
localVar.f1()
fun foo2() = object : MyClass() {}
foo2().f1()
}
}
protected val packageProtectedProperty = object : MyClass() {}
public val packagePublicProperty = object : MyClass() {}
public val packagePublic2Property : MyClass = object : MyClass() {fun invisible() {}}
private val packagePrivateProperty = object : MyClass() {fun invisible() {}}
internal val packageInternalProperty = object : MyClass() {fun invisible() {}}
fun testProperties() {
packagePrivateProperty.f1()
packageInternalProperty.f1()
packagePublic2Property.f1()
packagePrivateProperty.invisible()
packageInternalProperty.invisible()
packagePublic2Property.<!UNRESOLVED_REFERENCE!>invisible<!>()
}
private fun privateFunction() = object : MyClass() {fun invisible() {}}
protected fun protectedFunction() = object : MyClass() {}
public fun publicFunction() = object : MyClass() {}
public fun public2Function() : MyClass = object : MyClass() {fun invisible() {}}
internal fun internalFunction() = object : MyClass() {fun invisible() {}}
fun testFunctions() {
privateFunction().f1()
internalFunction().f1()
public2Function().f1()
privateFunction().invisible()
internalFunction().invisible()
public2Function().<!UNRESOLVED_REFERENCE!>invisible<!>()
}
fun fooPackage() {
val packageLocalVar = object : MyClass() {fun visible() {}}
packageLocalVar.f1()
packageLocalVar.visible()
fun fooPackageLocal() = object : MyClass() {fun visible() {}}
fooPackageLocal().f1()
fooPackageLocal().visible()
}
@@ -0,0 +1,12 @@
fun f(
val a: Int,
var b: Int,
c: Int,
vararg var d: Int,
vararg val e: Int,
vararg f: Int
) {
a + b + c + d[0] + e[0] + f[0] // to avoid 'unused parameter'
}