[FIR2IR] Fix labeled this references
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3d60fdfed1
commit
a11866ab5a
@@ -287,32 +287,30 @@ class Fir2IrVisitor(
|
|||||||
override fun visitThisReceiverExpression(thisReceiverExpression: FirThisReceiverExpression, data: Any?): IrElement {
|
override fun visitThisReceiverExpression(thisReceiverExpression: FirThisReceiverExpression, data: Any?): IrElement {
|
||||||
val calleeReference = thisReceiverExpression.calleeReference
|
val calleeReference = thisReceiverExpression.calleeReference
|
||||||
val boundSymbol = calleeReference.boundSymbol
|
val boundSymbol = calleeReference.boundSymbol
|
||||||
if (calleeReference.labelName == null) {
|
if (boundSymbol is FirClassSymbol) {
|
||||||
if (boundSymbol is FirClassSymbol) {
|
// Object case
|
||||||
// Object case
|
val firClass = boundSymbol.fir as FirClass
|
||||||
val firClass = boundSymbol.fir as FirClass
|
val irClass = classifierStorage.getCachedIrClass(firClass)!!
|
||||||
val irClass = classifierStorage.getCachedIrClass(firClass)!!
|
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.classKind == ClassKind.OBJECT) {
|
||||||
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.classKind == ClassKind.OBJECT) {
|
if (irClass != conversionScope.lastClass()) {
|
||||||
if (irClass != conversionScope.lastClass()) {
|
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol)
|
||||||
IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val dispatchReceiver = conversionScope.dispatchReceiverParameter(irClass)
|
val dispatchReceiver = conversionScope.dispatchReceiverParameter(irClass)
|
||||||
if (dispatchReceiver != null) {
|
if (dispatchReceiver != null) {
|
||||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (boundSymbol is FirCallableSymbol) {
|
}
|
||||||
val receiverSymbol = calleeReference.toSymbol(session, classifierStorage, declarationStorage, conversionScope)
|
} else if (boundSymbol is FirCallableSymbol) {
|
||||||
val receiver = (receiverSymbol?.owner as? IrSimpleFunction)?.extensionReceiverParameter
|
val receiverSymbol = calleeReference.toSymbol(session, classifierStorage, declarationStorage, conversionScope)
|
||||||
if (receiver != null) {
|
val receiver = (receiverSymbol?.owner as? IrSimpleFunction)?.extensionReceiverParameter
|
||||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
if (receiver != null) {
|
||||||
IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
|
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||||
}
|
IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-1
@@ -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, NATIVE
|
// IGNORE_BACKEND: JS, NATIVE
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class A {
|
class A {
|
||||||
var value: String = "fail1"
|
var value: String = "fail1"
|
||||||
private set
|
private set
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
fun test1(str: String): String {
|
fun test1(str: String): String {
|
||||||
data class A(val x: Int) {
|
data class A(val x: Int) {
|
||||||
fun foo() = str
|
fun foo() = str
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
// 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
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
fun Int.thisRef1() = fun () = this
|
fun Int.thisRef1() = fun () = this
|
||||||
fun Int.thisRef2() = fun (): Int {return this}
|
fun Int.thisRef2() = fun (): Int {return this}
|
||||||
|
|||||||
Vendored
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +NewInference
|
// !LANGUAGE: +NewInference
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// NewInference needed because of KT-26531
|
// NewInference needed because of KT-26531
|
||||||
|
|
||||||
fun Int.thisRef1() = fun () = this
|
fun Int.thisRef1() = fun () = this
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
val Int.getter: Int
|
val Int.getter: Int
|
||||||
get() {
|
get() {
|
||||||
return this@getter
|
return this@getter
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
val Int.getter: Int
|
val Int.getter: Int
|
||||||
get() {
|
get() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
val Int.getter: Int
|
val Int.getter: Int
|
||||||
get() {
|
get() {
|
||||||
val extFun: Int.() -> Int = {
|
val extFun: Int.() -> Int = {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
interface Base {
|
interface Base {
|
||||||
fun foo(): Int
|
fun foo(): Int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Test {
|
class Test {
|
||||||
val Int.innerGetter: Int
|
val Int.innerGetter: Int
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
val A.a: String
|
val A.a: String
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
class C(val s : String) {
|
class C(val s : String) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
class C(val s : String) {
|
class C(val s : String) {
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
class Outer {
|
class Outer {
|
||||||
val foo = "Foo"
|
val foo = "Foo"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A(open val v: String) {
|
open class A(open val v: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user