diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 97ba1db06b9..004ea58400a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -360,7 +360,8 @@ class Fir2IrDeclarationStorage( val containerSource = function.containerSource val descriptor = containerSource?.let { WrappedFunctionDescriptorWithContainerSource(it) } ?: WrappedSimpleFunctionDescriptor() return function.convertWithOffsets { startOffset, endOffset -> - irSymbolTable.declareSimpleFunction(startOffset, endOffset, origin, descriptor) { symbol -> + enterScope(descriptor) + val result = irSymbolTable.declareSimpleFunction(startOffset, endOffset, origin, descriptor) { symbol -> IrFunctionImpl( startOffset, endOffset, origin, symbol, function.name, function.visibility, function.modality!!, @@ -372,6 +373,8 @@ class Fir2IrDeclarationStorage( isExpect = function.isExpect ) } + leaveScope(descriptor) + result }.bindAndDeclareParameters(function, descriptor, irParent, isStatic = function.isStatic, shouldLeaveScope = shouldLeaveScope) } @@ -486,7 +489,8 @@ class Fir2IrDeclarationStorage( val containerSource = property.containerSource val descriptor = containerSource?.let { WrappedPropertyDescriptorWithContainerSource(it) } ?: WrappedPropertyDescriptor() property.convertWithOffsets { startOffset, endOffset -> - irSymbolTable.declareProperty( + enterScope(descriptor) + val result = irSymbolTable.declareProperty( startOffset, endOffset, origin, descriptor, property.delegate != null ) { symbol -> @@ -525,6 +529,8 @@ class Fir2IrDeclarationStorage( } } } + leaveScope(descriptor) + result } } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 3af504c1cdf..8a6c919eebc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -526,6 +526,7 @@ class Fir2IrVisitor( property: FirProperty, firOverriddenSymbol: FirPropertySymbol? = null ): IrProperty { + declarationStorage.enterScope(descriptor) val initializer = property.initializer val delegate = property.delegate val irParent = this.parent @@ -572,6 +573,7 @@ class Fir2IrVisitor( property.annotations.forEach { annotations += it.accept(this@Fir2IrVisitor, null) as IrConstructorCall } + declarationStorage.leaveScope(descriptor) return this } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt index 137fde703dc..b2646f7d45f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.Name interface ImplicitReceiverStack { - fun add(name: Name, value: ImplicitReceiverValue<*>) - fun pop(name: Name) + fun add(name: Name?, value: ImplicitReceiverValue<*>) + fun pop(name: Name?) operator fun get(name: String?): ImplicitReceiverValue<*>? @@ -31,17 +31,21 @@ class ImplicitReceiverStackImpl : ImplicitReceiverStack, Iterable, Int> = mutableMapOf() val size: Int get() = stack.size - override fun add(name: Name, value: ImplicitReceiverValue<*>) { + override fun add(name: Name?, value: ImplicitReceiverValue<*>) { stack += value originalTypes += value.type val index = stack.size - 1 - indexesPerLabel.put(name, index) + if (name != null) { + indexesPerLabel.put(name, index) + } indexesPerSymbol.put(value.boundSymbol, index) } - override fun pop(name: Name) { + override fun pop(name: Name?) { val index = stack.size - 1 - indexesPerLabel.remove(name, index) + if (name != null) { + indexesPerLabel.remove(name, index) + } originalTypes.removeAt(index) val value = stack.removeAt(index) indexesPerSymbol.remove(value.boundSymbol) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt index d93c5e7dbe9..c3631dbbf76 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt @@ -6,6 +6,8 @@ package org.jetbrains.kotlin.fir.resolve import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject +import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope @@ -18,8 +20,8 @@ fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession) is ConeKotlinErrorType -> null is ConeAbbreviatedType -> directExpansionType(useSiteSession)?.scope(useSiteSession, scopeSession) is ConeClassLikeType -> { - // TODO: for ConeClassLikeType they might be a type alias instead of a regular class - val fir = this.lookupTag.toSymbol(useSiteSession)?.fir as? FirRegularClass ?: return null + // TODO: for ConeClassLikeType they might be a type alias instead of a class + val fir = this.lookupTag.toSymbol(useSiteSession)?.fir as? FirClass<*> ?: return null wrapSubstitutionScopeIfNeed(useSiteSession, fir.buildUseSiteMemberScope(useSiteSession, scopeSession)!!, fir, scopeSession) } is ConeTypeParameterType -> { @@ -53,3 +55,11 @@ fun FirRegularClass.defaultType(): ConeClassTypeImpl { isNullable = false ) } + +fun FirAnonymousObject.defaultType(): ConeClassTypeImpl { + return ConeClassTypeImpl( + symbol.toLookupTag(), + emptyArray(), + isNullable = false + ) +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt index b5168d24935..5cb219118c4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt @@ -55,7 +55,7 @@ fun FirClassSymbol<*>.buildUseSiteMemberScope(useSiteSession: FirSession, builde } } -fun FirRegularClass.buildUseSiteMemberScope(useSiteSession: FirSession, builder: ScopeSession): FirScope? { +fun FirClass<*>.buildUseSiteMemberScope(useSiteSession: FirSession, builder: ScopeSession): FirScope? { if (classId.isLocal) { // It's not possible to find local class by symbol return buildDefaultUseSiteMemberScope(useSiteSession, builder) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt index a75cc44e388..a4e4936406a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/ReturnTypeCalculator.kt @@ -67,10 +67,9 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc classId.outerClassId }.mapTo(mutableListOf()) { provider.getFirClassifierByFqName(it) } - if (file == null || outerClasses.any { it == null }) return FirErrorTypeRefImpl( - null, - "I don't know what todo" - ) + if (file == null || outerClasses.any { it == null }) { + return FirErrorTypeRefImpl(null, "Cannot calculate return type (local class/object?)") + } declaration.transformReturnTypeRef( TransformImplicitType, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index a6e6c1edc0d..d1abbb27ab7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -150,6 +150,10 @@ open class FirBodyResolveTransformer( return declarationsTransformer.transformRegularClass(regularClass, data) } + override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): CompositeTransformResult { + return declarationsTransformer.transformAnonymousObject(anonymousObject, data) + } + override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?): CompositeTransformResult { return declarationsTransformer.transformSimpleFunction(simpleFunction, data) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 4e89f1db57a..c09e1927ea0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -151,6 +151,15 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) return result as CompositeTransformResult } + override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): CompositeTransformResult { + val type = anonymousObject.defaultType() + anonymousObject.resultType = FirResolvedTypeRefImpl(anonymousObject.source, type) + val result = withLabelAndReceiverType(null, anonymousObject, type) { + transformDeclaration(anonymousObject, data) + } + return result as CompositeTransformResult + } + private fun transformAnonymousFunctionWithLambdaResolution( anonymousFunction: FirAnonymousFunction, lambdaResolution: LambdaResolution ): FirAnonymousFunction { @@ -339,13 +348,13 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) } private inline fun withLabelAndReceiverType( - labelName: Name, + labelName: Name?, owner: FirDeclaration, type: ConeKotlinType, block: () -> T ): T { val implicitReceiverValue = when (owner) { - is FirRegularClass -> { + is FirClass<*> -> { ImplicitDispatchReceiverValue(owner.symbol, type, symbolProvider, session, scopeSession) } is FirFunction<*> -> { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/localImplicitBodies.txt b/compiler/fir/resolve/testData/resolve/expresssions/localImplicitBodies.txt index a9df799a27d..ba88b60031d 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/localImplicitBodies.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/localImplicitBodies.txt @@ -1,12 +1,12 @@ FILE: localImplicitBodies.kt public final fun foo(): R|kotlin/Unit| { - lval x: R|kotlin/Any| = object : R|kotlin/Any| { + lval x: R|anonymous| = object : R|kotlin/Any| { private constructor(): R|kotlin/Any| { super() } - public final fun sss(): { - ^sss #() + public final fun sss(): { + ^sss R?C|/abc|() } public final fun abc(): R|kotlin/Int| { @@ -15,5 +15,5 @@ FILE: localImplicitBodies.kt } - lval g: = R|/x|.#() + lval g: = R|/x|.R?C|/sss|() } diff --git a/compiler/fir/resolve/testData/resolve/localObject.txt b/compiler/fir/resolve/testData/resolve/localObject.txt index 8b46686c66b..0fa64d5feba 100644 --- a/compiler/fir/resolve/testData/resolve/localObject.txt +++ b/compiler/fir/resolve/testData/resolve/localObject.txt @@ -8,7 +8,7 @@ FILE: localObject.kt } public final fun tesLambda(x: R|kotlin/Int|): R|kotlin/Int| { ^tesLambda R|/run|( = run@fun (): R|kotlin/Int| { - lval obj: R|Foo| = object : R|Foo| { + lval obj: R|anonymous| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() } @@ -34,7 +34,7 @@ FILE: localObject.kt public final var x: R|kotlin/Int| = Int(1) public get(): R|kotlin/Int| public set(value: R|kotlin/Int|): R|kotlin/Unit| { - lval obj: R|Foo| = object : R|Foo| { + lval obj: R|anonymous| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() } @@ -50,7 +50,7 @@ FILE: localObject.kt public final val y: R|kotlin/Int| public get(): R|kotlin/Int| { - lval obj: R|Foo| = object : R|Foo| { + lval obj: R|anonymous| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() } @@ -65,7 +65,7 @@ FILE: localObject.kt } public final val z: R|kotlin/Int| = R|/run|( = run@fun (): R|kotlin/Int| { - lval obj: R|Foo| = object : R|Foo| { + lval obj: R|anonymous| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt index 97827a4c002..befefd03d76 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems.txt @@ -1,7 +1,7 @@ FILE: problems.kt public final val sb: R|java/lang/StringBuilder| = R|java/lang/StringBuilder.StringBuilder|() public get(): R|java/lang/StringBuilder| - public final val o: R|kotlin/Any| = object : R|kotlin/Any| { + public final val o: R|anonymous| = object : R|kotlin/Any| { private constructor(): R|kotlin/Any| { super() } @@ -10,12 +10,12 @@ FILE: problems.kt public get(): R|kotlin/String| public final fun test(): R|kotlin/Unit| { - # + R|/name| } } - public get(): R|kotlin/Any| + public get(): R|anonymous| public final fun test(): R|kotlin/Unit| { local final class Local : R|kotlin/Any| { public constructor(): R|Local| { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt index f013cdac6a5..62598d37c7d 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt @@ -61,7 +61,7 @@ fun FirEnumEntryImpl.addDeclaration(declaration: FirDeclaration) { val FirTypeAlias.expandedConeType: ConeClassLikeType? get() = expandedTypeRef.coneTypeSafe() -val FirRegularClass.classId get() = symbol.classId +val FirClass<*>.classId get() = symbol.classId val FirClassSymbol<*>.superConeTypes get() = when (this) { diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt index 79e9a09245e..5ea542af9fc 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt @@ -17,7 +17,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:test1 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Any visibility:private [final,static] + FIELD PROPERTY_BACKING_FIELD name:test1 type:. visibility:private [final,static] EXPRESSION_BODY BLOCK type=.test1. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] @@ -27,13 +27,13 @@ FILE fqName: fileName:/objectLiteralExpressions.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test1.' type=.test1. origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Any + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:. correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Any visibility:private [final,static]' type=kotlin.Any origin=null + RETURN type=kotlin.Nothing from='public final fun (): . declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:. visibility:private [final,static]' type=. origin=null PROPERTY name:test2 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test2 type:.IFoo visibility:private [final,static] + FIELD PROPERTY_BACKING_FIELD name:test2 type:. visibility:private [final,static] EXPRESSION_BODY BLOCK type=.test2. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.IFoo] @@ -48,11 +48,11 @@ FILE fqName: fileName:/objectLiteralExpressions.kt CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test2.' type=.test2. origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.IFoo + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:. correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .IFoo declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:.IFoo visibility:private [final,static]' type=.IFoo origin=null + RETURN type=kotlin.Nothing from='public final fun (): . declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:. visibility:private [final,static]' type=. origin=null CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer CONSTRUCTOR visibility:public <> () returnType:.Outer [primary] @@ -82,10 +82,10 @@ FILE fqName: fileName:/objectLiteralExpressions.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test3 visibility:public modality:FINAL <> ($this:.Outer) returnType:.Outer.Inner + FUN name:test3 visibility:public modality:FINAL <> ($this:.Outer) returnType:. $this: VALUE_PARAMETER name: type:.Outer BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test3 (): .Outer.Inner declared in .Outer' + RETURN type=kotlin.Nothing from='public final fun test3 (): . declared in .Outer' BLOCK type=.Outer.test3. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer.test3. @@ -112,10 +112,10 @@ FILE fqName: fileName:/objectLiteralExpressions.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test4 visibility:public modality:FINAL <> ($receiver:.Outer) returnType:.Outer.Inner + FUN name:test4 visibility:public modality:FINAL <> ($receiver:.Outer) returnType:. $receiver: VALUE_PARAMETER name: type:.Outer BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test4 (): .Outer.Inner declared in ' + RETURN type=kotlin.Nothing from='public final fun test4 (): . declared in ' BLOCK type=.test4. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test4. diff --git a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt index 36b0382c634..21992994b7c 100644 --- a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt @@ -48,10 +48,10 @@ FILE fqName: fileName:/classLiteralInAnnotation.kt $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL () returnType:kotlin.Any [inline] + FUN name:test2 visibility:public modality:FINAL () returnType:. [inline] TYPE_PARAMETER name:T index:0 variance: superTypes:[] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Any [inline] declared in ' + RETURN type=kotlin.Nothing from='public final fun test2 (): . [inline] declared in ' BLOCK type=.test2. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] annotations: @@ -63,10 +63,10 @@ FILE fqName: fileName:/classLiteralInAnnotation.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test2.' type=.test2. origin=null PROPERTY name:test3 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Any + FUN name: visibility:public modality:FINAL <> () returnType:. correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' + RETURN type=kotlin.Nothing from='public final fun (): . declared in ' BLOCK type=.. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] annotations: @@ -77,9 +77,9 @@ FILE fqName: fileName:/classLiteralInAnnotation.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in ..' type=.. origin=null - FUN name: visibility:public modality:FINAL <> (v:kotlin.Any) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (v:.) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:v index:0 type:kotlin.Any + VALUE_PARAMETER name:v index:0 type:. BLOCK_BODY BLOCK type=.. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] diff --git a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt index 478c72a3cb6..125e1c1d6a0 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt @@ -62,7 +62,7 @@ FILE fqName: fileName:/enumEntryReferenceFromEnumEntryClass.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aLambda type:kotlin.Function0 visibility:private [final]' type=kotlin.Function0 origin=null receiver: GET_VAR ': .MyEnum.Z declared in .MyEnum.Z.' type=.MyEnum.Z origin=null PROPERTY name:anObject visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:anObject type:. visibility:private [final] EXPRESSION_BODY BLOCK type=.MyEnum.Z.anObject. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] @@ -87,12 +87,12 @@ FILE fqName: fileName:/enumEntryReferenceFromEnumEntryClass.kt CALL 'public final fun foo (): kotlin.Unit declared in .MyEnum.Z' type=kotlin.Unit origin=null $this: GET_VAR ': .MyEnum.Z declared in .MyEnum.Z' type=.MyEnum.Z origin=null CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum.Z.anObject.' type=.MyEnum.Z.anObject. origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyEnum.Z) returnType:kotlin.Any + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyEnum.Z) returnType:. correspondingProperty: PROPERTY name:anObject visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.MyEnum.Z BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .MyEnum.Z' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + RETURN type=kotlin.Nothing from='public final fun (): . declared in .MyEnum.Z' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:. visibility:private [final]' type=. origin=null receiver: GET_VAR ': .MyEnum.Z declared in .MyEnum.Z.' type=.MyEnum.Z origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: diff --git a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt index b40b6186688..e5857302ec7 100644 --- a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt @@ -67,31 +67,32 @@ FILE fqName: fileName:/multipleThisReferences.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null - FUN name:test visibility:public modality:FINAL <> ($this:.Host, $receiver:.Outer) returnType:.Outer.Inner + FUN name:test visibility:public modality:FINAL <> ($this:.Host, $receiver:.Outer) returnType:. $this: VALUE_PARAMETER name: type:.Host $receiver: VALUE_PARAMETER name: type:.Outer BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (): .Outer.Inner declared in .Host' + RETURN type=kotlin.Nothing from='public final fun test (): . declared in .Host' BLOCK type=.Host.test. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host.test. CONSTRUCTOR visibility:private <> () returnType:.Outer.Inner [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int) [primary] declared in .Outer.Inner' - x: CONST Int type=.Outer.Inner value=42 + x: CONST Int type=. value=42 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner]' PROPERTY name:xx visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.String visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final] EXPRESSION_BODY - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin' type=kotlin.String origin=null - $receiver: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Outer.Inner' type=kotlin.Int origin=null + $this: GET_VAR ': .Outer.Inner declared in .Outer.Inner' type=.Outer.Inner origin=null other: GET_VAR 'y: kotlin.Int declared in .Host.' type=kotlin.Int origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host.test.) returnType:kotlin.String + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host.test.) returnType:kotlin.Int correspondingProperty: PROPERTY name:xx visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host.test. BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Host.test.' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host.test.' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .Host.test. declared in .Host.test..' type=.Host.test. origin=null CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Host.test.' type=.Host.test. origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean diff --git a/compiler/testData/ir/irText/expressions/objectReference.fir.txt b/compiler/testData/ir/irText/expressions/objectReference.fir.txt index 3f3200a0f90..f4a62e4afa6 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.txt @@ -109,7 +109,7 @@ FILE fqName: fileName:/objectReference.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aLambda type:kotlin.Function0 visibility:private [final]' type=kotlin.Function0 origin=null receiver: GET_VAR ': .Z declared in .Z.' type=.Z origin=null PROPERTY name:anObject visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:anObject type:. visibility:private [final] EXPRESSION_BODY BLOCK type=.Z.anObject. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] @@ -144,12 +144,12 @@ FILE fqName: fileName:/objectReference.kt CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Z.anObject.' type=.Z.anObject. origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:kotlin.Any + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:. correspondingProperty: PROPERTY name:anObject visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Z BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .Z' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + RETURN type=kotlin.Nothing from='public final fun (): . declared in .Z' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:. visibility:private [final]' type=. origin=null receiver: GET_VAR ': .Z declared in .Z.' type=.Z origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: diff --git a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt index 1c124187ede..824126b48ae 100644 --- a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt @@ -62,28 +62,31 @@ FILE fqName: fileName:/thisOfGenericOuterClass.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> ($receiver:.Outer) returnType:.Outer.Inner + FUN name:test visibility:public modality:FINAL <> ($receiver:.Outer) returnType:. $receiver: VALUE_PARAMETER name: type:.Outer BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (): .Outer.Inner declared in ' + RETURN type=kotlin.Nothing from='public final fun test (): . declared in ' BLOCK type=.test. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. CONSTRUCTOR visibility:private <> () returnType:.Outer.Inner [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (y: kotlin.Int) [primary] declared in .Outer.Inner' - y: CONST Int type=.Outer.Inner value=42 + y: CONST Int type=. value=42 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.Outer.Inner]' PROPERTY name:xx visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xx type:IrErrorType visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.test.) returnType:IrErrorType + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Outer' type=kotlin.Int origin=null + $this: GET_VAR ': .Outer declared in .Outer' type=.Outer<*> origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Outer.Inner' type=kotlin.Int origin=null + $this: GET_VAR ': .Outer.Inner declared in .Outer.Inner' type=.Outer.Inner origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.test.) returnType:kotlin.Int correspondingProperty: PROPERTY name:xx visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.test. BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .test.' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xx type:IrErrorType visibility:private [final]' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .test.' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .test. declared in .test..' type=.test. origin=null CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=null diff --git a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt index 51d4fdf7a29..b521c224074 100644 --- a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt @@ -2,17 +2,17 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt FUN name:test visibility:public modality:FINAL <> ($receiver:.WithCompanion) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.WithCompanion BLOCK_BODY - VAR name:test1 type:.WithCompanion [val] + VAR name:test1 type:. [val] BLOCK type=.test. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.WithCompanion] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. CONSTRUCTOR visibility:private <> () returnType:.WithCompanion [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (a: .WithCompanion.Companion) [primary] declared in .WithCompanion' - a: GET_VAR ': .WithCompanion declared in .test' type=.WithCompanion origin=null + a: GET_VAR ': . declared in .' type=. origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.WithCompanion]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=null - VAR name:test2 type:.WithCompanion [val] + VAR name:test2 type:. [val] BLOCK type=.test. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.WithCompanion] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test.