[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract fun foo(): Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
override fun foo() = 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class A {
|
||||
abstract fun foo(): Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract val i: Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
override val i = 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class A {
|
||||
abstract val i: Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract var i: Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
override var i = 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class A {
|
||||
abstract var i: Int
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
interface A {
|
||||
private val a: String
|
||||
get() = "AAAA!"
|
||||
}
|
||||
|
||||
open class C {
|
||||
private val a: String = ""
|
||||
}
|
||||
|
||||
class Subject : C(), A {
|
||||
val c = <!INAPPLICABLE_CANDIDATE!>a<!>
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER
|
||||
package override.generics
|
||||
|
||||
abstract class MyAbstractClass<T> {
|
||||
abstract val pr : T
|
||||
}
|
||||
|
||||
abstract class MyLegalAbstractClass2<T>(t : T) : MyAbstractClass<Int>() {
|
||||
val <R> pr : T = t
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
open class Aaa() {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
open class Bbb() : Aaa() {
|
||||
fun <T> foo() = 2
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// !DIAGNOSTICS: -TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER
|
||||
open class Aaa() {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
open class Bbb() : Aaa() {
|
||||
val <T> bar = "aa"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
open class A {
|
||||
open fun foo(a : Int) {}
|
||||
}
|
||||
|
||||
class C : A() {
|
||||
override fun foo(a : Int = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
class D : A() {
|
||||
override fun foo(a : Int = 1) {
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface YSub : Y {
|
||||
|
||||
}
|
||||
|
||||
class Z2 : Y, YSub {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
|
||||
object Z2O : Y, YSub {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package test
|
||||
|
||||
interface X {
|
||||
fun foo(): String? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(): String {
|
||||
return "foo"
|
||||
}
|
||||
}
|
||||
|
||||
interface Incompatible {
|
||||
fun foo(): Int {
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
class Test1(val x: X) : X by x, Y {
|
||||
override fun foo(): String? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class Test2(val x: X) : X by x, Y {
|
||||
override fun foo(): String {
|
||||
return "foo"
|
||||
}
|
||||
}
|
||||
|
||||
class Test3(val y: Y) : X, Y by y {
|
||||
override fun foo(): String? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class Test4(val y: Y) : X, Y by y {
|
||||
override fun foo(): String {
|
||||
return "foo"
|
||||
}
|
||||
}
|
||||
|
||||
class Test5(val y: Y, val x: X) : X by x, Y by y, Incompatible {
|
||||
override fun foo(): Int {
|
||||
return 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package delegation
|
||||
|
||||
interface Aaa {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class Bbb(aaa: Aaa) : Aaa by aaa
|
||||
@@ -0,0 +1,7 @@
|
||||
package delegation
|
||||
|
||||
interface Aaa {
|
||||
val i: Int
|
||||
}
|
||||
|
||||
class Bbb(aaa: Aaa) : Aaa by aaa
|
||||
@@ -0,0 +1,7 @@
|
||||
package delegation
|
||||
|
||||
interface Aaa {
|
||||
var i: Int
|
||||
}
|
||||
|
||||
class Bbb(aaa: Aaa) : Aaa by aaa
|
||||
@@ -0,0 +1,8 @@
|
||||
interface Some {
|
||||
fun test()
|
||||
}
|
||||
|
||||
class SomeImpl : Some {
|
||||
override fun test() {}
|
||||
override fun test() {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface Foo
|
||||
interface Bar
|
||||
|
||||
interface A {
|
||||
fun <T> foo()
|
||||
where T : Foo, T : Bar
|
||||
= Unit
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun <T> foo()
|
||||
where T : Foo, T : Bar
|
||||
= Unit
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package extendFunctionClass
|
||||
|
||||
class A : Function1<Int, Int> {
|
||||
|
||||
}
|
||||
|
||||
class B : Function1<Int, Int> {
|
||||
override fun invoke(p1 : Int) = p1
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
open class Ccc() {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
interface Ttt {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
class Zzz() : Ccc(), Ttt
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
interface A {
|
||||
fun f(): String = "string"
|
||||
}
|
||||
|
||||
open class B {
|
||||
open fun f(): CharSequence = "charSequence"
|
||||
}
|
||||
|
||||
class C : B(), A
|
||||
|
||||
val obj: A = object : B(), A {}
|
||||
@@ -0,0 +1,14 @@
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface C {
|
||||
abstract fun foo()
|
||||
}
|
||||
|
||||
// Fake override Z#foo should be abstract
|
||||
class Z : B, C
|
||||
@@ -0,0 +1,18 @@
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface C : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface D : A {
|
||||
override fun foo() = super.foo()
|
||||
}
|
||||
|
||||
// Fake override Z#foo should be open
|
||||
class Z : B, C, D
|
||||
@@ -0,0 +1,16 @@
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface C : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface D : A
|
||||
|
||||
// Fake override Z#foo should be abstract
|
||||
class Z : B, C, D
|
||||
@@ -0,0 +1,60 @@
|
||||
package override.generics
|
||||
|
||||
interface MyTrait<T> {
|
||||
fun foo(t: T) : T
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass<T> {
|
||||
abstract fun bar(t: T) : T
|
||||
abstract val pr : T
|
||||
}
|
||||
|
||||
interface MyProps<T> {
|
||||
val p : T
|
||||
}
|
||||
|
||||
open class MyGenericClass<T>(t : T) : MyTrait<T>, MyAbstractClass<T>(), MyProps<T> {
|
||||
override fun foo(t: T) = t
|
||||
override fun bar(t: T) = t
|
||||
override val p : T = t
|
||||
override val pr : T = t
|
||||
}
|
||||
|
||||
class MyChildClass() : MyGenericClass<Int>(1) {}
|
||||
class MyChildClass1<T>(t : T) : MyGenericClass<T>(t) {}
|
||||
class MyChildClass2<T>(t : T) : MyGenericClass<T>(t) {
|
||||
fun foo(t: T) = t
|
||||
val pr : T = t
|
||||
override fun bar(t: T) = t
|
||||
override val p : T = t
|
||||
}
|
||||
|
||||
open class MyClass() : MyTrait<Int>, MyAbstractClass<String>() {
|
||||
override fun foo(t: Int) = t
|
||||
override fun bar(t: String) = t
|
||||
override val pr : String = "1"
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass1 : MyTrait<Int>, MyAbstractClass<String>() {
|
||||
override fun foo(t: Int) = t
|
||||
override fun bar(t: String) = t
|
||||
}
|
||||
|
||||
class MyIllegalGenericClass1<T> : MyTrait<T>, MyAbstractClass<T>() {}
|
||||
class MyIllegalGenericClass2<T, R>(r : R) : MyTrait<T>, MyAbstractClass<R>() {
|
||||
override fun foo(r: R) = r
|
||||
override val <T> pr : R = r
|
||||
}
|
||||
class MyIllegalClass1 : MyTrait<Int>, MyAbstractClass<String>() {}
|
||||
abstract class MyLegalAbstractClass1 : MyTrait<Int>, MyAbstractClass<String>() {}
|
||||
|
||||
class MyIllegalClass2<T>(t : T) : MyTrait<Int>, MyAbstractClass<Int>() {
|
||||
fun foo(t: T) = t
|
||||
fun bar(t: T) = t
|
||||
val <R> pr : T = t
|
||||
}
|
||||
abstract class MyLegalAbstractClass2<T>(t : T) : MyTrait<Int>, MyAbstractClass<Int>() {
|
||||
fun foo(t: T) = t
|
||||
fun bar(t: T) = t
|
||||
val <R> pr : T = t
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
open class A {
|
||||
private fun foo() : Int = 1
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
fun foo() : String = ""
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C : Base1 by Base2(1) {
|
||||
fun test() { }
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
class Z : X, Y {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
|
||||
object ZO : X, Y {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
class Z : X, Y {
|
||||
fun foo(a : Int) {}
|
||||
}
|
||||
|
||||
object ZO : X, Y {
|
||||
fun foo(a : Int) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
interface A {
|
||||
fun foo(x: Int = 42): Int
|
||||
}
|
||||
|
||||
open class B {
|
||||
fun foo(x: Int = 239) = x
|
||||
}
|
||||
|
||||
interface C {
|
||||
fun foo(y: Int): Int
|
||||
}
|
||||
|
||||
// TODO DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES reported twice
|
||||
class Z : A, B(), C
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
class Z1 : X, Y {} // BUG
|
||||
object Z1O : X, Y {} // BUG
|
||||
@@ -0,0 +1,50 @@
|
||||
package override.normal
|
||||
|
||||
interface MyTrait {
|
||||
fun foo()
|
||||
val pr : Unit
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass {
|
||||
abstract fun bar()
|
||||
abstract val prr : Unit
|
||||
|
||||
}
|
||||
|
||||
open class MyClass() : MyTrait, MyAbstractClass() {
|
||||
override fun foo() {}
|
||||
override fun bar() {}
|
||||
|
||||
override val pr : Unit = Unit
|
||||
override val prr : Unit = Unit
|
||||
}
|
||||
|
||||
class MyChildClass() : MyClass() {}
|
||||
|
||||
class MyIllegalClass : MyTrait, MyAbstractClass() {}
|
||||
|
||||
class MyIllegalClass2() : MyTrait, MyAbstractClass() {
|
||||
override fun foo() {}
|
||||
override val pr : Unit = Unit
|
||||
override val prr : Unit = Unit
|
||||
}
|
||||
|
||||
class MyIllegalClass3() : MyTrait, MyAbstractClass() {
|
||||
override fun bar() {}
|
||||
override val pr : Unit = Unit
|
||||
override val prr : Unit = Unit
|
||||
}
|
||||
|
||||
class MyIllegalClass4() : MyTrait, MyAbstractClass() {
|
||||
fun foo() {}
|
||||
val pr : Unit
|
||||
override fun other() {}
|
||||
override val otherPr : Int = 1
|
||||
}
|
||||
|
||||
class MyChildClass1() : MyClass() {
|
||||
fun foo() {}
|
||||
val pr : Unit = Unit
|
||||
override fun bar() {}
|
||||
override val prr : Unit = Unit
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
interface D {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface E {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
object Impl : D, E {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
val obj: D = object : D by Impl, E by Impl {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open fun foo(a: E) {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo(a: E) {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
open class A {
|
||||
final fun foo() {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo() {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int)
|
||||
}
|
||||
|
||||
class Z : X, Y {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package d
|
||||
|
||||
interface A {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
interface B {
|
||||
fun foo() = 2
|
||||
}
|
||||
|
||||
open class C : A, B {}
|
||||
|
||||
interface E {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
class D : C() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
open class Base {
|
||||
protected open val prot: Int = 1
|
||||
internal open val int: Int = 1
|
||||
public open val pub: Int = 1
|
||||
}
|
||||
|
||||
class Child(
|
||||
override val prot: Int,
|
||||
override val int: Int,
|
||||
override val pub: Int
|
||||
) : Base()
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
interface A {
|
||||
val a: String
|
||||
}
|
||||
|
||||
interface B {
|
||||
val a: String
|
||||
}
|
||||
|
||||
open class C {
|
||||
private val a: String = ""
|
||||
}
|
||||
|
||||
class Subject : C(), A, B {
|
||||
val c = a
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// NamedFunctionDescriptor.substitute substitutes "overrides"
|
||||
// this test checks it does it properly
|
||||
|
||||
interface Foo<P> {
|
||||
fun quux(p: P, q: Int = 17) : Int = 18
|
||||
}
|
||||
|
||||
interface Bar<Q> : Foo<Q>
|
||||
|
||||
abstract class Baz() : Bar<String>
|
||||
|
||||
fun zz(b: Baz) = b.quux("a")
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// http://youtrack.jetbrains.com/issue/KT-1996
|
||||
|
||||
interface Foo {
|
||||
fun foo(): Unit
|
||||
}
|
||||
|
||||
interface Bar {
|
||||
fun foo(): Unit
|
||||
}
|
||||
|
||||
class Baz : Foo, Bar
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
interface IBase {
|
||||
fun copy(): IBase
|
||||
}
|
||||
|
||||
interface ILeft : IBase {
|
||||
override fun copy(): ILeft
|
||||
}
|
||||
|
||||
open class CLeft : ILeft {
|
||||
override fun copy(): ILeft = CLeft()
|
||||
}
|
||||
|
||||
interface IRight : IBase {
|
||||
override fun copy(): IRight
|
||||
}
|
||||
|
||||
interface IDerived : ILeft, IRight {
|
||||
override fun copy(): IDerived
|
||||
}
|
||||
|
||||
// Error: ILeft::copy and IRight::copy have unrelated return types
|
||||
class CDerivedInvalid1 : ILeft, IRight
|
||||
|
||||
// Error: CLeft::copy and IRight::copy have unrelated return types
|
||||
class CDerivedInvalid2 : CLeft(), IRight
|
||||
|
||||
// OK: CDerived1::copy overrides both ILeft::copy and IRight::copy
|
||||
class CDerived1 : ILeft, IRight {
|
||||
override fun copy(): CDerived1 = CDerived1()
|
||||
}
|
||||
|
||||
// Although ILeft::copy and IRight::copy return types are unrelated, IDerived::copy return type is the most specific of three.
|
||||
abstract class CDerived2 : ILeft, IRight, IDerived
|
||||
|
||||
class CDerived2a : ILeft, IRight, IDerived {
|
||||
override fun copy(): IDerived = CDerived2a()
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
String foo(); // String!
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
interface K1 {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface K2 {
|
||||
fun foo(): String?
|
||||
}
|
||||
|
||||
interface KDerived1a : K1, J
|
||||
|
||||
interface KDerived1b : J, K1
|
||||
|
||||
interface KDerived2a : K2, J
|
||||
|
||||
interface KDerived2b : J, K2
|
||||
|
||||
interface KDerived12a : K1, K2, J
|
||||
|
||||
interface KDerived12b : K1, J, K2
|
||||
|
||||
interface KDerived12c : J, K1, K2
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
// FILE: InOut.kt
|
||||
interface In<in T>
|
||||
|
||||
// FILE: J1.java
|
||||
public interface J1 {
|
||||
In<String> foo();
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public interface J2 {
|
||||
@NotNull In<String> foo();
|
||||
}
|
||||
|
||||
// FILE: J3.java
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public interface J3 {
|
||||
@Nullable In<String> foo();
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
interface K1 {
|
||||
fun foo(): In<String>
|
||||
}
|
||||
|
||||
interface K2 {
|
||||
fun foo(): In<String?>
|
||||
}
|
||||
|
||||
// FIXME TestJ1K1 should have foo(): In<String!>, since In<String!> <: In<String>.
|
||||
interface TestJ1K1 : J1, K1
|
||||
interface TestK1J1 : K1, J1
|
||||
|
||||
interface TestJ1K2 : J1, K2
|
||||
interface TestK2J1 : K2, J1
|
||||
|
||||
interface TestJ2K1 : J2, K1
|
||||
interface TestK1J2 : K1, J2
|
||||
|
||||
interface TestJ2K2 : J2, K2
|
||||
interface TestK2J2 : K2, J2
|
||||
|
||||
interface TestJ3K1 : J3, K1
|
||||
interface TestK1J3 : K1, J3
|
||||
|
||||
interface TestJ3K2 : J3, K2
|
||||
interface TestK2J3 : K2, J3
|
||||
|
||||
interface TestJ1K1K2 : J1, K1, K2
|
||||
interface TestK1J1K2 : K1, J1, K2
|
||||
interface TestK1K2J1 : K1, K2, J1
|
||||
|
||||
interface TestJ2K1K2 : J2, K1, K2
|
||||
interface TestK1J2K2 : K1, J2, K2
|
||||
interface TestK1K2J2 : K1, K2, J2
|
||||
|
||||
interface TestJ3K1K2 : J3, K1, K2
|
||||
interface TestK1J3K2 : K1, J3, K2
|
||||
interface TestK1K2J3 : K1, K2, J3
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
java.util.List<String> foo();
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
interface ILNS {
|
||||
fun foo(): List<String?>
|
||||
}
|
||||
|
||||
interface IMLS {
|
||||
fun foo(): MutableList<String>
|
||||
}
|
||||
|
||||
interface IMLNS {
|
||||
fun foo(): MutableList<String?>
|
||||
}
|
||||
|
||||
interface ILS {
|
||||
fun foo(): List<String>
|
||||
}
|
||||
|
||||
interface Test1 : ILNS, J
|
||||
interface Test2 : J, ILNS
|
||||
|
||||
interface Test3 : IMLS, J
|
||||
interface Test4 : J, IMLS
|
||||
|
||||
interface Test5 : ILNS, IMLS, J
|
||||
interface Test6 : ILNS, J, IMLS
|
||||
interface Test7 : J, ILNS, IMLS
|
||||
|
||||
// Return types of ILS::foo and IMLNS::foo are incompatible themselves.
|
||||
// However, return type of J::foo is (Mutable)List<String!>!,
|
||||
// which is subtype of both List<String> and MutalbeList<String?>.
|
||||
// Thus, inheriting from J, IMLNS, and ILS is Ok,
|
||||
// but inheriting from IMLNS and ILS is not.
|
||||
|
||||
interface Test8 : J, IMLNS, ILS
|
||||
interface Test9 : IMLNS, J, ILS
|
||||
interface Test10 : IMLNS, ILS, J
|
||||
|
||||
interface Test11 : IMLNS, ILS
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
// FILE: JFooWithUpperBound.java
|
||||
public interface JFooWithUpperBound<T extends IBase> {
|
||||
T foo();
|
||||
}
|
||||
|
||||
// FILE: JFooWithUpperBoundDerived.java
|
||||
public interface JFooWithUpperBoundDerived<T extends IBase> extends JFooWithUpperBound<T> {
|
||||
}
|
||||
|
||||
// FILE: JCFooWithUpperBound.java
|
||||
public class JCFooWithUpperBound<T extends IBase> {
|
||||
public T foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: JCFooWithUpperBoundDerived.java
|
||||
public class JCFooWithUpperBoundDerived<T extends IBase> extends JCFooWithUpperBound<T> {
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
interface IBase
|
||||
|
||||
interface IDerived : IBase
|
||||
|
||||
interface IFooWithUpperBound<T : IBase> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
interface IFooT<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
interface IFoo {
|
||||
fun foo(): IBase
|
||||
}
|
||||
|
||||
interface IFooDerived : IFoo {
|
||||
override fun foo(): IDerived
|
||||
}
|
||||
|
||||
interface IFooWithUpperBoundDerived<T : IBase> : IFooWithUpperBound<T>
|
||||
|
||||
interface Test1<T : IBase> : IFooWithUpperBound<T>, IFoo
|
||||
|
||||
interface Test2<T : IBase> : IFooT<T>, IFoo
|
||||
|
||||
interface Test3<T : IDerived> : IFooWithUpperBoundDerived<T>, IFooDerived
|
||||
|
||||
interface Test4<T : IBase> : JFooWithUpperBound<T>, IFoo
|
||||
|
||||
interface Test5<T : IDerived> : JFooWithUpperBoundDerived<T>, IFooDerived
|
||||
|
||||
class Test6<T : IBase> : JCFooWithUpperBound<T>(), IFoo
|
||||
|
||||
class Test7<T : IDerived> : JCFooWithUpperBoundDerived<T>(), IFooDerived
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface IFooAny {
|
||||
val foo: Any
|
||||
}
|
||||
|
||||
interface IFooStr : IFooAny {
|
||||
override val foo: String
|
||||
}
|
||||
|
||||
abstract class BaseAny(override val foo: Any): IFooAny
|
||||
|
||||
abstract class BaseStr : BaseAny(42), IFooStr
|
||||
|
||||
class C : BaseStr()
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// FILE: K.kt
|
||||
abstract class ATest1 : TestNN.JNullVsNotNull()
|
||||
|
||||
abstract class ATest2 : TestNN.JUnknownImpl(), TestNN.JNotNull
|
||||
|
||||
abstract class ATest3 : TestNN.JUnknownVsNotNull()
|
||||
|
||||
class CTest1 : TestNN.JNullVsNotNull()
|
||||
|
||||
class CTest2 : TestNN.JUnknownImpl(), TestNN.JNotNull
|
||||
|
||||
class CTest3 : TestNN.JUnknownVsNotNull()
|
||||
|
||||
// FILE: TestNN.java
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class TestNN {
|
||||
public interface JNull {
|
||||
@Nullable Object foo();
|
||||
}
|
||||
|
||||
public interface JNotNull {
|
||||
@NotNull Object foo();
|
||||
}
|
||||
|
||||
public static class JNullVsNotNull implements JNull, JNotNull {
|
||||
public Object foo() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JNullBase {
|
||||
@Nullable public Object foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JUnknownImpl extends JNullBase {
|
||||
public Object foo() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JUnknownVsNotNull extends JUnknownImpl implements JNotNull {
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
interface A {
|
||||
fun <T> foo()
|
||||
fun <T> bar()
|
||||
}
|
||||
|
||||
interface B {
|
||||
fun foo()
|
||||
fun bar()
|
||||
}
|
||||
|
||||
interface C1 : A, B {
|
||||
override fun bar()
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
open class A {
|
||||
open fun foo(): Boolean = true
|
||||
}
|
||||
|
||||
interface IA {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface IAA {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
interface IGA<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
class B1: A(), IA
|
||||
|
||||
class B2: A(), IA, IAA
|
||||
|
||||
abstract class B3: IA, IAA
|
||||
|
||||
class BS1: A(), IGA<Boolean>
|
||||
|
||||
class BS2: A(), IGA<Any>
|
||||
|
||||
class BS3: A(), IGA<String>
|
||||
|
||||
class BG1<T>: A(), IGA<T>
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
interface IA {
|
||||
fun method(): String
|
||||
val propVal: String
|
||||
var propVar: String
|
||||
}
|
||||
|
||||
interface IB1 : IA
|
||||
interface IB2 : IA
|
||||
|
||||
interface IGA<T> {
|
||||
fun method(): T
|
||||
val propVal: T
|
||||
var propVar: T
|
||||
}
|
||||
|
||||
interface IGB1Str : IGA<String>
|
||||
interface IGB2Str : IGA<String>
|
||||
interface IGB3Int : IGA<Int>
|
||||
|
||||
interface IGB4T<T> : IGA<T>
|
||||
interface IGB5T<T> : IGA<T>
|
||||
|
||||
interface IC : IB1, IB2
|
||||
|
||||
interface IGC1 : IGB1Str, IGB2Str
|
||||
|
||||
interface IGC2 : IGB1Str, IGB3Int
|
||||
|
||||
interface IGC3<T> : IGB4T<T>, IGB5T<T>
|
||||
|
||||
interface IGC4<T> : IGB4T<T>, IGB5T<String>
|
||||
|
||||
interface IGC5 : IGB4T<String>, IGB5T<String>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
open class A {
|
||||
open val foo: Boolean = true
|
||||
}
|
||||
|
||||
interface IA {
|
||||
val foo: String
|
||||
}
|
||||
|
||||
interface IAA {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
interface IGA<T> {
|
||||
val foo: T
|
||||
}
|
||||
|
||||
class B1: A(), IA
|
||||
|
||||
class B2: A(), IA, IAA
|
||||
|
||||
abstract class B3: IA, IAA
|
||||
|
||||
class BS1: A(), IGA<Boolean>
|
||||
|
||||
class BS2: A(), IGA<Any>
|
||||
|
||||
class BS3: A(), IGA<String>
|
||||
|
||||
class BG1<T>: A(), IGA<T>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
open class A {
|
||||
open var foo: Boolean = true
|
||||
}
|
||||
|
||||
interface IA {
|
||||
var foo: String
|
||||
}
|
||||
|
||||
interface IAA {
|
||||
var foo: Int
|
||||
}
|
||||
|
||||
interface IGA<T> {
|
||||
var foo: T
|
||||
}
|
||||
|
||||
class B1: A(), IA
|
||||
|
||||
class B2: A(), IA, IAA
|
||||
|
||||
abstract class B3: IA, IAA
|
||||
|
||||
class BS1: A(), IGA<Boolean>
|
||||
|
||||
class BS2: A(), IGA<Any>
|
||||
|
||||
class BS3: A(), IGA<String>
|
||||
|
||||
class BG1<T>: A(), IGA<T>
|
||||
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_REFERENCE
|
||||
|
||||
class Foo
|
||||
|
||||
fun test(a: Foo, b: Foo) {
|
||||
// Note that signature matches the 'equals'
|
||||
fun equals(x: Any?): Boolean = false
|
||||
equals(b)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
abstract class A {
|
||||
abstract override fun toString(): String
|
||||
}
|
||||
|
||||
interface B
|
||||
|
||||
abstract class C : A(), B
|
||||
|
||||
class Test : C()
|
||||
@@ -0,0 +1,14 @@
|
||||
interface A {
|
||||
fun test() {
|
||||
}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun test()
|
||||
}
|
||||
|
||||
interface C : A
|
||||
|
||||
interface D : C, B
|
||||
|
||||
class K : D
|
||||
@@ -0,0 +1,11 @@
|
||||
interface A {
|
||||
fun test(): String = "A"
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun test(): Unit = "B"
|
||||
}
|
||||
|
||||
open class C : A
|
||||
|
||||
class D : C(), B
|
||||
@@ -0,0 +1,11 @@
|
||||
open class Aaa() {
|
||||
open fun foo() = 1
|
||||
}
|
||||
|
||||
open class Bbb() : Aaa() {
|
||||
override fun foo() = 2
|
||||
}
|
||||
|
||||
interface Ccc : Aaa
|
||||
|
||||
class Ddd() : Bbb(), Ccc
|
||||
@@ -0,0 +1,10 @@
|
||||
interface Runnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class C {
|
||||
fun f() {
|
||||
class MyRunnable(): Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface T {
|
||||
public fun foo()
|
||||
}
|
||||
|
||||
open class C {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
class D : C(), T
|
||||
|
||||
val obj: C = object : C(), T {}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface A {
|
||||
fun f(): String
|
||||
}
|
||||
|
||||
open class B {
|
||||
open fun f(): CharSequence = "charSequence"
|
||||
}
|
||||
|
||||
class C : B(), A
|
||||
|
||||
val d: A = object : B(), A {}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface P {
|
||||
var f: Number
|
||||
}
|
||||
|
||||
open class Q {
|
||||
val x: Int = 42
|
||||
}
|
||||
|
||||
class R : P, Q()
|
||||
|
||||
val s: Q = object : Q(), P {}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface T {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
open class C {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
class E : C(), T
|
||||
|
||||
val z: T = object : C(), T {}
|
||||
@@ -0,0 +1,17 @@
|
||||
interface IBase {
|
||||
override fun toString(): String
|
||||
}
|
||||
|
||||
interface IDerived : IBase
|
||||
|
||||
object BaseImpl : IBase {
|
||||
override fun toString(): String = "A"
|
||||
}
|
||||
|
||||
object DerivedImpl : IDerived {
|
||||
override fun toString(): String = "A"
|
||||
}
|
||||
|
||||
class Test1 : IBase by BaseImpl
|
||||
|
||||
class Test2 : IDerived by DerivedImpl
|
||||
@@ -0,0 +1,16 @@
|
||||
// KT-880 Overload resolution ambiguity
|
||||
|
||||
public interface I {
|
||||
open fun test() : Unit
|
||||
}
|
||||
|
||||
abstract public class A() {
|
||||
open public fun test() : Unit {
|
||||
}
|
||||
}
|
||||
|
||||
public open class T() : A(), I {
|
||||
open fun main() : Unit {
|
||||
test() // Test no "Overload resolution ambiguity" is here
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
open class A {
|
||||
private fun foo() {}
|
||||
|
||||
inner class B : A() {
|
||||
private fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class C : A() {
|
||||
private fun foo() {}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
class Foo {
|
||||
open fun openFoo() {}
|
||||
fun finalFoo() {}
|
||||
}
|
||||
|
||||
class Bar : Foo() {
|
||||
override fun openFoo() {}
|
||||
override fun finalFoo() {}
|
||||
}
|
||||
|
||||
|
||||
open class A1 {
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
class B1 : A1()
|
||||
class C1 : B1() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
abstract class A2 {
|
||||
abstract fun foo()
|
||||
}
|
||||
|
||||
class B2 : A2()
|
||||
class C2 : B2() {
|
||||
override fun foo() {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
interface A {
|
||||
fun b(a : Int)
|
||||
}
|
||||
|
||||
interface B : A {}
|
||||
|
||||
class C1 : A {
|
||||
override fun b(b : Int) {}
|
||||
}
|
||||
|
||||
class C2 : B {
|
||||
override fun b(b : Int) {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface C {
|
||||
fun foo(a : Int)
|
||||
}
|
||||
|
||||
interface D {
|
||||
fun foo(b : Int)
|
||||
}
|
||||
|
||||
interface E : C, D
|
||||
|
||||
interface F : C, D {
|
||||
override fun foo(a : Int) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class Function1Impl : (String) -> Unit {
|
||||
override fun invoke(myParamName: String) {}
|
||||
}
|
||||
|
||||
fun test1(f: Function1Impl) {
|
||||
f("")
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(p0 = "")
|
||||
f(myParamName = "")
|
||||
f.invoke("")
|
||||
f.<!INAPPLICABLE_CANDIDATE!>invoke<!>(p0 = "")
|
||||
f.invoke(myParamName = "")
|
||||
}
|
||||
|
||||
fun test2(f: (String) -> Unit) {
|
||||
f("")
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(p0 = "")
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(myParamName = "")
|
||||
f.invoke("")
|
||||
f.<!INAPPLICABLE_CANDIDATE!>invoke<!>(p0 = "")
|
||||
f.<!INAPPLICABLE_CANDIDATE!>invoke<!>(myParamName = "")
|
||||
}
|
||||
|
||||
fun test3(f: String.(String) -> Unit) {
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>("")
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>(p0 = "")
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>(zzz = "")
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: Super.java
|
||||
|
||||
interface Super {
|
||||
void foo(long superName);
|
||||
}
|
||||
|
||||
// FILE: Sub.java
|
||||
|
||||
interface Sub extends Super {
|
||||
}
|
||||
|
||||
// FILE: SubSub.kt
|
||||
|
||||
class SubSub : Sub {
|
||||
override fun foo(subName: Long) {}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: Super.kt
|
||||
|
||||
interface Super {
|
||||
fun foo(superName: Int)
|
||||
}
|
||||
|
||||
// FILE: Sub.java
|
||||
|
||||
interface Sub extends Super {
|
||||
}
|
||||
|
||||
// FILE: SubSub.kt
|
||||
|
||||
class SubSub : Sub {
|
||||
override fun foo(subName: Int) {}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// FILE: KSuper.kt
|
||||
|
||||
interface KSuper {
|
||||
fun foo(ksuperName: Int)
|
||||
}
|
||||
|
||||
// FILE: JSuper1.java
|
||||
|
||||
interface JSuper1 {
|
||||
void foo(int jsuper1Name);
|
||||
}
|
||||
|
||||
// FILE: JSuper2.java
|
||||
|
||||
interface JSuper2 {
|
||||
void foo(int jsuper2Name);
|
||||
}
|
||||
|
||||
|
||||
// FILE: Sub1.java
|
||||
interface Sub1 extends KSuper, JSuper1, JSuper2 {
|
||||
@Override
|
||||
void foo(int sub1Name);
|
||||
}
|
||||
|
||||
// FILE: Sub2.java
|
||||
interface Sub2 extends JSuper1, KSuper, JSuper2 {
|
||||
@Override
|
||||
void foo(int sub2Name);
|
||||
}
|
||||
|
||||
// FILE: Sub3.java
|
||||
interface Sub3 extends JSuper1, JSuper2, KSuper {
|
||||
@Override
|
||||
void foo(int sub3Name);
|
||||
}
|
||||
|
||||
|
||||
// FILE: SubSub.kt
|
||||
|
||||
class SubSub1 : Sub1 {
|
||||
override fun foo(ksuperName: Int) {}
|
||||
}
|
||||
|
||||
class SubSub2 : Sub2 {
|
||||
override fun foo(ksuperName: Int) {}
|
||||
}
|
||||
|
||||
class SubSub3 : Sub3 {
|
||||
override fun foo(ksuperName: Int) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
interface JavaInterface {
|
||||
void foo(int javaName);
|
||||
}
|
||||
|
||||
// FILE: kotlin.kt
|
||||
|
||||
interface KotlinTrait {
|
||||
public fun foo(someOtherName: Int) {}
|
||||
}
|
||||
|
||||
class BothTraitsSubclass : JavaInterface, KotlinTrait
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
public interface JavaInterface {
|
||||
void foo(int javaName);
|
||||
}
|
||||
|
||||
// FILE: kotlin.kt
|
||||
|
||||
class SimpleSubclass : JavaInterface {
|
||||
override fun foo(kotlinName: Int) {}
|
||||
}
|
||||
|
||||
|
||||
interface SubtraitWithFakeOverride : JavaInterface
|
||||
|
||||
class Subclass : SubtraitWithFakeOverride {
|
||||
override fun foo(otherKotlinName: Int) {}
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
interface I1
|
||||
interface I2
|
||||
open class C
|
||||
|
||||
interface A {
|
||||
fun <T> foo(t: T) where T : I1, T : C, T : I2
|
||||
}
|
||||
|
||||
interface B1 : A {
|
||||
override fun <T> foo(t: T) where T : C, T : I1, T : I2
|
||||
}
|
||||
|
||||
interface B2 : A {
|
||||
override fun <T> foo(t: T) where T : I1, T : C, T : I2
|
||||
}
|
||||
|
||||
interface B3 : A {
|
||||
override fun <T> foo(t: T) where T : I1, T : I2, T : C
|
||||
}
|
||||
|
||||
interface B4 : A {
|
||||
override fun <T> foo(t: T) where T : C, T : I2, T : I1
|
||||
}
|
||||
|
||||
interface B5 : A {
|
||||
override fun <T> foo(t: T) where T : I2, T : C, T : I1
|
||||
}
|
||||
|
||||
interface B6 : A {
|
||||
override fun <T> foo(t: T) where T : I2, T : I1, T : C
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
interface A {
|
||||
fun <T> foo() where T : Any, T : Cloneable?
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun <T> foo() where T : Any?, T : Cloneable
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
abstract class Base {
|
||||
abstract fun <T> foo(list: List<T>) where T : Number, T : Comparable<T>
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
override fun <T> foo(list: List<T>) where T : Number, T : Comparable<T> {
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
interface A<R>
|
||||
|
||||
interface B {
|
||||
fun accept(visitor: String)
|
||||
fun <R> accept(visitor: A<R>): R
|
||||
}
|
||||
|
||||
interface C : B {
|
||||
override fun <R> accept(visitor: A<R>): R
|
||||
}
|
||||
Reference in New Issue
Block a user