[FIR] Fix anonymous object handling as 'this' receiver

This commit is contained in:
Jinseong Jeon
2020-03-27 00:06:56 -07:00
committed by Mikhail Glukhikh
parent c8206c4666
commit 4388b30f87
19 changed files with 12 additions and 25 deletions
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperator
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
@@ -286,7 +285,7 @@ class Fir2IrVisitor(
override fun visitThisReceiverExpression(thisReceiverExpression: FirThisReceiverExpression, data: Any?): IrElement {
val calleeReference = thisReceiverExpression.calleeReference
if (calleeReference.labelName == null && calleeReference.boundSymbol is FirRegularClassSymbol) {
if (calleeReference.labelName == null && calleeReference.boundSymbol is FirClassSymbol) {
// Object case
val firObject = (calleeReference.boundSymbol?.fir as? FirClass)?.takeIf {
it is FirAnonymousObject || it is FirRegularClass && it.classKind == ClassKind.OBJECT
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
fun box() : String {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class B () {}
open class A(val b : B) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface T {
fun result(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface T {
fun result(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface T {
fun result(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KT-4423 Enum with function not compiled
enum class Sign(val str: String, val func: (x: Int, y: Int) -> Int){
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
enum class Direction() {
NORTH {
val someSpecialValue = "OK"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
enum class Bar {
ONE {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
enum class A(val b: String) {
E1("OK"){ override fun t() = b };
@@ -1,3 +1,4 @@
// IGNORE_BACKEND_FIR: JVM_IR
enum class X {
B {
val value2 = "K"
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface MyIterator<T> {
operator fun hasNext() : Boolean
operator fun next() : T
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface T {
fun foo(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
abstract class Your {
abstract val your: String
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
abstract class Your {
abstract val your: String
@@ -41,10 +41,10 @@ FILE fqName:<root> fileName:/enumEntryReferenceFromEnumEntryClass.kt
$this: VALUE_PARAMETER name:<this> type:<root>.MyEnum.Z
BLOCK_BODY
CALL 'public final fun <set-counter> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=EQ
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z.bar' type=<root>.MyEnum.Z origin=null
<set-?>: CONST Int type=kotlin.Int value=1
CALL 'public final fun foo (): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=null
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z.bar' type=<root>.MyEnum.Z origin=null
PROPERTY name:aLambda visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:aLambda type:kotlin.Function0<kotlin.Unit> visibility:private [final]
EXPRESSION_BODY
@@ -76,18 +76,18 @@ FILE fqName:<root> fileName:/enumEntryReferenceFromEnumEntryClass.kt
ANONYMOUS_INITIALIZER isStatic=false
BLOCK_BODY
CALL 'public final fun <set-counter> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=EQ
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_OBJECT 'CLASS ENUM_ENTRY name:Z modality:FINAL visibility:private superTypes:[<root>.MyEnum]' type=<root>.MyEnum.Z
<set-?>: CONST Int type=kotlin.Int value=1
CALL 'public final fun foo (): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=null
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_OBJECT 'CLASS ENUM_ENTRY name:Z modality:FINAL visibility:private superTypes:[<root>.MyEnum]' type=<root>.MyEnum.Z
FUN name:test visibility:public modality:FINAL <> ($this:<root>.MyEnum.Z.anObject.<no name provided>) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.MyEnum.Z.anObject.<no name provided>
BLOCK_BODY
CALL 'public final fun <set-counter> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=EQ
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_OBJECT 'CLASS ENUM_ENTRY name:Z modality:FINAL visibility:private superTypes:[<root>.MyEnum]' type=<root>.MyEnum.Z
<set-?>: CONST Int type=kotlin.Int value=1
CALL 'public final fun foo (): kotlin.Unit declared in <root>.MyEnum.Z' type=kotlin.Unit origin=null
$this: GET_VAR '<this>: <root>.MyEnum.Z declared in <root>.MyEnum.Z' type=<root>.MyEnum.Z origin=null
$this: GET_OBJECT 'CLASS ENUM_ENTRY name:Z modality:FINAL visibility:private superTypes:[<root>.MyEnum]' type=<root>.MyEnum.Z
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum.Z.anObject.<no name provided>' type=<root>.MyEnum.Z.anObject.<no name provided> origin=OBJECT_LITERAL
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-anObject> visibility:public modality:FINAL <> ($this:<root>.MyEnum.Z) returnType:<root>.MyEnum.Z.anObject.<no name provided>
correspondingProperty: PROPERTY name:anObject visibility:public modality:FINAL [val]
@@ -86,7 +86,7 @@ FILE fqName:<root> fileName:/multipleThisReferences.kt
EXPRESSION_BODY
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: CALL 'public final fun <get-x> (): kotlin.Int declared in <root>.Outer.Inner' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Host.test.<no name provided> declared in <root>.Host.test.<no name provided>' type=<root>.Host.test.<no name provided> origin=null
$this: GET_VAR '<this>: <root>.Host declared in <root>.Host.test' type=<root>.Host origin=null
other: CALL 'public final fun <get-y> (): kotlin.Int declared in <root>.Host' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Host declared in <root>.Host.test' type=<root>.Host origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-xx> visibility:public modality:FINAL <> ($this:<root>.Host.test.<no name provided>) returnType:kotlin.Int
+1 -1
View File
@@ -29,7 +29,7 @@ FILE fqName:<root> fileName:/enumEntry.kt
$this: VALUE_PARAMETER name:<this> type:<root>.Z.ENTRY.A
BLOCK_BODY
CALL 'public final fun test (): kotlin.Unit declared in <root>.Z.ENTRY' type=kotlin.Unit origin=null
$this: GET_VAR '<this>: <root>.Z.ENTRY declared in <root>.Z.ENTRY' type=<root>.Z.ENTRY origin=null
$this: GET_OBJECT 'CLASS ENUM_ENTRY name:ENTRY modality:FINAL visibility:private superTypes:[<root>.Z]' type=<root>.Z.ENTRY
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
@@ -304,10 +304,10 @@ FILE fqName:<root> fileName:/genericDelegatedDeepProperty.kt
<class: P1>: T of <root>.<get-additionalText>
<class: P2>: T of <root>.<get-additionalText>
p1: CALL 'public final fun <get-deepO> (): T of <root>.<get-additionalText> declared in <root>.additionalText$delegate.<no name provided>' type=T of <root>.<get-additionalText> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.additionalText$delegate.<no name provided> declared in <root>.additionalText$delegate.<no name provided>' type=<root>.additionalText$delegate.<no name provided> origin=null
$this: GET_VAR '<this>: <root>.additionalText$delegate.<no name provided> declared in <root>.additionalText$delegate.<no name provided>.getValue' type=<root>.additionalText$delegate.<no name provided> origin=null
$receiver: GET_VAR 't: <root>.Value<T of <root>.<get-additionalText>, <root>.CR<T of <root>.<get-additionalText>>> declared in <root>.additionalText$delegate.<no name provided>.getValue' type=<root>.Value<T of <root>.<get-additionalText>, <root>.CR<T of <root>.<get-additionalText>>> origin=null
p2: CALL 'public final fun <get-deepK> (): T of <root>.<get-additionalText> declared in <root>.additionalText$delegate.<no name provided>' type=T of <root>.<get-additionalText> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.additionalText$delegate.<no name provided> declared in <root>.additionalText$delegate.<no name provided>' type=<root>.additionalText$delegate.<no name provided> origin=null
$this: GET_VAR '<this>: <root>.additionalText$delegate.<no name provided> declared in <root>.additionalText$delegate.<no name provided>.getValue' type=<root>.additionalText$delegate.<no name provided> origin=null
$receiver: GET_VAR 't: <root>.Value<T of <root>.<get-additionalText>, <root>.CR<T of <root>.<get-additionalText>>> declared in <root>.additionalText$delegate.<no name provided>.getValue' type=<root>.Value<T of <root>.<get-additionalText>, <root>.CR<T of <root>.<get-additionalText>>> origin=null
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.additionalText$delegate.<no name provided>' type=<root>.additionalText$delegate.<no name provided> origin=OBJECT_LITERAL
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-additionalText> visibility:public modality:FINAL <T> ($receiver:<root>.Value<T of <root>.<get-additionalText>, <root>.CR<T of <root>.<get-additionalText>>>) returnType:<root>.P<T of <root>.<get-additionalText>, T of <root>.<get-additionalText>>