FIR: Mark all dependencies' declarations as fully resolved

This commit is contained in:
Denis Zharkov
2020-01-28 13:18:23 +03:00
parent dd51d5065a
commit c6c773f6f9
10 changed files with 27 additions and 25 deletions
@@ -54,7 +54,7 @@ class FirJavaClass internal constructor(
status.isInline = false status.isInline = false
} }
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
override val superTypeRefs = mutableListOf<FirTypeRef>() override val superTypeRefs = mutableListOf<FirTypeRef>()
@@ -49,7 +49,7 @@ class FirJavaConstructor(
this.isInner = isInner this.isInner = isInner
} }
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
init { init {
symbol.bind(this) symbol.bind(this)
@@ -116,4 +116,4 @@ class FirJavaConstructor(
override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) { override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) {
returnTypeRef = newReturnTypeRef returnTypeRef = newReturnTypeRef
} }
} }
@@ -46,7 +46,7 @@ class FirJavaField(
isOverride = false isOverride = false
} }
override val receiverTypeRef: FirTypeRef? get() = null override val receiverTypeRef: FirTypeRef? get() = null
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
override val isVal: Boolean = true override val isVal: Boolean = true
override val getter: FirPropertyAccessor? get() = null override val getter: FirPropertyAccessor? get() = null
override val setter: FirPropertyAccessor? get() = null override val setter: FirPropertyAccessor? get() = null
@@ -115,4 +115,4 @@ class FirJavaField(
override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirField { override fun <D> transformInitializer(transformer: FirTransformer<D>, data: D): FirField {
return this return this
} }
} }
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
class FirJavaMethod( class FirJavaMethod(
@@ -46,6 +46,6 @@ class FirJavaMethod(
symbol symbol
) { ) {
init { init {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
} }
} }
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
class FirJavaValueParameter( class FirJavaValueParameter(
@@ -31,6 +31,6 @@ class FirJavaValueParameter(
isVararg = isVararg isVararg = isVararg
) { ) {
init { init {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
} }
} }
@@ -181,7 +181,7 @@ class JavaClassEnhancementScope(
FirVariableSymbol(this.name), FirVariableSymbol(this.name),
defaultValue ?: newDefaultValue, isCrossinline, isNoinline, isVararg defaultValue ?: newDefaultValue, isCrossinline, isNoinline, isVararg
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
annotations += valueParameter.annotations annotations += valueParameter.annotations
} }
} }
@@ -213,7 +213,7 @@ class JavaClassEnhancementScope(
symbol symbol
) )
}.apply { }.apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
this.valueParameters += newValueParameters this.valueParameters += newValueParameters
this.typeParameters += firMethod.typeParameters this.typeParameters += firMethod.typeParameters
} }
@@ -228,7 +228,7 @@ class JavaClassEnhancementScope(
if (!isAccessor) FirNamedFunctionSymbol(methodId) if (!isAccessor) FirNamedFunctionSymbol(methodId)
else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId) else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId)
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
this.valueParameters += newValueParameters this.valueParameters += newValueParameters
this.typeParameters += firMethod.typeParameters this.typeParameters += firMethod.typeParameters
} }
@@ -383,4 +383,4 @@ class JavaClassEnhancementScope(
) )
} }
} }
@@ -17,7 +17,8 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl import org.jetbrains.kotlin.fir.declarations.impl.FirSealedClassImpl
import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider
import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.ProtoBuf
@@ -78,7 +79,7 @@ fun deserializeClassToSymbol(
) )
} }
firClass.apply { firClass.apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
val context = val context =
parentContext?.childContext( parentContext?.childContext(
classProto.typeParameterList, classProto.typeParameterList,
@@ -136,7 +137,7 @@ fun deserializeClassToSymbol(
isStatic = true isStatic = true
} }
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
} }
property property
@@ -146,7 +146,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
local.typeDeserializer.type(proto.underlyingType(c.typeTable)) local.typeDeserializer.type(proto.underlyingType(c.typeTable))
) )
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
} }
} }
@@ -184,7 +184,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
false, false,
status status
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver) annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver)
getter = FirDefaultPropertyGetter(null, c.session, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))) getter = FirDefaultPropertyGetter(null, c.session, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags)))
@@ -234,7 +234,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
status, status,
symbol symbol
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList) valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList)
annotations += local.annotationDeserializer.loadFunctionAnnotations(proto, local.nameResolver) annotations += local.annotationDeserializer.loadFunctionAnnotations(proto, local.nameResolver)
@@ -290,7 +290,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
symbol symbol
) )
}.apply { }.apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
this.typeParameters += typeParameters this.typeParameters += typeParameters
valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList) valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList)
annotations += local.annotationDeserializer.loadConstructorAnnotations(proto, local.nameResolver) annotations += local.annotationDeserializer.loadConstructorAnnotations(proto, local.nameResolver)
@@ -166,7 +166,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider:
kotlinScopeProvider, kotlinScopeProvider,
this this
).apply klass@{ ).apply klass@{
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
typeParameters.addAll((1..arity).map { typeParameters.addAll((1..arity).map {
FirTypeParameterImpl( FirTypeParameterImpl(
null, null,
@@ -222,7 +222,7 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider:
functionStatus, functionStatus,
FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name)) FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name))
).apply { ).apply {
resolvePhase = FirResolvePhase.DECLARATIONS resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
valueParameters += typeArguments.dropLast(1).mapIndexed { index, typeArgument -> valueParameters += typeArguments.dropLast(1).mapIndexed { index, typeArgument ->
val parameterName = Name.identifier("p${index + 1}") val parameterName = Name.identifier("p${index + 1}")
FirValueParameterImpl( FirValueParameterImpl(
@@ -22,5 +22,6 @@ enum class FirResolvePhase {
companion object { companion object {
// Short-cut // Short-cut
val DECLARATIONS = STATUS val DECLARATIONS = STATUS
val ANALYZED_DEPENDENCIES = BODY_RESOLVE
} }
} }