[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 {
return ConeClassLikeTypeImpl(
fun FirAnonymousObject.defaultType(): ConeClassLikeType {
return this.typeRef.coneTypeSafe() ?: ConeClassLikeTypeImpl(
symbol.toLookupTag(),
emptyArray(),
isNullable = false
@@ -369,9 +369,11 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
}
dataFlowAnalyzer.enterClass()
val type = anonymousObject.defaultType()
anonymousObject.resultType = buildResolvedTypeRef {
source = anonymousObject.source
this.type = type
if (anonymousObject.typeRef !is FirResolvedTypeRef) {
anonymousObject.resultType = buildResolvedTypeRef {
source = anonymousObject.source
this.type = type
}
}
var result = withLabelAndReceiverType(null, anonymousObject, type) {
transformDeclarationContent(anonymousObject, data).single as FirAnonymousObject
@@ -200,11 +200,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
//require(this is ConeSymbol)
return when (this) {
is FirTypeParameterSymbol,
is FirAnonymousObjectSymbol,
is ConeCapturedTypeConstructor,
is ErrorTypeConstructor,
is ConeTypeVariableTypeConstructor,
is ConeIntersectionType -> 0
is FirAnonymousObjectSymbol -> fir.typeParameters.size
is FirRegularClassSymbol -> fir.typeParameters.size
is FirTypeAliasSymbol -> fir.typeParameters.size
is ConeIntegerLiteralType -> 0
@@ -216,6 +216,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
//require(this is ConeSymbol)
return when (this) {
is FirTypeParameterSymbol -> error("?!:11")
is FirAnonymousObjectSymbol -> fir.typeParameters[index].symbol
is FirRegularClassSymbol -> fir.typeParameters[index].symbol
is FirTypeAliasSymbol -> fir.typeParameters[index].symbol
else -> error("?!:12")