[K2] Resolve bodies of const properties during IMPLICIT_TYPES_BODY_RESOLVE
This is required to implement constant evaluator on the FIR level. #KT-64151
This commit is contained in:
+7
-1
@@ -8,9 +8,11 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.transformers
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.LLFirResolveTarget
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.throwUnexpectedFirElementError
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.LLFirDeclarationModificationService
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.checkInitializerIsResolved
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.checkReturnTypeRefIsResolved
|
||||
import org.jetbrains.kotlin.fir.FirElementWithResolveState
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isConst
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.isCopyCreatedInScope
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer
|
||||
@@ -30,6 +32,10 @@ internal object LLFirImplicitTypesLazyResolver : LLFirLazyResolver(FirResolvePha
|
||||
override fun phaseSpecificCheckIsResolved(target: FirElementWithResolveState) {
|
||||
if (target !is FirCallableDeclaration) return
|
||||
checkReturnTypeRefIsResolved(target)
|
||||
|
||||
if (target is FirProperty && target.isConst) {
|
||||
checkInitializerIsResolved(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +186,7 @@ internal class LLFirImplicitBodyTargetResolver(
|
||||
}
|
||||
|
||||
target is FirProperty -> {
|
||||
if (target.returnTypeRef is FirImplicitTypeRef || target.backingField?.returnTypeRef is FirImplicitTypeRef) {
|
||||
if (target.isConst || target.returnTypeRef is FirImplicitTypeRef || target.backingField?.returnTypeRef is FirImplicitTypeRef) {
|
||||
resolve(target, BodyStateKeepers.PROPERTY)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+9
-9
@@ -81,28 +81,28 @@ FILE: [ResolvedTo(IMPORTS)] constCyclePropertyWithExplicitType.kt
|
||||
|
||||
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] constCyclePropertyWithExplicitType.kt
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val withCycle1: R|kotlin/Int| = IntegerLiteral(1).plus#(withCycle2#)
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val withCycle1: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(R|/withCycle2|)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle2: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public final const [ResolvedTo(CONTRACTS)] val withCycle2: R|kotlin/Int| = IntegerLiteral(2).plus#(withCycle3#)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle3: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
|
||||
CONSTANT_EVALUATION:
|
||||
FILE: [ResolvedTo(IMPORTS)] constCyclePropertyWithExplicitType.kt
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val withCycle1: R|kotlin/Int| = IntegerLiteral(1).plus#(withCycle2#)
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val withCycle1: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(R|/withCycle2|)
|
||||
public [ResolvedTo(CONSTANT_EVALUATION)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle2: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public final const [ResolvedTo(CONTRACTS)] val withCycle2: R|kotlin/Int| = IntegerLiteral(2).plus#(withCycle3#)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle3: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
|
||||
ANNOTATION_ARGUMENTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] constCyclePropertyWithExplicitType.kt
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val withCycle1: R|kotlin/Int| = IntegerLiteral(1).plus#(withCycle2#)
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val withCycle1: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(R|/withCycle2|)
|
||||
public [ResolvedTo(ANNOTATION_ARGUMENTS)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle2: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public final const [ResolvedTo(CONTRACTS)] val withCycle2: R|kotlin/Int| = IntegerLiteral(2).plus#(withCycle3#)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val withCycle3: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
|
||||
|
||||
Vendored
+12
-6
@@ -54,20 +54,26 @@ FILE: [ResolvedTo(IMPORTS)] constErrorPropertyWithExplicitType.kt
|
||||
|
||||
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] constErrorPropertyWithExplicitType.kt
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun foo(): Int { LAZY_BLOCK }
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val nonConstantInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(foo#())
|
||||
public final [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Int| {
|
||||
^foo IntegerLiteral(0)
|
||||
}
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val nonConstantInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/foo|())
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
|
||||
CONSTANT_EVALUATION:
|
||||
FILE: [ResolvedTo(IMPORTS)] constErrorPropertyWithExplicitType.kt
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun foo(): Int { LAZY_BLOCK }
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val nonConstantInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(foo#())
|
||||
public final [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Int| {
|
||||
^foo IntegerLiteral(0)
|
||||
}
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val nonConstantInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/foo|())
|
||||
public [ResolvedTo(CONSTANT_EVALUATION)] get(): R|kotlin/Int|
|
||||
|
||||
ANNOTATION_ARGUMENTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] constErrorPropertyWithExplicitType.kt
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun foo(): Int { LAZY_BLOCK }
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val nonConstantInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(foo#())
|
||||
public final [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Int| {
|
||||
^foo IntegerLiteral(0)
|
||||
}
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val nonConstantInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/foo|())
|
||||
public [ResolvedTo(ANNOTATION_ARGUMENTS)] get(): R|kotlin/Int|
|
||||
|
||||
BODY_RESOLVE:
|
||||
|
||||
Vendored
+3
-3
@@ -54,19 +54,19 @@ FILE: [ResolvedTo(IMPORTS)] constPropertiesWithExplicitType.kt
|
||||
|
||||
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertiesWithExplicitType.kt
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] var simple: R|kotlin/Int| = Int(24)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] set([ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
CONSTANT_EVALUATION:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertiesWithExplicitType.kt
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] var simple: R|kotlin/Int| = Int(24)
|
||||
public [ResolvedTo(CONSTANT_EVALUATION)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(CONSTANT_EVALUATION)] set([ResolvedTo(CONSTANT_EVALUATION)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
ANNOTATION_ARGUMENTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertiesWithExplicitType.kt
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] var simple: R|kotlin/Int| = Int(24)
|
||||
public [ResolvedTo(ANNOTATION_ARGUMENTS)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(ANNOTATION_ARGUMENTS)] set([ResolvedTo(ANNOTATION_ARGUMENTS)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
|
||||
+12
-12
@@ -72,26 +72,26 @@ FILE: [ResolvedTo(IMPORTS)] constPropertyWithExplicitTypeAndInitializer.kt
|
||||
|
||||
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertyWithExplicitTypeAndInitializer.kt
|
||||
public? final? const [ResolvedTo(RAW_FIR)] var simple: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public? [ResolvedTo(RAW_FIR)] set([ResolvedTo(RAW_FIR)] value: Int): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val withConstInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(simple#)
|
||||
public final const [ResolvedTo(CONTRACTS)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(CONTRACTS)] set([ResolvedTo(CONTRACTS)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val withConstInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/simple|)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
|
||||
CONSTANT_EVALUATION:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertyWithExplicitTypeAndInitializer.kt
|
||||
public? final? const [ResolvedTo(RAW_FIR)] var simple: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public? [ResolvedTo(RAW_FIR)] set([ResolvedTo(RAW_FIR)] value: Int): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val withConstInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(simple#)
|
||||
public final const [ResolvedTo(CONTRACTS)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(CONTRACTS)] set([ResolvedTo(CONTRACTS)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(CONSTANT_EVALUATION)] val withConstInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/simple|)
|
||||
public [ResolvedTo(CONSTANT_EVALUATION)] get(): R|kotlin/Int|
|
||||
|
||||
ANNOTATION_ARGUMENTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] constPropertyWithExplicitTypeAndInitializer.kt
|
||||
public? final? const [ResolvedTo(RAW_FIR)] var simple: Int = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): Int
|
||||
public? [ResolvedTo(RAW_FIR)] set([ResolvedTo(RAW_FIR)] value: Int): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val withConstInitializer: R|kotlin/Int| = IntegerLiteral(1).plus#(IntegerLiteral(5)).plus#(simple#)
|
||||
public final const [ResolvedTo(CONTRACTS)] var simple: R|kotlin/Int| = IntegerLiteral(24)
|
||||
public [ResolvedTo(CONTRACTS)] get(): R|kotlin/Int|
|
||||
public [ResolvedTo(CONTRACTS)] set([ResolvedTo(CONTRACTS)] value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
public final const [ResolvedTo(ANNOTATION_ARGUMENTS)] val withConstInitializer: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(5)).R|kotlin/Int.plus|(R|/simple|)
|
||||
public [ResolvedTo(ANNOTATION_ARGUMENTS)] get(): R|kotlin/Int|
|
||||
|
||||
BODY_RESOLVE:
|
||||
|
||||
Reference in New Issue
Block a user