[FIR] Support captured type arguments of anonymous objects in resolve

This commit is contained in:
simon.ogorodnik
2020-04-09 22:27:51 +03:00
parent 2b114dd2b4
commit b72d0957e4
3 changed files with 9 additions and 6 deletions
@@ -78,8 +78,8 @@ fun FirRegularClass.defaultType(): ConeClassLikeTypeImpl {
) )
} }
fun FirAnonymousObject.defaultType(): ConeClassLikeTypeImpl { fun FirAnonymousObject.defaultType(): ConeClassLikeType {
return ConeClassLikeTypeImpl( return this.typeRef.coneTypeSafe() ?: ConeClassLikeTypeImpl(
symbol.toLookupTag(), symbol.toLookupTag(),
emptyArray(), emptyArray(),
isNullable = false isNullable = false
@@ -369,9 +369,11 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
} }
dataFlowAnalyzer.enterClass() dataFlowAnalyzer.enterClass()
val type = anonymousObject.defaultType() val type = anonymousObject.defaultType()
anonymousObject.resultType = buildResolvedTypeRef { if (anonymousObject.typeRef !is FirResolvedTypeRef) {
source = anonymousObject.source anonymousObject.resultType = buildResolvedTypeRef {
this.type = type source = anonymousObject.source
this.type = type
}
} }
var result = withLabelAndReceiverType(null, anonymousObject, type) { var result = withLabelAndReceiverType(null, anonymousObject, type) {
transformDeclarationContent(anonymousObject, data).single as FirAnonymousObject transformDeclarationContent(anonymousObject, data).single as FirAnonymousObject
@@ -200,11 +200,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
//require(this is ConeSymbol) //require(this is ConeSymbol)
return when (this) { return when (this) {
is FirTypeParameterSymbol, is FirTypeParameterSymbol,
is FirAnonymousObjectSymbol,
is ConeCapturedTypeConstructor, is ConeCapturedTypeConstructor,
is ErrorTypeConstructor, is ErrorTypeConstructor,
is ConeTypeVariableTypeConstructor, is ConeTypeVariableTypeConstructor,
is ConeIntersectionType -> 0 is ConeIntersectionType -> 0
is FirAnonymousObjectSymbol -> fir.typeParameters.size
is FirRegularClassSymbol -> fir.typeParameters.size is FirRegularClassSymbol -> fir.typeParameters.size
is FirTypeAliasSymbol -> fir.typeParameters.size is FirTypeAliasSymbol -> fir.typeParameters.size
is ConeIntegerLiteralType -> 0 is ConeIntegerLiteralType -> 0
@@ -216,6 +216,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
//require(this is ConeSymbol) //require(this is ConeSymbol)
return when (this) { return when (this) {
is FirTypeParameterSymbol -> error("?!:11") is FirTypeParameterSymbol -> error("?!:11")
is FirAnonymousObjectSymbol -> fir.typeParameters[index].symbol
is FirRegularClassSymbol -> fir.typeParameters[index].symbol is FirRegularClassSymbol -> fir.typeParameters[index].symbol
is FirTypeAliasSymbol -> fir.typeParameters[index].symbol is FirTypeAliasSymbol -> fir.typeParameters[index].symbol
else -> error("?!:12") else -> error("?!:12")