[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,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()
}