FIR: use dispatch receiver of the enclosing function if any.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a363a5be58
commit
de0c9a5c73
@@ -77,15 +77,17 @@ class Fir2IrConversionScope {
|
|||||||
fun parent(): IrDeclarationParent? = parentStack.lastOrNull()
|
fun parent(): IrDeclarationParent? = parentStack.lastOrNull()
|
||||||
|
|
||||||
fun lastDispatchReceiverParameter(): IrValueParameter? {
|
fun lastDispatchReceiverParameter(): IrValueParameter? {
|
||||||
val dispatchReceiver = functionStack.lastOrNull()?.dispatchReceiverParameter
|
var dispatchReceiver = functionStack.lastOrNull()?.dispatchReceiverParameter
|
||||||
return if (dispatchReceiver != null) {
|
// Use the dispatch receiver of the containing function
|
||||||
// Use the dispatch receiver of the containing function
|
dispatchReceiver?.let { return it }
|
||||||
dispatchReceiver
|
|
||||||
} else {
|
// Use the dispatch receiver of the enclosing function if any
|
||||||
val lastClassSymbol = classStack.lastOrNull()?.symbol
|
dispatchReceiver = functionStack.elementAtOrNull(functionStack.size - 2)?.dispatchReceiverParameter
|
||||||
// Use the dispatch receiver of the containing class
|
dispatchReceiver?.let { return it }
|
||||||
lastClassSymbol?.owner?.thisReceiver
|
|
||||||
}
|
// Use the dispatch receiver of the containing class
|
||||||
|
val lastClassSymbol = classStack.lastOrNull()?.symbol
|
||||||
|
return lastClassSymbol?.owner?.thisReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
fun lastClass(): IrClass? = classStack.lastOrNull()
|
fun lastClass(): IrClass? = classStack.lastOrNull()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||||
// IGNORE_BACKEND: JS
|
// IGNORE_BACKEND: JS
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class C(val f: () -> String)
|
open class C(val f: () -> String)
|
||||||
|
|
||||||
class B(val x: String) {
|
class B(val x: String) {
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
abstract class Base(val fn: () -> String)
|
abstract class Base(val fn: () -> String)
|
||||||
|
|
||||||
open class Outer {
|
open class Outer {
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
abstract class Base(val fn: () -> String)
|
abstract class Base(val fn: () -> String)
|
||||||
|
|
||||||
class Outer {
|
class Outer {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Point(val x:Int, val y:Int) {
|
class Point(val x:Int, val y:Int) {
|
||||||
fun mul() : (scalar:Int)->Point {
|
fun mul() : (scalar:Int)->Point {
|
||||||
return { scalar:Int -> Point(x * scalar, y * scalar) }
|
return { scalar:Int -> Point(x * scalar, y * scalar) }
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: Foo.kt
|
// FILE: Foo.kt
|
||||||
|
|
||||||
package foo
|
package foo
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class X {
|
class X {
|
||||||
fun g(x: () -> Boolean = { super.equals(this) }) = x()
|
fun g(x: () -> Boolean = { super.equals(this) }) = x()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
var sayResult = ""
|
var sayResult = ""
|
||||||
|
|
||||||
class NoiseMaker {
|
class NoiseMaker {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
var result = ""
|
var result = ""
|
||||||
fun result(r: String) { result = r }
|
fun result(r: String) { result = r }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
//KT-3190 Compiler crash if function called 'invoke' calls a closure
|
//KT-3190 Compiler crash if function called 'invoke' calls a closure
|
||||||
// IGNORE_BACKEND: JS
|
// IGNORE_BACKEND: JS
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline class Composed(val s: String) {
|
inline class Composed(val s: String) {
|
||||||
|
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline class R(private val r: Int) {
|
inline class R(private val r: Int) {
|
||||||
fun test() = { ok() }()
|
fun test() = { ok() }()
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline class R(private val r: Long) {
|
inline class R(private val r: Long) {
|
||||||
fun test() = { ok() }()
|
fun test() = { ok() }()
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline class R(private val r: Int) {
|
inline class R(private val r: Int) {
|
||||||
fun test() = { ok() }()
|
fun test() = { ok() }()
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline class R(private val r: Long) {
|
inline class R(private val r: Long) {
|
||||||
fun test() = { ok() }()
|
fun test() = { ok() }()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
inline class Z(private val i: Int) {
|
inline class Z(private val i: Int) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// !JVM_DEFAULT_MODE: enable
|
// !JVM_DEFAULT_MODE: enable
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// !JVM_DEFAULT_MODE: enable
|
// !JVM_DEFAULT_MODE: enable
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
var log = ""
|
var log = ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline fun on(body: () -> Any) = body().toString()
|
inline fun on(body: () -> Any) = body().toString()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: -ProperVisibilityForCompanionObjectInstanceField
|
// !LANGUAGE: -ProperVisibilityForCompanionObjectInstanceField
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
inline fun on(body: () -> Any) = body().toString()
|
inline fun on(body: () -> Any) = body().toString()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
inline fun on(body: () -> Any) = body().toString()
|
inline fun on(body: () -> Any) = body().toString()
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// See KT-14999
|
// See KT-14999
|
||||||
|
|
||||||
object Obj {
|
object Obj {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class My {
|
class My {
|
||||||
val my: String = "O"
|
val my: String = "O"
|
||||||
get() = { field }() + "K"
|
get() = { field }() + "K"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class P {
|
class P {
|
||||||
var x : Int = 0
|
var x : Int = 0
|
||||||
private set
|
private set
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A
|
open class A
|
||||||
class B : A() {
|
class B : A() {
|
||||||
fun foo() = 1
|
fun foo() = 1
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class A {
|
class A {
|
||||||
public var prop = "OK"
|
public var prop = "OK"
|
||||||
private set
|
private set
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class A(
|
class A(
|
||||||
private val x: String,
|
private val x: String,
|
||||||
private var y: Double
|
private var y: Double
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Test {
|
class Test {
|
||||||
private var i : Int
|
private var i : Int
|
||||||
get() = 1
|
get() = 1
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
//KT-10934 compiler throws UninferredParameterTypeConstructor in when block that covers all types
|
//KT-10934 compiler throws UninferredParameterTypeConstructor in when block that covers all types
|
||||||
|
|
||||||
class Parser<TInput, TValue>(val f: (TInput) -> Result<TInput, TValue>) {
|
class Parser<TInput, TValue>(val f: (TInput) -> Result<TInput, TValue>) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class C(val f: () -> Unit) {
|
open class C(val f: () -> Unit) {
|
||||||
fun test() {
|
fun test() {
|
||||||
f()
|
f()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class X(var s: ()-> Unit)
|
open class X(var s: ()-> Unit)
|
||||||
|
|
||||||
open class C(val f: X) {
|
open class C(val f: X) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
import b.B
|
import b.B
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class A {
|
class A {
|
||||||
fun foo() = o_plus_f_plus_k {""}
|
fun foo() = o_plus_f_plus_k {""}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class A {
|
class A {
|
||||||
private inline fun f() = g()
|
private inline fun f() = g()
|
||||||
private fun g() = "OK"
|
private fun g() = "OK"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Foo {
|
class Foo {
|
||||||
private val fld: String = "O"
|
private val fld: String = "O"
|
||||||
get() = { field }() + "K"
|
get() = { field }() + "K"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Foo {
|
class Foo {
|
||||||
private val fld: String = "O"
|
private val fld: String = "O"
|
||||||
get() = { field }() + "K"
|
get() = { field }() + "K"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: kt36973.kt
|
// FILE: kt36973.kt
|
||||||
import other.*
|
import other.*
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user