[FIR] Add default upper bound to type parameter in fir deserializer

This commit is contained in:
Dmitriy Novozhilov
2019-08-01 11:53:04 +03:00
parent 2fe01f9086
commit 317e3edba8
5 changed files with 12 additions and 8 deletions
@@ -31,7 +31,8 @@ class FirTypeParameterImpl(
/*
* Note that each type parameter have to has at least one upper bound (Any? if there is no other bounds)
* so if you create FirTypeParameterImpl you need to guarantee this contract
* so after initializing FirTypeParameterImpl you should call [addDefaultBoundIfNecessary] to guarantee
* this contract
*/
override val bounds: MutableList<FirTypeRef> = mutableListOf()
@@ -40,4 +41,10 @@ class FirTypeParameterImpl(
return super<FirAbstractNamedAnnotatedDeclaration>.transformChildren(transformer, data)
}
}
fun FirTypeParameterImpl.addDefaultBoundIfNecessary() {
if (bounds.isEmpty()) {
bounds += FirImplicitNullableAnyTypeRef(null)
}
}