[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
interface I {
|
||||
fun <T : Comparable<T>> f(t: List<T>): Any// T = D, List<D> == List<D>
|
||||
}
|
||||
|
||||
abstract class Base {
|
||||
fun <D : Comparable<D>> f(t: List<D>) {}
|
||||
}
|
||||
|
||||
|
||||
class C : Base(), I
|
||||
|
||||
|
||||
fun f(list: List<Int>) {
|
||||
C().f(list)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
FILE: generics.kt
|
||||
public abstract interface I : R|kotlin/Any| {
|
||||
public abstract fun <T : R|kotlin/Comparable<T>|> f(t: R|kotlin/collections/List<T>|): R|kotlin/Any|
|
||||
|
||||
}
|
||||
public abstract class Base : R|kotlin/Any| {
|
||||
public constructor(): R|Base| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun <D : R|kotlin/Comparable<D>|> f(t: R|kotlin/collections/List<D>|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|Base|, R|I| {
|
||||
public constructor(): R|C| {
|
||||
super<R|Base|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun f(list: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
|
||||
R|/C.C|().R|/Base.f|<R|kotlin/Int|>(R|<local>/list|)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
interface Ext<M : Message<M>, T>
|
||||
interface Message<M : Message<M>> {
|
||||
fun <T> ext(e: Ext<M, T>): T
|
||||
}
|
||||
|
||||
class MyMessage : Message<MyMessage>
|
||||
class MyExt : Ext<MyMessage, String>
|
||||
|
||||
fun <M : Message<M>, T> Message<M>.extF(e: Ext<M, T>): T = ext(e)
|
||||
|
||||
fun foo(m: MyMessage, e: MyExt) {
|
||||
m.ext(e)
|
||||
m.extF(e)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
FILE: protobufExt.kt
|
||||
public abstract interface Ext<M : R|Message<M>|, T> : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface Message<M : R|Message<M>|> : R|kotlin/Any| {
|
||||
public abstract fun <T> ext(e: R|Ext<M, T>|): R|T|
|
||||
|
||||
}
|
||||
public final class MyMessage : R|Message<MyMessage>| {
|
||||
public constructor(): R|MyMessage| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class MyExt : R|Ext<MyMessage, kotlin/String>| {
|
||||
public constructor(): R|MyExt| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <M : R|Message<M>|, T> R|Message<M>|.extF(e: R|Ext<M, T>|): R|T| {
|
||||
^extF this@R|/extF|.R|FakeOverride</Message.ext: R|T|>|<R|T|>(R|<local>/e|)
|
||||
}
|
||||
public final fun foo(m: R|MyMessage|, e: R|MyExt|): R|kotlin/Unit| {
|
||||
R|<local>/m|.R|FakeOverride</MyMessage.ext: R|T|>|<R|kotlin/String|>(R|<local>/e|)
|
||||
R|<local>/m|.R|/extF|<R|MyMessage|, R|kotlin/String|>(R|<local>/e|)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
open class A {
|
||||
open fun foo(): A = this
|
||||
open fun bar(): A = this
|
||||
open fun buz(p: A): A = this
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo(): B = this
|
||||
fun bar(): B = this // Ambiguity, no override here (really it's just "missing override" and no ambiguity)
|
||||
override fun buz(p: B): B = this //No override as B <!:> A
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
<!INAPPLICABLE_CANDIDATE!>buz<!>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
FILE: simple.kt
|
||||
public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun foo(): R|A| {
|
||||
^foo this@R|/A|
|
||||
}
|
||||
|
||||
public open fun bar(): R|A| {
|
||||
^bar this@R|/A|
|
||||
}
|
||||
|
||||
public open fun buz(p: R|A|): R|A| {
|
||||
^buz this@R|/A|
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final override fun foo(): R|B| {
|
||||
^foo this@R|/B|
|
||||
}
|
||||
|
||||
public final fun bar(): R|B| {
|
||||
^bar this@R|/B|
|
||||
}
|
||||
|
||||
public final override fun buz(p: R|B|): R|B| {
|
||||
^buz this@R|/B|
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
this@R|/B|.R|/B.foo|()
|
||||
this@R|/B|.R|/B.bar|()
|
||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/B.buz, /A.buz]>#()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
open class A<T> {
|
||||
fun foo(t: T): T {
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
class Some
|
||||
|
||||
class B : A<Some>() {
|
||||
fun test() {
|
||||
foo(Some())
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
FILE: simpleFakeOverride.kt
|
||||
public open class A<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|A<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(t: R|T|): R|T| {
|
||||
^foo R|<local>/t|
|
||||
}
|
||||
|
||||
}
|
||||
public final class Some : R|kotlin/Any| {
|
||||
public constructor(): R|Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|A<Some>| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A<Some>|>()
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
this@R|/B|.R|FakeOverride</B.foo: R|Some|>|(R|/Some.Some|())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// !CHECK_TYPE
|
||||
interface A {
|
||||
val x: CharSequence
|
||||
|
||||
fun foo(): String?
|
||||
|
||||
fun <T, F> bar(x: T, y: F): F?
|
||||
}
|
||||
|
||||
interface B {
|
||||
var x: String
|
||||
|
||||
fun foo(): String
|
||||
|
||||
fun <X, Y> bar(x: X, y: Y): Y
|
||||
}
|
||||
|
||||
interface C {
|
||||
val x: String
|
||||
}
|
||||
|
||||
interface D1 : A, B
|
||||
interface D2 : B, A
|
||||
interface D3 : A, C
|
||||
|
||||
fun main(d1: D1, d2: D2, d3: D3) {
|
||||
d1.x.checkType { _<String>() }
|
||||
d1.x = ""
|
||||
d1.foo().checkType { _<String>() }
|
||||
d1.bar(1, "").checkType { _<String>() }
|
||||
|
||||
d2.x.checkType { _<String>() }
|
||||
d2.x = ""
|
||||
d2.foo().checkType { _<String>() }
|
||||
d2.bar(1, "").checkType { _<String>() }
|
||||
|
||||
d3.x.checkType { _<String>() }
|
||||
d3.x = ""
|
||||
d3.foo().checkType { _<String?>() }
|
||||
d3.bar(1, "").checkType { _<String?>() }
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
FILE: simpleMostSpecific.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
public abstract val x: R|kotlin/CharSequence|
|
||||
public get(): R|kotlin/CharSequence|
|
||||
|
||||
public abstract fun foo(): R|kotlin/String?|
|
||||
|
||||
public abstract fun <T, F> bar(x: R|T|, y: R|F|): R|F?|
|
||||
|
||||
}
|
||||
public abstract interface B : R|kotlin/Any| {
|
||||
public abstract var x: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
public set(value: R|kotlin/String|): R|kotlin/Unit|
|
||||
|
||||
public abstract fun foo(): R|kotlin/String|
|
||||
|
||||
public abstract fun <X, Y> bar(x: R|X|, y: R|Y|): R|Y|
|
||||
|
||||
}
|
||||
public abstract interface C : R|kotlin/Any| {
|
||||
public abstract val x: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public abstract interface D1 : R|A|, R|B| {
|
||||
}
|
||||
public abstract interface D2 : R|B|, R|A| {
|
||||
}
|
||||
public abstract interface D3 : R|A|, R|C| {
|
||||
}
|
||||
public final fun main(d1: R|D1|, d2: R|D2|, d3: R|D3|): R|kotlin/Unit| {
|
||||
R|<local>/d1|.R|/B.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d1|.R|/B.x| = String()
|
||||
R|<local>/d1|.R|/B.foo|().R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d1|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d2|.R|/B.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d2|.R|/B.x| = String()
|
||||
R|<local>/d2|.R|/B.foo|().R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d2|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d3|.R|/C.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d3|.R|/C.x| = String()
|
||||
R|<local>/d3|.R|/A.foo|().R|tests/_checkType/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>()
|
||||
}
|
||||
)
|
||||
R|<local>/d3|.R|/A.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| {
|
||||
}
|
||||
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
interface I<F> {
|
||||
fun <T : Comparable<T>> f(t: List<T>, f: List<F>): Any// T = D, List<D> == List<D>
|
||||
}
|
||||
|
||||
abstract class Base<E> {
|
||||
fun <D : Comparable<D>> f(t: List<D>, e: List<E>) {}
|
||||
}
|
||||
|
||||
|
||||
class C : Base<String>(), I<String>
|
||||
|
||||
fun f(list: List<Int>, s: List<String>) {
|
||||
C().f(list, s)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
FILE: supertypeGenerics.kt
|
||||
public abstract interface I<F> : R|kotlin/Any| {
|
||||
public abstract fun <T : R|kotlin/Comparable<T>|> f(t: R|kotlin/collections/List<T>|, f: R|kotlin/collections/List<F>|): R|kotlin/Any|
|
||||
|
||||
}
|
||||
public abstract class Base<E> : R|kotlin/Any| {
|
||||
public constructor<E>(): R|Base<E>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun <D : R|kotlin/Comparable<D>|> f(t: R|kotlin/collections/List<D>|, e: R|kotlin/collections/List<E>|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|Base<kotlin/String>|, R|I<kotlin/String>| {
|
||||
public constructor(): R|C| {
|
||||
super<R|Base<kotlin/String>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun f(list: R|kotlin/collections/List<kotlin/Int>|, s: R|kotlin/collections/List<kotlin/String>|): R|kotlin/Unit| {
|
||||
R|/C.C|().R|FakeOverride</C.f: R|kotlin/Unit|>|<R|kotlin/Int|>(R|<local>/list|, R|<local>/s|)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Out<out T>
|
||||
|
||||
interface X : Out<String>
|
||||
|
||||
abstract class Base<E> {
|
||||
fun <D : Out<E>> f(t: MutableList<D>, e: MutableList<E>) {}
|
||||
}
|
||||
|
||||
class C : Base<CharSequence>()
|
||||
|
||||
fun f(list: MutableList<X>, s: MutableList<CharSequence>) {
|
||||
C().f(list, s)
|
||||
C().<!INAPPLICABLE_CANDIDATE!>f<!>(s, list)
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE: supertypeGenericsComplex.kt
|
||||
public final class Out<out T> : R|kotlin/Any| {
|
||||
public constructor<out T>(): R|Out<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface X : R|Out<kotlin/String>| {
|
||||
}
|
||||
public abstract class Base<E> : R|kotlin/Any| {
|
||||
public constructor<E>(): R|Base<E>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun <D : R|Out<E>|> f(t: R|kotlin/collections/MutableList<D>|, e: R|kotlin/collections/MutableList<E>|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|Base<kotlin/CharSequence>| {
|
||||
public constructor(): R|C| {
|
||||
super<R|Base<kotlin/CharSequence>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun f(list: R|kotlin/collections/MutableList<X>|, s: R|kotlin/collections/MutableList<kotlin/CharSequence>|): R|kotlin/Unit| {
|
||||
R|/C.C|().R|FakeOverride</C.f: R|kotlin/Unit|>|<R|X|>(R|<local>/list|, R|<local>/s|)
|
||||
R|/C.C|().<Inapplicable(INAPPLICABLE): [/C.f]>#(R|<local>/s|, R|<local>/list|)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
abstract class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun baz() {}
|
||||
}
|
||||
|
||||
open class B : A(), Y {
|
||||
fun bar() {
|
||||
foo()
|
||||
baz()
|
||||
}
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
FILE: three.kt
|
||||
public abstract class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface Y : R|kotlin/Any| {
|
||||
public open fun baz(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public open class B : R|A|, R|Y| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
this@R|/B|.R|/A.foo|()
|
||||
this@R|/B|.R|/Y.baz|()
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|B| {
|
||||
public constructor(): R|C| {
|
||||
super<R|B|>()
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
this@R|/C|.R|/A.foo|()
|
||||
this@R|/C|.R|/B.bar|()
|
||||
this@R|/C|.R|/Y.baz|()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user