[FIR IDE] Code review minor changes
This commit is contained in:
+2
-1
@@ -10,5 +10,6 @@ import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirPhaseManager
|
||||
|
||||
object FirPhaseCheckingPhaseManager : FirPhaseManager() {
|
||||
override fun ensureResolved(symbol: FirBasedSymbol<*>, requiredPhase: FirResolvePhase) = Unit
|
||||
override fun ensureResolved(symbol: FirBasedSymbol<*>, requiredPhase: FirResolvePhase) {
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -71,7 +71,6 @@ class FirStatusResolver(
|
||||
val scope = containingClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false)
|
||||
scope.processPropertiesByName(property.name) {}
|
||||
scope.processDirectOverriddenPropertiesWithBaseScope(property.symbol) { symbol, _ ->
|
||||
symbol.ensureResolved(FirResolvePhase.STATUS)
|
||||
this += symbol.fir
|
||||
ProcessorAction.NEXT
|
||||
}
|
||||
|
||||
+7
-7
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirDesignatedB
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyResolveComputationSession
|
||||
import org.jetbrains.kotlin.fir.symbols.ensureResolved
|
||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignation
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyBodiesCalculator
|
||||
|
||||
@@ -29,9 +30,7 @@ fun FirIdeDesignatedImpliciteTypesBodyResolveTransformerForReturnTypeCalculator(
|
||||
): FirDesignatedBodyResolveTransformerForReturnTypeCalculator {
|
||||
|
||||
val designationList = mutableListOf<FirElement>()
|
||||
for (element in designation) {
|
||||
designationList.add(element)
|
||||
}
|
||||
designation.forEachRemaining(designationList::add)
|
||||
require(designationList.isNotEmpty()) { "Designation should not be empty" }
|
||||
|
||||
return FirIdeDesignatedBodyResolveTransformerForReturnTypeCalculatorImpl(
|
||||
@@ -64,10 +63,11 @@ private class FirIdeDesignatedBodyResolveTransformerForReturnTypeCalculatorImpl(
|
||||
private inline fun <D : FirCallableDeclaration> D.processCallable(body: (FirDeclarationDesignation) -> Unit) {
|
||||
if (this !== targetDeclaration) return
|
||||
ensureResolved(FirResolvePhase.TYPES)
|
||||
if (returnTypeRef !is FirImplicitTypeRef) return
|
||||
val declarationList = designation.filterIsInstance<FirDeclaration>()
|
||||
check(declarationList.isNotEmpty()) { "Invalid empty declaration designation" }
|
||||
body(FirDeclarationDesignation(declarationList.dropLast(1), this))
|
||||
if (returnTypeRef is FirImplicitTypeRef) {
|
||||
val declarationList = designation.filterIsInstance<FirDeclaration>()
|
||||
check(declarationList.isNotEmpty()) { "Invalid empty declaration designation" }
|
||||
body(FirDeclarationDesignation(declarationList.dropLast(1), this))
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformSimpleFunction(
|
||||
|
||||
+7
-8
@@ -27,9 +27,7 @@ fun FirIdeEnsureBasedTransformerForReturnTypeCalculator(
|
||||
): FirDesignatedBodyResolveTransformerForReturnTypeCalculator {
|
||||
|
||||
val designationList = mutableListOf<FirElement>()
|
||||
for (element in designation) {
|
||||
designationList.add(element)
|
||||
}
|
||||
designation.forEachRemaining(designationList::add)
|
||||
require(designationList.isNotEmpty()) { "Designation should not be empty" }
|
||||
|
||||
return FirIdeEnsureBasedTransformerForReturnTypeCalculatorImpl(
|
||||
@@ -60,21 +58,22 @@ private class FirIdeEnsureBasedTransformerForReturnTypeCalculatorImpl(
|
||||
) {
|
||||
private val targetDeclaration = designation.last()
|
||||
|
||||
private fun <T : FirCallableDeclaration> T.ensuredReturnType() {
|
||||
private fun <T : FirCallableDeclaration> T.ensureReturnType() {
|
||||
if (this !== targetDeclaration) return
|
||||
ensureResolved(FirResolvePhase.TYPES)
|
||||
if (returnTypeRef !is FirImplicitTypeRef) return
|
||||
ensureResolved(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||
if (returnTypeRef is FirImplicitTypeRef) {
|
||||
ensureResolved(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: ResolutionMode): FirSimpleFunction {
|
||||
simpleFunction.ensuredReturnType()
|
||||
simpleFunction.ensureReturnType()
|
||||
return super.transformSimpleFunction(simpleFunction, data)
|
||||
}
|
||||
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: ResolutionMode): FirProperty {
|
||||
property.ensuredReturnType()
|
||||
property.ensureReturnType()
|
||||
return super.transformProperty(property, data)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -93,6 +93,7 @@ internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBui
|
||||
is FirDeclarationOrigin.Delegated,
|
||||
is FirDeclarationOrigin.Synthetic,
|
||||
is FirDeclarationOrigin.SubstitutionOverride,
|
||||
is FirDeclarationOrigin.SamConstructor,
|
||||
is FirDeclarationOrigin.IntersectionOverride -> {
|
||||
when (this) {
|
||||
is FirFile -> true
|
||||
|
||||
-37
@@ -64,43 +64,6 @@ internal interface FirLazyTransformerForIDE {
|
||||
internal var enableDeepEnsure: Boolean = false
|
||||
@TestOnly set
|
||||
|
||||
// private object ResolvePhaseWithForAllDeclarationsKey : FirDeclarationDataKey()
|
||||
|
||||
// private var FirDeclaration.resolvePhaseForDeclarationAndChildrenAttr: FirResolvePhase?
|
||||
// by FirDeclarationDataRegistry.data(ResolvePhaseWithForAllDeclarationsKey)
|
||||
//
|
||||
// /**
|
||||
// * This resolve phase is used to check if current declaration and it's children were resolved for phase
|
||||
// */
|
||||
// var FirDeclaration.resolvePhaseForDeclarationAndChildren: FirResolvePhase
|
||||
// get() = resolvePhaseForDeclarationAndChildrenAttr ?: FirResolvePhase.RAW_FIR
|
||||
// set(value) {
|
||||
// resolvePhaseForDeclarationAndChildrenAttr = value
|
||||
// }
|
||||
//
|
||||
// fun FirDeclaration.updateResolvedPhaseForDeclarationAndChildren(phase: FirResolvePhase) {
|
||||
// val allDeclaration = resolvePhaseForDeclarationAndChildren
|
||||
// if (allDeclaration < phase) {
|
||||
// resolvePhaseForDeclarationAndChildren = phase
|
||||
// }
|
||||
// }
|
||||
|
||||
// fun FirDeclarationDesignation.resolvePhaseForAllDeclarations(includeDeclarationPhase: Boolean): FirResolvePhase {
|
||||
// //resolvePhaseWithForAllDeclarations for these origins are derived from original declaration
|
||||
// val includeTarget = when (declaration.origin) {
|
||||
// is FirDeclarationOrigin.SubstitutionOverride,
|
||||
// is FirDeclarationOrigin.IntersectionOverride,
|
||||
// is FirDeclarationOrigin.Delegated -> false
|
||||
// else -> true
|
||||
// }
|
||||
//
|
||||
// val allContaining = toSequence(includeTarget = includeTarget)
|
||||
// .maxByOrNull { it.resolvePhase }
|
||||
// ?.resolvePhase
|
||||
// ?: FirResolvePhase.RAW_FIR
|
||||
// return if (includeDeclarationPhase) minOf(declaration.resolvePhase, allContaining) else allContaining
|
||||
// }
|
||||
|
||||
val DUMMY = object : FirLazyTransformerForIDE {
|
||||
override fun transformDeclaration(phaseRunner: FirPhaseRunner) = Unit
|
||||
override fun ensureResolved(declaration: FirDeclaration) = error("Not implemented")
|
||||
|
||||
+20
-20
@@ -363,8 +363,8 @@ FILE: delegates.kt
|
||||
[STATUS] public get(): <implicit> {
|
||||
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate#
|
||||
@@ -374,11 +374,11 @@ FILE: delegates.kt
|
||||
[STATUS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
|
||||
D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/variableWithImplicitType|)
|
||||
}
|
||||
[STATUS] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
|
||||
}
|
||||
|
||||
@@ -459,8 +459,8 @@ FILE: delegates.kt
|
||||
[STATUS] public get(): <implicit> {
|
||||
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate#
|
||||
@@ -470,11 +470,11 @@ FILE: delegates.kt
|
||||
[STATUS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
|
||||
D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/variableWithImplicitType|)
|
||||
}
|
||||
[STATUS] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
|
||||
}
|
||||
|
||||
@@ -507,8 +507,8 @@ FILE: delegates.kt
|
||||
[STATUS] public get(): <implicit> {
|
||||
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate#
|
||||
@@ -518,11 +518,11 @@ FILE: delegates.kt
|
||||
[STATUS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
|
||||
D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/variableWithImplicitType|)
|
||||
}
|
||||
[STATUS] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
|
||||
}
|
||||
|
||||
@@ -651,8 +651,8 @@ FILE: delegates.kt
|
||||
[STATUS] public get(): <implicit> {
|
||||
^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] val valueWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/valueWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/valueWithImplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithExplicitType: R|kotlin/Int|by delegate#
|
||||
@@ -662,11 +662,11 @@ FILE: delegates.kt
|
||||
[STATUS] public set([RAW_FIR] <set-?>: <implicit>): R|kotlin/Unit| {
|
||||
D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|<local>/variableWithExplicitType|)
|
||||
}
|
||||
public final [STATUS] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[STATUS] public get(): R|kotlin/Int| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] var variableWithImplicitType: R|kotlin/Int|by R|/delegate|
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public get(): R|kotlin/Int| {
|
||||
^ D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|kotlin/Int|>|(Null(null), ::R|/variableWithImplicitType|)
|
||||
}
|
||||
[STATUS] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
[IMPLICIT_TYPES_BODY_RESOLVE] public set([RAW_FIR] <set-?>: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
D|/variableWithImplicitType|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(Null(null), ::R|/variableWithImplicitType|, R|<local>/variableWithImplicitType|)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -82,7 +82,7 @@ FILE: topLevelFunctionsWithImplicitType.kt
|
||||
}
|
||||
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
^functionWithLazyBody String(42)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ FILE: topLevelFunctionsWithImplicitType.kt
|
||||
}
|
||||
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
^functionWithLazyBody String(42)
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ FILE: topLevelFunctionsWithImplicitType.kt
|
||||
}
|
||||
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
^functionWithLazyBody String(42)
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ FILE: topLevelFunctionsWithImplicitType.kt
|
||||
}
|
||||
public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun functionWithLazyBody(): R|kotlin/String| {
|
||||
^functionWithLazyBody String(42)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user