FIR: Support proper implicit return type computation for local classes
This commit is contained in:
+3
-9
@@ -5,11 +5,8 @@ FILE: localImplicitBodies.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun sss(): <ERROR TYPE REF: Cannot calculate return type during full-body resolution (local class/object?): public final fun abc(): <implicit> {
|
||||
^abc IntegerLiteral(1)
|
||||
}
|
||||
> {
|
||||
^sss R?C|/anonymous.abc|()
|
||||
public final fun sss(): R|kotlin/Int| {
|
||||
^sss this@R|/anonymous|.R|/anonymous.abc|()
|
||||
}
|
||||
|
||||
public final fun abc(): R|kotlin/Int| {
|
||||
@@ -18,8 +15,5 @@ FILE: localImplicitBodies.kt
|
||||
|
||||
}
|
||||
|
||||
lval g: <ERROR TYPE REF: Cannot calculate return type during full-body resolution (local class/object?): public final fun abc(): <implicit> {
|
||||
^abc IntegerLiteral(1)
|
||||
}
|
||||
> = R|<local>/x|.R?C|/anonymous.sss|()
|
||||
lval g: R|kotlin/Int| = R|<local>/x|.R|/anonymous.sss|()
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ FILE: O.kt
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val zz: R|kotlin/Boolean| = R|<local>/z|
|
||||
public final val zz: R|kotlin/Boolean| = this@R|/O.Derived.Some|.R|/O.Derived.Some.z|
|
||||
public get(): R|kotlin/Boolean|
|
||||
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
private val x = object {
|
||||
fun foo(x: Int) = /* here we have not computed return type for "bar" */bar(x)
|
||||
fun bar(y: Int) = this.hashCode() + y > 0
|
||||
|
||||
val w get() = z
|
||||
val z get() = this.hashCode() == 0
|
||||
}
|
||||
|
||||
fun useBoolean(b: Boolean) {}
|
||||
|
||||
fun main() {
|
||||
useBoolean(x.foo(1))
|
||||
useBoolean(x.bar(2))
|
||||
useBoolean(x.w)
|
||||
useBoolean(x.z)
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
FILE: implicitInAnonymous.kt
|
||||
private final val x: R|anonymous| = object : R|kotlin/Any| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^foo this@R|/anonymous|.R|/anonymous.bar|(R|<local>/x|)
|
||||
}
|
||||
|
||||
public final fun bar(y: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^bar CMP(>, this@R|/anonymous|.R|kotlin/Any.hashCode|().R|kotlin/Int.plus|(R|<local>/y|).R|kotlin/Int.compareTo|(Int(0)))
|
||||
}
|
||||
|
||||
public final val w: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ this@R|/anonymous|.R|/anonymous.z|
|
||||
}
|
||||
|
||||
public final val z: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ ==(this@R|/anonymous|.R|kotlin/Any.hashCode|(), Int(0))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private get(): R|anonymous|
|
||||
public final fun useBoolean(b: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
R|/useBoolean|(R|/x|.R|/anonymous.foo|(Int(1)))
|
||||
R|/useBoolean|(R|/x|.R|/anonymous.bar|(Int(2)))
|
||||
R|/useBoolean|(R|/x|.R|/anonymous.w|)
|
||||
R|/useBoolean|(R|/x|.R|/anonymous.z|)
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fun useBoolean(b: Boolean) {}
|
||||
|
||||
fun main() {
|
||||
class A {
|
||||
fun foo(x: Int) = bar(x)
|
||||
fun bar(y: Int) = this.hashCode() + y > 0
|
||||
|
||||
val w get() = z
|
||||
val z get() = this.hashCode() == 0
|
||||
}
|
||||
|
||||
val a = A()
|
||||
|
||||
useBoolean(a.foo(1))
|
||||
useBoolean(a.bar(1))
|
||||
useBoolean(a.w)
|
||||
useBoolean(a.z)
|
||||
|
||||
class B {
|
||||
fun foo(x: Int) = inner.w
|
||||
fun bar(y: Int) = this.hashCode() + y > 0
|
||||
|
||||
val inner = Inner()
|
||||
|
||||
inner class Inner {
|
||||
val w get() = z
|
||||
val z get() = bar(1)
|
||||
}
|
||||
}
|
||||
|
||||
val b = B()
|
||||
|
||||
useBoolean(b.foo(1))
|
||||
useBoolean(b.bar(1))
|
||||
useBoolean(b.inner.w)
|
||||
useBoolean(b.inner.z)
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
FILE: implicitInLocalClasses.kt
|
||||
public final fun useBoolean(b: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
local final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^foo this@R|/A|.R|/A.bar|(R|<local>/x|)
|
||||
}
|
||||
|
||||
public final fun bar(y: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^bar CMP(>, this@R|/A|.R|kotlin/Any.hashCode|().R|kotlin/Int.plus|(R|<local>/y|).R|kotlin/Int.compareTo|(Int(0)))
|
||||
}
|
||||
|
||||
public final val w: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ this@R|/A|.R|/A.z|
|
||||
}
|
||||
|
||||
public final val z: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ ==(this@R|/A|.R|kotlin/Any.hashCode|(), Int(0))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lval a: R|A| = R|/A.A|()
|
||||
R|/useBoolean|(R|<local>/a|.R|/A.foo|(Int(1)))
|
||||
R|/useBoolean|(R|<local>/a|.R|/A.bar|(Int(1)))
|
||||
R|/useBoolean|(R|<local>/a|.R|/A.w|)
|
||||
R|/useBoolean|(R|<local>/a|.R|/A.z|)
|
||||
local final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(x: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^foo this@R|/B|.R|/B.inner|.R|/B.Inner.w|
|
||||
}
|
||||
|
||||
public final fun bar(y: R|kotlin/Int|): R|kotlin/Boolean| {
|
||||
^bar CMP(>, this@R|/B|.R|kotlin/Any.hashCode|().R|kotlin/Int.plus|(R|<local>/y|).R|kotlin/Int.compareTo|(Int(0)))
|
||||
}
|
||||
|
||||
public final val inner: R|B.Inner| = this@R|/B|.R|/B.Inner.Inner|()
|
||||
public get(): R|B.Inner|
|
||||
|
||||
local final inner class Inner : R|kotlin/Any| {
|
||||
public constructor(): R|B.Inner| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val w: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ this@R|/B.Inner|.R|/B.Inner.z|
|
||||
}
|
||||
|
||||
public final val z: R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
^ this@R|/B|.R|/B.bar|(Int(1))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lval b: R|B| = R|/B.B|()
|
||||
R|/useBoolean|(R|<local>/b|.R|/B.foo|(Int(1)))
|
||||
R|/useBoolean|(R|<local>/b|.R|/B.bar|(Int(1)))
|
||||
R|/useBoolean|(R|<local>/b|.R|/B.inner|.R|/B.Inner.w|)
|
||||
R|/useBoolean|(R|<local>/b|.R|/B.inner|.R|/B.Inner.z|)
|
||||
}
|
||||
Reference in New Issue
Block a user