From 43fe0c3bc17e7e15578653d09e32dac21d119842 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 2 Jul 2021 12:54:47 +0300 Subject: [PATCH] [FIR] Don't initialize type of FirAnonymousObjectExpression In some cases we check that some declaration (e.g. field) was analyzed by checking type of it's body/initializer (is it implicit or not), so if type of FirAnonymousObjectExpression is not implicit we can skip resolve of anonymous object itself --- .../kotlin/fir/lightTree/converter/DeclarationsConverter.kt | 1 - .../src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 46f20ad6700..5dee3ec8c70 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -595,7 +595,6 @@ class DeclarationsConverter( annotations += modifiers.annotations this.superTypeRefs += superTypeRefs - this@buildAnonymousObjectExpression.typeRef = delegatedSelfType val classWrapper = ClassWrapper( SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this, diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 6fee4de4bd1..0433f3d537b 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -982,7 +982,8 @@ open class RawFirBuilder( scopeProvider = baseScopeProvider symbol = FirAnonymousObjectSymbol() context.applyToActualCapturedTypeParameters(false) { - typeParameters += buildOuterClassTypeParameterRef { symbol = it } } + typeParameters += buildOuterClassTypeParameterRef { symbol = it } + } val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this) registerSelfType(delegatedSelfType) objectDeclaration.extractAnnotationsTo(this) @@ -993,7 +994,6 @@ open class RawFirBuilder( ClassKind.CLASS, containerTypeParameters = emptyList() ) - this@buildAnonymousObjectExpression.typeRef = delegatedSelfType for (declaration in objectDeclaration.declarations) { declarations += declaration.toFirDeclaration(