Specify type arguments to fix compilation against bootstrap compiler

This commit is contained in:
Mikhail Zarechenskiy
2019-05-06 12:30:48 +03:00
parent 8446ea8a6b
commit 2f835ed66f
7 changed files with 16 additions and 15 deletions
@@ -762,7 +762,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
}
private fun typeParametersFromSelfType(delegatedSelfTypeRef: FirTypeRef): List<FirTypeParameter> {
return delegatedSelfTypeRef.coneTypeSafe()
return delegatedSelfTypeRef.coneTypeSafe<ConeKotlinType>()
?.typeArguments
?.map { ((it as ConeTypeParameterType).lookupTag as FirTypeParameterSymbol).fir }
?: emptyList()
@@ -38,7 +38,11 @@ fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession)
// TODO: support LibraryTypeParameterSymbol or get rid of it
val toSymbol = this.lookupTag.toSymbol(useSiteSession)?.takeIf { it is FirBasedSymbol<*> } ?: return null
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)
else -> error("Failed type ${this}")
@@ -46,8 +46,8 @@ inline fun <reified T : FirScope> scopeSessionKey(): ScopeSessionKey<T> {
return object : ScopeSessionKey<T>() {}
}
val USE_SITE = scopeSessionKey()
val DECLARED = scopeSessionKey()
val USE_SITE = scopeSessionKey<FirScope>()
val DECLARED = scopeSessionKey<FirScope>()
data class SubstitutionScopeKey<T : FirClassSubstitutionScope>(val type: ConeClassLikeType) : ScopeSessionKey<T>() {}
@@ -149,7 +149,7 @@ internal fun FirExpression.getExpectedType(
// parameter.type.unwrap()
// } else {
if (parameter.isVararg) {
parameter.returnTypeRef.coneTypeUnsafe().varargElementType(session)
parameter.returnTypeRef.coneTypeUnsafe<ConeKotlinType>().varargElementType(session)
} else {
parameter.returnTypeRef.coneTypeUnsafe()
}//?.varargElementType?.unwrap() ?: parameter.type.unwrap()
@@ -150,7 +150,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
resolved.resultType =
resolved.conversionTypeRef.withReplacedConeType(
session,
resolved.conversionTypeRef.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE)
resolved.conversionTypeRef.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NULLABLE)
)
}
else -> error("Unknown type operator")
@@ -193,7 +193,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
if (symbol is ConeCallableSymbol) {
jump.tryCalculateReturnType(symbol.firUnsafe())
} else if (symbol is ConeClassifierSymbol) {
val firUnsafe = symbol.firUnsafe()
val firUnsafe = symbol.firUnsafe<FirElement>()
// TODO: unhack
if (firUnsafe is FirEnumEntry) {
(firUnsafe.superTypeRefs.firstOrNull() as? FirResolvedTypeRef) ?: FirErrorTypeRefImpl(
@@ -309,7 +309,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
val receiverTypeRef = anonymousFunction.receiverTypeRef
fun transform(): FirAnonymousFunction {
return withScopeCleanup(scopes) {
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe()?.scope(session, scopeSession))
scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe<ConeKotlinType>()?.scope(session, scopeSession))
val result =
super.transformAnonymousFunction(
anonymousFunction,
@@ -648,7 +648,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
fun transform(): CompositeTransformResult<FirDeclaration> {
localScopes.lastOrNull()?.storeDeclaration(namedFunction)
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
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
import org.jetbrains.kotlin.fir.scopes.FirPosition
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
import org.jetbrains.kotlin.fir.scopes.impl.*
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
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.*
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
import org.jetbrains.kotlin.fir.visitors.compose
@@ -103,7 +100,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
if (valueParameter.isVararg) {
val returnTypeRef = valueParameter.returnTypeRef
val returnType = returnTypeRef.coneTypeUnsafe()
val returnType = returnTypeRef.coneTypeUnsafe<ConeKotlinType>()
valueParameter.transformReturnTypeRef(
StoreType,
valueParameter.returnTypeRef.withReplacedConeType(
@@ -138,7 +138,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext {
// TODO: get rid of class types with type-alias symbols
if (typeConstructor is FirTypeAliasSymbol) {
return typeConstructor.fir.expandedTypeRef.coneTypeSafe()?.typeConstructor()
return typeConstructor.fir.expandedTypeRef.coneTypeSafe<ConeKotlinType>()?.typeConstructor()
?: ErrorTypeConstructor("Failed to expand alias: ${this}")
}
return typeConstructor