[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,12 @@
// FILE: f.kt
class A() {
fun foo() : Unit {
this@A
this@a
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
@@ -0,0 +1,64 @@
package example
interface T {
fun foo() {}
}
open class C() {
fun bar() {}
}
class A<E>() : C(), T {
fun test() {
super
super<T>
super.<!UNRESOLVED_REFERENCE!>foo<!>()
super<T>.foo()
super<C>.bar()
super<T>@A.foo()
super<C>@A.bar()
super<E>.<!UNRESOLVED_REFERENCE!>bar<!>()
super<E>@A.<!UNRESOLVED_REFERENCE!>bar<!>()
super<Int>.<!UNRESOLVED_REFERENCE!>foo<!>()
super<<!SYNTAX!><!>>.<!UNRESOLVED_REFERENCE!>foo<!>()
super<() -> Unit>.<!UNRESOLVED_REFERENCE!>foo<!>()
super<Unit>.<!UNRESOLVED_REFERENCE!>foo<!>()
super<T>@B.foo()
super<C>@B.bar()
}
inner class B : T {
fun test() {
super<T>.foo();
super<C>.bar()
super<C>@A.bar()
super<T>@A.foo()
super<T>@B.foo()
super<C>@B.<!UNRESOLVED_REFERENCE!>foo<!>()
super.foo()
super
super<T>
}
}
}
interface G<T> {
fun foo() {}
}
class CG : G<Int> {
fun test() {
super<G>.foo() // OK
super<G<Int>>.foo() // Warning
super<G<E>>.foo() // Error
super<G<String>>.foo() // Error
}
}
// The case when no supertype is resolved
class ERROR<E>() : UR {
fun test() {
super.<!UNRESOLVED_REFERENCE!>foo<!>()
}
}
@@ -0,0 +1,5 @@
class Dup {
fun Dup() : Unit {
this@Dup
}
}
@@ -0,0 +1,19 @@
interface IBase<T> {
fun foo() {}
fun bar() {}
}
interface IDerived<T> : IBase<T> {
override fun foo() {}
fun qux() {}
}
class Test : IDerived<String>, IBase<String> {
fun test() {
super<IBase>.foo()
super<IBase>.bar()
super<IDerived>.foo()
super<IDerived>.bar()
super<IDerived>.qux()
}
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A {
operator fun invoke() {}
operator fun invoke(f: () -> Unit) {}
}
class B : A() {
fun bar() {
super()
(super)()
super {}
(super) {}
}
}
@@ -0,0 +1,10 @@
open class A {
open fun foo() {}
}
interface ATrait : A {
override fun foo() {
super<A>.foo()
}
}
@@ -0,0 +1,29 @@
interface IBase {
fun foo() {}
fun bar() {}
}
interface IDerived1 : IBase {
override fun foo() {}
fun qux() {}
}
interface IDerived2 : IBase {
override fun foo() {}
}
class Test : IDerived1, IBase, IDerived2 {
override fun foo() {}
fun test() {
super<IBase>.foo()
super<IBase>.bar()
super<IDerived1>.foo()
super<IDerived1>.bar()
super<IDerived1>.qux()
super<IDerived2>.foo()
super<IDerived2>.bar()
}
}
@@ -0,0 +1,4 @@
fun String.f() {
<!NO_SUPERTYPE, NO_SUPERTYPE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
@@ -0,0 +1,9 @@
// No supertype at all
fun Any.extension(arg: Any?) {}
class A1 {
fun test() {
super.extension(null) // Call to an extension function
}
}
@@ -0,0 +1,5 @@
fun foo() {
<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!>
<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
super<Nothing>.<!UNRESOLVED_REFERENCE!>foo<!>()
}
@@ -0,0 +1,12 @@
fun any(a : Any) {}
fun notAnExpression() {
any(<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!>) // not an expression
if (<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!>) {} else {} // not an expression
val x = <!NO_SUPERTYPE, NO_SUPERTYPE, NO_SUPERTYPE!>super<!> // not an expression
when (1) {
<!NO_SUPERTYPE, NO_SUPERTYPE!>super<!> -> 1 // not an expression
else -> {}
}
}
@@ -0,0 +1,18 @@
// !CHECK_TYPE
class A(val a:Int) {
inner class B() {
fun Byte.xx() : Double.() -> Any {
checkSubtype<Byte>(this)
val a: Double.() -> Unit = {
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Double>(this)
checkSubtype<Byte>(this@xx)
checkSubtype<B>(this@B)
checkSubtype<A>(this@A)
}
val b: Double.() -> Unit = a@{ <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Double>(this@a) + checkSubtype<Byte>(this@xx) }
val c = a@{ -> this@a + checkSubtype<Byte>(this@xx) }
return (a@{<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Double>(this@a) + checkSubtype<Byte>(this@xx)})
}
}
}
@@ -0,0 +1,11 @@
// !CHECK_TYPE
class A(val a:Int) {
inner class B() {
val x = checkSubtype<B>(this@B)
val y = checkSubtype<A>(this@A)
val z = checkSubtype<B>(this)
val Int.xx : Int get() = checkSubtype<Int>(this)
}
}
@@ -0,0 +1,8 @@
interface Base {
fun foo()
}
val String.test: Base = object: Base {
override fun foo() {
this@test
}
}
@@ -0,0 +1,4 @@
fun foo1() : Unit {
this
this@a
}
@@ -0,0 +1,24 @@
// FILE: test.kt
public interface Test {
fun test(): String {
return "123";
}
}
interface KTrait : Test {
fun ktest() {
super.test()
test()
}
}
class A : KTrait {
fun b() {
super.test()
test()
}
}
@@ -0,0 +1,38 @@
// !WITH_NEW_INFERENCE
open class GenericBaseClass<T> {
open fun foo(x: T): T = x
open fun ambiguous(x: T): T = x
}
interface GenericBaseInterface<T> {
fun bar(x: T): T = x
fun ambiguous(x: T): T = x
}
class GenericDerivedClass<T> : GenericBaseClass<T>(), GenericBaseInterface<T> {
override fun foo(x: T): T = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun ambiguous(x: T): T =
super.ambiguous(x)
}
class SpecializedDerivedClass : GenericBaseClass<Int>(), GenericBaseInterface<String> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: String): String = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun ambiguous(x: String): String =
super.<!INAPPLICABLE_CANDIDATE!>ambiguous<!>(x)
override fun ambiguous(x: Int): Int =
super.ambiguous(x)
}
class MixedDerivedClass<T> : GenericBaseClass<Int>(), GenericBaseInterface<T> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
override fun ambiguous(x: Int): Int =
super.ambiguous(x)
override fun ambiguous(x: T): T =
super.<!INAPPLICABLE_CANDIDATE!>ambiguous<!>(x)
}
@@ -0,0 +1,57 @@
// Base Interface
// \ /
// \/
// Derived
//
open class Base() {
open fun foo() {}
open fun ambiguous() {}
open val prop: Int
get() = 1234
open val ambiguousProp: Int
get() = 111
}
interface Interface {
fun bar() {}
fun ambiguous() {}
val ambiguousProp: Int
get() = 222
}
class Derived : Base(), Interface {
override fun foo() {}
override fun bar() {}
override fun ambiguous() {}
override val ambiguousProp: Int
get() = 333
override val prop: Int
get() = 4321
fun callsFunFromSuperClass() {
super.foo()
}
fun getSuperProp(): Int =
super.prop
fun getAmbiguousSuperProp(): Int =
super.ambiguousProp
fun callsFunFromSuperInterface() {
super.<!UNRESOLVED_REFERENCE!>bar<!>()
}
fun callsAmbiguousSuperFun() {
super.ambiguous()
}
}
@@ -0,0 +1,39 @@
// fun foo: abstract in A, unresolved in I
// fun bar: implemented in A, abstract in I
// fun qux: abstract in A, abstract in I
// val x: unresolved in A, abstract in I
// val y: abstract in A, implemented in I
abstract class A {
abstract fun foo(): Int
open fun bar() {}
abstract fun qux()
abstract val y: Int
}
interface I {
fun bar()
fun qux()
val x: Int
val y: Int get() = 111
}
class B : A(), I {
override val x: Int = 12345
override val y: Int = super.y
override fun foo(): Int {
super.foo()
return super.<!UNRESOLVED_REFERENCE!>x<!>
}
override fun bar() {
super.bar()
}
override fun qux() {
super.qux()
}
}
@@ -0,0 +1,21 @@
// !WITH_NEW_INFERENCE
// Ambiguity between fun and callable property
open class BaseWithCallableProp {
val fn = { "fn.invoke()" }
val bar = { "bar.invoke()"}
open fun bar(): String = "bar()"
}
interface InterfaceWithFun {
fun fn(): String = "fn()"
}
class DerivedUsingFun : BaseWithCallableProp(), InterfaceWithFun {
fun foo(): String =
super.fn()
override fun bar(): String =
super.bar()
}
@@ -0,0 +1,51 @@
// Check that it works with inherited members
//
// DeeperBase DeeperInterface
// | |
// DeepBase DeepInterface
// \ /
// \/
// DeepDerived
//
open class DeeperBase {
open fun deeperBaseFun() {}
open val deeperBaseProp: Int
get() = 333
}
open class DeepBase : DeeperBase() {
}
interface DeeperInterface {
fun deeperInterfaceFun() {}
}
interface DeepInterface : DeeperInterface {
fun deepInterfaceFun() {}
}
class DeepDerived : DeepBase(), DeepInterface {
override fun deeperBaseFun() {}
override val deeperBaseProp: Int
get() = 444
override fun deeperInterfaceFun() {}
override fun deepInterfaceFun() {}
fun callsSuperDeeperBaseFun() {
super.deeperBaseFun()
}
fun getsSuperDeeperBaseProp(): Int =
super.deeperBaseProp
fun callsSuperInterfaceFuns() {
super.<!UNRESOLVED_REFERENCE!>deeperInterfaceFun<!>()
super.<!UNRESOLVED_REFERENCE!>deepInterfaceFun<!>()
super<DeepInterface>.deeperInterfaceFun()
super<DeepInterface>.deepInterfaceFun()
}
}
@@ -0,0 +1,22 @@
open class GenericBaseClass<T> {
open fun foo(x: T): T = x
}
interface GenericBaseInterface<T> {
fun bar(x: T): T = x
}
class GenericDerivedClass<T> : GenericBaseClass<T>(), GenericBaseInterface<T> {
override fun foo(x: T): T = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
}
class SpecializedDerivedClass : GenericBaseClass<Int>(), GenericBaseInterface<String> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: String): String = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
}
class MixedDerivedClass<T> : GenericBaseClass<Int>(), GenericBaseInterface<T> {
override fun foo(x: Int): Int = super.foo(x)
override fun bar(x: T): T = super.<!UNRESOLVED_REFERENCE!>bar<!>(x)
}
@@ -0,0 +1,33 @@
open class A {
open fun foo() {}
}
interface B {
fun bar() {}
}
interface Q {
fun qux() {}
}
class C : A(), B {
override fun foo() {
super@C.foo()
}
override fun bar() {
super@C.<!UNRESOLVED_REFERENCE!>bar<!>()
}
inner class D : A(), Q {
override fun foo() {
super@C.foo()
super@D.foo()
}
override fun qux() {
super@C.<!UNRESOLVED_REFERENCE!>qux<!>()
super@D.<!UNRESOLVED_REFERENCE!>qux<!>()
}
}
}
@@ -0,0 +1,28 @@
// Interface AnotherInterface
// \ /
// \/
// DerivedInterface
//
interface Interface {
fun foo() {}
fun ambiguous() {}
val ambiguousProp: Int
get() = 222
}
interface AnotherInterface {
fun ambiguous() {}
val ambiguousProp: Int
get() = 333
}
interface DerivedInterface: Interface, AnotherInterface {
override fun foo() { super.foo() }
override fun ambiguous() {
super.ambiguous()
}
override val ambiguousProp: Int
get() = super.ambiguousProp
}
@@ -0,0 +1,21 @@
interface Interface {
fun foo(x: Int): Int
}
fun withLocalClasses(param: Int): Interface {
open class LocalBase {
open val param: Int
get() = 100
}
interface LocalInterface : Interface {
override fun foo(x: Int): Int =
x + param
}
return object : LocalBase(), LocalInterface {
override fun foo(x: Int): Int =
x + super.param
}
}
@@ -0,0 +1,53 @@
// Check that unresolved super type doesn't interfere with unqualified super resolution.
open class Base() {
open fun foo() {}
open fun ambiguous() {}
open val prop: Int
get() = 1234
open val ambiguousProp: Int
get() = 111
}
interface Interface {
fun bar() {}
fun ambiguous() {}
val ambiguousProp: Int
get() = 222
}
class ClassDerivedFromUnresolved : Base(), Interface, Unresolved {
override fun foo() {}
override fun bar() {}
override fun ambiguous() {}
override val ambiguousProp: Int
get() = 333
override val prop: Int
get() = 4321
fun callsFunFromSuperClass() {
super.foo()
}
fun getSuperProp(): Int =
super.prop
fun getAmbiguousSuperProp(): Int =
super.ambiguousProp
fun callsFunFromSuperInterface() {
super.<!UNRESOLVED_REFERENCE!>bar<!>()
}
fun callsAmbiguousSuperFun() {
super.ambiguous()
}
}
@@ -0,0 +1,8 @@
interface IWithToString {
override fun toString(): String
}
class A : IWithToString {
// Should be Any#toString(), even though IWithToString defines an abstract toString.
override fun toString(): String = super.toString()
}
@@ -0,0 +1,29 @@
interface A {
fun foo() {}
}
abstract class C : A {
override abstract fun foo()
}
interface Unrelated {
fun foo() {}
}
class Test1 : C(), A {
override fun foo() {
// Abstract 'foo' defined in 'C' wins against non-abstract 'foo' defined in 'A',
// because 'C' is a subclass of 'A' (and 'C::foo' overrides 'A::foo'),
// even though 'A' is explicitly listed in supertypes list for 'D'.
super.foo()
}
}
class Test2 : C(), A, Unrelated {
override fun foo() {
// This is ok, because there's a non-abstract 'foo' in 'Unrelated',
// which is not overridden by abstract 'foo' in 'C'.
super.foo()
super<Unrelated>.foo()
}
}
@@ -0,0 +1,10 @@
interface IFoo
interface IBar
class A : IFoo, IBar {
// Unqualified 'super' should be resolved to 'Any'.
override fun equals(other: Any?): Boolean = super.equals(other)
override fun hashCode(): Int = super.hashCode()
override fun toString(): String = super.toString()
}