Expand ConeTypeContext, implement FIR type inference & related checkers
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f1eb66819b
commit
1dae135840
@@ -36,8 +36,8 @@ FILE: access.kt
|
||||
^plus String()
|
||||
}
|
||||
|
||||
public final fun R|Foo|.check(): <ERROR TYPE REF: Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]> {
|
||||
^check R|/Foo.abc|().<Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(R|/Bar.bar|())
|
||||
public final fun R|Foo|.check(): R|kotlin/String| {
|
||||
^check R|/Foo.abc|().R|/Bar.plus|(R|/Bar.bar|())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class A
|
||||
open class B
|
||||
class C : B
|
||||
|
||||
|
||||
fun bar(a: A) = a
|
||||
fun bar(b: B) = b
|
||||
|
||||
fun foo() {
|
||||
val a = A()
|
||||
val b = B()
|
||||
val c = C()
|
||||
val ra = bar(a)
|
||||
val rb = bar(b)
|
||||
val rc = bar(c)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
FILE: checkArguments.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
}
|
||||
public open class B : R|kotlin/Any| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
}
|
||||
public final class C : R|B|, R|kotlin/Any| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
}
|
||||
public final fun bar(a: R|A|): R|A| {
|
||||
^bar R|<local>/a|
|
||||
}
|
||||
public final fun bar(b: R|B|): R|B| {
|
||||
^bar R|<local>/b|
|
||||
}
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval a: R|A| = R|/A.A|()
|
||||
lval b: R|B| = R|/B.B|()
|
||||
lval c: R|C| = R|/C.C|()
|
||||
lval ra: R|A| = R|/bar|(R|<local>/a|)
|
||||
lval rb: R|B| = R|/bar|(R|<local>/b|)
|
||||
lval rc: R|B| = R|/bar|(R|<local>/c|)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
|
||||
fun main() {
|
||||
val a = id("string")
|
||||
val b = id(null)
|
||||
val c = id(id(a))
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
FILE: id.kt
|
||||
public final fun <T> id(t: R|T|): R|T| {
|
||||
^id R|<local>/t|
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/String| = R|/id|<R|kotlin/String|>(String(string))
|
||||
lval b: R|kotlin/Nothing|? = R|/id|<R|kotlin/Nothing|?>(Null(null))
|
||||
lval c: R|kotlin/String| = R|/id|<R|kotlin/String|>(R|/id|<R|kotlin/String|>(R|<local>/a|))
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface Foo
|
||||
class FooImpl : Foo
|
||||
class Bar
|
||||
|
||||
fun <T : Foo> foo(t: T) = t
|
||||
|
||||
|
||||
fun main(fooImpl: FooImpl, bar: Bar) {
|
||||
val a = foo(fooImpl)
|
||||
val b = foo(bar)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
FILE: typeParameters.kt
|
||||
public abstract interface Foo : R|kotlin/Any| {
|
||||
}
|
||||
public final class FooImpl : R|Foo| {
|
||||
public constructor(): R|FooImpl| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Bar : R|kotlin/Any| {
|
||||
public constructor(): R|Bar| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <T : R|Foo|> foo(t: R|T|): R|T| {
|
||||
^foo R|<local>/t|
|
||||
}
|
||||
public final fun main(fooImpl: R|FooImpl|, bar: R|Bar|): R|kotlin/Unit| {
|
||||
lval a: R|FooImpl| = R|/foo|<R|FooImpl|>(R|<local>/fooImpl|)
|
||||
lval b: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#(R|<local>/bar|)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface Foo
|
||||
class FooImpl : Foo
|
||||
class FooBarImpl : Foo
|
||||
|
||||
fun <T : Foo> foo(t: T) = t
|
||||
|
||||
|
||||
fun main(fooImpl: FooImpl, fooBarImpl: FooBarImpl) {
|
||||
val a = foo<FooImpl>(fooBarImpl)
|
||||
val b = foo<Foo>(fooImpl)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
FILE: typeParameters2.kt
|
||||
public abstract interface Foo : R|kotlin/Any| {
|
||||
}
|
||||
public final class FooImpl : R|Foo| {
|
||||
public constructor(): R|FooImpl| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class FooBarImpl : R|Foo| {
|
||||
public constructor(): R|FooBarImpl| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <T : R|Foo|> foo(t: R|T|): R|T| {
|
||||
^foo R|<local>/t|
|
||||
}
|
||||
public final fun main(fooImpl: R|FooImpl|, fooBarImpl: R|FooBarImpl|): R|kotlin/Unit| {
|
||||
lval a: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#<R|FooImpl|>(R|<local>/fooBarImpl|)
|
||||
lval b: R|Foo| = R|/foo|<R|Foo|>(R|<local>/fooImpl|)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ FILE: enums.kt
|
||||
|
||||
}
|
||||
|
||||
public final val g: R|kotlin/Double| = <Unresolved name: G>#.<Unresolved name: times>#(R|/Planet.m|).<Unresolved name: div>#(R|/Planet.r|.<Ambiguity: times, [kotlin/Double.times, kotlin/Double.times, kotlin/Double.times, kotlin/Double.times, kotlin/Double.times, kotlin/Double.times]>#(R|/Planet.r|))
|
||||
public final val g: R|kotlin/Double| = <Unresolved name: G>#.<Unresolved name: times>#(R|/Planet.m|).<Unresolved name: div>#(R|/Planet.r|.R|kotlin/Double.times|(R|/Planet.r|))
|
||||
public get(): R|kotlin/Double|
|
||||
|
||||
public abstract fun sayHello(): R|kotlin/Unit|
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main() {
|
||||
println("Hello, world!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
FILE: helloWorld.kt
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|kotlin/io/println|(String(Hello, world!))
|
||||
}
|
||||
Reference in New Issue
Block a user