[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 {
|
||||
val calleeReference = thisReceiverExpression.calleeReference
|
||||
val boundSymbol = calleeReference.boundSymbol
|
||||
if (calleeReference.labelName == null) {
|
||||
if (boundSymbol is FirClassSymbol) {
|
||||
// Object case
|
||||
val firClass = boundSymbol.fir as FirClass
|
||||
val irClass = classifierStorage.getCachedIrClass(firClass)!!
|
||||
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.classKind == ClassKind.OBJECT) {
|
||||
if (irClass != conversionScope.lastClass()) {
|
||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol)
|
||||
}
|
||||
if (boundSymbol is FirClassSymbol) {
|
||||
// Object case
|
||||
val firClass = boundSymbol.fir as FirClass
|
||||
val irClass = classifierStorage.getCachedIrClass(firClass)!!
|
||||
if (firClass is FirAnonymousObject || firClass is FirRegularClass && firClass.classKind == ClassKind.OBJECT) {
|
||||
if (irClass != conversionScope.lastClass()) {
|
||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dispatchReceiver = conversionScope.dispatchReceiverParameter(irClass)
|
||||
if (dispatchReceiver != null) {
|
||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
||||
}
|
||||
val dispatchReceiver = conversionScope.dispatchReceiverParameter(irClass)
|
||||
if (dispatchReceiver != null) {
|
||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
|
||||
}
|
||||
} else if (boundSymbol is FirCallableSymbol) {
|
||||
val receiverSymbol = calleeReference.toSymbol(session, classifierStorage, declarationStorage, conversionScope)
|
||||
val receiver = (receiverSymbol?.owner as? IrSimpleFunction)?.extensionReceiverParameter
|
||||
if (receiver != null) {
|
||||
return thisReceiverExpression.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetValueImpl(startOffset, endOffset, receiver.type, receiver.symbol)
|
||||
}
|
||||
}
|
||||
} else if (boundSymbol is FirCallableSymbol) {
|
||||
val receiverSymbol = calleeReference.toSymbol(session, classifierStorage, declarationStorage, conversionScope)
|
||||
val receiver = (receiverSymbol?.owner as? IrSimpleFunction)?.extensionReceiverParameter
|
||||
if (receiver != null) {
|
||||
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
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class A {
|
||||
var value: String = "fail1"
|
||||
private set
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
fun test1(str: String): String {
|
||||
data class A(val x: Int) {
|
||||
fun foo() = str
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
// 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.thisRef2() = fun (): Int {return this}
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// NewInference needed because of KT-26531
|
||||
|
||||
fun Int.thisRef1() = fun () = this
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
val Int.getter: Int
|
||||
get() {
|
||||
return this@getter
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
val Int.getter: Int
|
||||
get() {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
val Int.getter: Int
|
||||
get() {
|
||||
val extFun: Int.() -> Int = {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
interface Base {
|
||||
fun foo(): Int
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class Test {
|
||||
val Int.innerGetter: Int
|
||||
get() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
package test
|
||||
|
||||
val A.a: String
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
package test
|
||||
|
||||
class C(val s : String) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
package test
|
||||
|
||||
class C(val s : String) {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class Outer {
|
||||
val foo = "Foo"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A(open val v: String) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user