Specify type arguments to fix compilation against bootstrap compiler
This commit is contained in:
@@ -762,7 +762,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun typeParametersFromSelfType(delegatedSelfTypeRef: FirTypeRef): List<FirTypeParameter> {
|
private fun typeParametersFromSelfType(delegatedSelfTypeRef: FirTypeRef): List<FirTypeParameter> {
|
||||||
return delegatedSelfTypeRef.coneTypeSafe()
|
return delegatedSelfTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||||
?.typeArguments
|
?.typeArguments
|
||||||
?.map { ((it as ConeTypeParameterType).lookupTag as FirTypeParameterSymbol).fir }
|
?.map { ((it as ConeTypeParameterType).lookupTag as FirTypeParameterSymbol).fir }
|
||||||
?: emptyList()
|
?: emptyList()
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession)
|
|||||||
// TODO: support LibraryTypeParameterSymbol or get rid of it
|
// TODO: support LibraryTypeParameterSymbol or get rid of it
|
||||||
val toSymbol = this.lookupTag.toSymbol(useSiteSession)?.takeIf { it is FirBasedSymbol<*> } ?: return null
|
val toSymbol = this.lookupTag.toSymbol(useSiteSession)?.takeIf { it is FirBasedSymbol<*> } ?: return null
|
||||||
val fir = toSymbol.firUnsafe<FirTypeParameter>()
|
val fir = toSymbol.firUnsafe<FirTypeParameter>()
|
||||||
FirCompositeScope(fir.bounds.mapNotNullTo(mutableListOf()) { it.coneTypeUnsafe().scope(useSiteSession, scopeSession) })
|
FirCompositeScope(
|
||||||
|
fir.bounds.mapNotNullTo(mutableListOf()) {
|
||||||
|
it.coneTypeUnsafe<ConeKotlinType>().scope(useSiteSession, scopeSession)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
is ConeFlexibleType -> lowerBound.scope(useSiteSession, scopeSession)
|
is ConeFlexibleType -> lowerBound.scope(useSiteSession, scopeSession)
|
||||||
else -> error("Failed type ${this}")
|
else -> error("Failed type ${this}")
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ inline fun <reified T : FirScope> scopeSessionKey(): ScopeSessionKey<T> {
|
|||||||
return object : ScopeSessionKey<T>() {}
|
return object : ScopeSessionKey<T>() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
val USE_SITE = scopeSessionKey()
|
val USE_SITE = scopeSessionKey<FirScope>()
|
||||||
val DECLARED = scopeSessionKey()
|
val DECLARED = scopeSessionKey<FirScope>()
|
||||||
|
|
||||||
data class SubstitutionScopeKey<T : FirClassSubstitutionScope>(val type: ConeClassLikeType) : ScopeSessionKey<T>() {}
|
data class SubstitutionScopeKey<T : FirClassSubstitutionScope>(val type: ConeClassLikeType) : ScopeSessionKey<T>() {}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ internal fun FirExpression.getExpectedType(
|
|||||||
// parameter.type.unwrap()
|
// parameter.type.unwrap()
|
||||||
// } else {
|
// } else {
|
||||||
if (parameter.isVararg) {
|
if (parameter.isVararg) {
|
||||||
parameter.returnTypeRef.coneTypeUnsafe().varargElementType(session)
|
parameter.returnTypeRef.coneTypeUnsafe<ConeKotlinType>().varargElementType(session)
|
||||||
} else {
|
} else {
|
||||||
parameter.returnTypeRef.coneTypeUnsafe()
|
parameter.returnTypeRef.coneTypeUnsafe()
|
||||||
}//?.varargElementType?.unwrap() ?: parameter.type.unwrap()
|
}//?.varargElementType?.unwrap() ?: parameter.type.unwrap()
|
||||||
|
|||||||
+4
-4
@@ -150,7 +150,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
|||||||
resolved.resultType =
|
resolved.resultType =
|
||||||
resolved.conversionTypeRef.withReplacedConeType(
|
resolved.conversionTypeRef.withReplacedConeType(
|
||||||
session,
|
session,
|
||||||
resolved.conversionTypeRef.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE)
|
resolved.conversionTypeRef.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NULLABLE)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> error("Unknown type operator")
|
else -> error("Unknown type operator")
|
||||||
@@ -193,7 +193,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
|||||||
if (symbol is ConeCallableSymbol) {
|
if (symbol is ConeCallableSymbol) {
|
||||||
jump.tryCalculateReturnType(symbol.firUnsafe())
|
jump.tryCalculateReturnType(symbol.firUnsafe())
|
||||||
} else if (symbol is ConeClassifierSymbol) {
|
} else if (symbol is ConeClassifierSymbol) {
|
||||||
val firUnsafe = symbol.firUnsafe()
|
val firUnsafe = symbol.firUnsafe<FirElement>()
|
||||||
// TODO: unhack
|
// TODO: unhack
|
||||||
if (firUnsafe is FirEnumEntry) {
|
if (firUnsafe is FirEnumEntry) {
|
||||||
(firUnsafe.superTypeRefs.firstOrNull() as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(
|
(firUnsafe.superTypeRefs.firstOrNull() as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(
|
||||||
@@ -309,7 +309,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
|||||||
val receiverTypeRef = anonymousFunction.receiverTypeRef
|
val receiverTypeRef = anonymousFunction.receiverTypeRef
|
||||||
fun transform(): FirAnonymousFunction {
|
fun transform(): FirAnonymousFunction {
|
||||||
return withScopeCleanup(scopes) {
|
return withScopeCleanup(scopes) {
|
||||||
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe()?.scope(session, scopeSession))
|
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe<ConeKotlinType>()?.scope(session, scopeSession))
|
||||||
val result =
|
val result =
|
||||||
super.transformAnonymousFunction(
|
super.transformAnonymousFunction(
|
||||||
anonymousFunction,
|
anonymousFunction,
|
||||||
@@ -648,7 +648,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
|||||||
fun transform(): CompositeTransformResult<FirDeclaration> {
|
fun transform(): CompositeTransformResult<FirDeclaration> {
|
||||||
localScopes.lastOrNull()?.storeDeclaration(namedFunction)
|
localScopes.lastOrNull()?.storeDeclaration(namedFunction)
|
||||||
return withScopeCleanup(scopes) {
|
return withScopeCleanup(scopes) {
|
||||||
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe()?.scope(session, scopeSession))
|
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe<ConeKotlinType>()?.scope(session, scopeSession))
|
||||||
|
|
||||||
|
|
||||||
val result = super.transformNamedFunction(namedFunction, namedFunction.returnTypeRef).single as FirNamedFunction
|
val result = super.transformNamedFunction(namedFunction, namedFunction.returnTypeRef).single as FirNamedFunction
|
||||||
|
|||||||
+2
-5
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
|
|||||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||||
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.*
|
import org.jetbrains.kotlin.fir.scopes.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
|
||||||
import org.jetbrains.kotlin.fir.types.coneTypeUnsafe
|
|
||||||
import org.jetbrains.kotlin.fir.types.createArrayOf
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
|
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
import org.jetbrains.kotlin.fir.visitors.compose
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
@@ -103,7 +100,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
|||||||
|
|
||||||
if (valueParameter.isVararg) {
|
if (valueParameter.isVararg) {
|
||||||
val returnTypeRef = valueParameter.returnTypeRef
|
val returnTypeRef = valueParameter.returnTypeRef
|
||||||
val returnType = returnTypeRef.coneTypeUnsafe()
|
val returnType = returnTypeRef.coneTypeUnsafe<ConeKotlinType>()
|
||||||
valueParameter.transformReturnTypeRef(
|
valueParameter.transformReturnTypeRef(
|
||||||
StoreType,
|
StoreType,
|
||||||
valueParameter.returnTypeRef.withReplacedConeType(
|
valueParameter.returnTypeRef.withReplacedConeType(
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
|
|||||||
|
|
||||||
// TODO: get rid of class types with type-alias symbols
|
// TODO: get rid of class types with type-alias symbols
|
||||||
if (typeConstructor is FirTypeAliasSymbol) {
|
if (typeConstructor is FirTypeAliasSymbol) {
|
||||||
return typeConstructor.fir.expandedTypeRef.coneTypeSafe()?.typeConstructor()
|
return typeConstructor.fir.expandedTypeRef.coneTypeSafe<ConeKotlinType>()?.typeConstructor()
|
||||||
?: ErrorTypeConstructor("Failed to expand alias: ${this}")
|
?: ErrorTypeConstructor("Failed to expand alias: ${this}")
|
||||||
}
|
}
|
||||||
return typeConstructor
|
return typeConstructor
|
||||||
|
|||||||
Reference in New Issue
Block a user