[FIR] Return error type from common super type if it present

This commit is contained in:
Dmitriy Novozhilov
2019-08-01 19:02:35 +03:00
parent 6e2958880b
commit 3e44bc805f
7 changed files with 53 additions and 1 deletions
@@ -131,6 +131,7 @@ object NewCommonSuperTypeCalculator {
val explicitSupertypes = filterSupertypes(uniqueTypes)
if (explicitSupertypes.size == 1) return explicitSupertypes.single()
findErrorTypeInSupertypesIfItIsNeeded(explicitSupertypes)?.let { return it }
findCommonIntegerLiteralTypesSuperType(explicitSupertypes)?.let { return it }
// IntegerLiteralTypeConstructor.findCommonSuperType(explicitSupertypes)?.let { return it }
@@ -138,6 +139,14 @@ object NewCommonSuperTypeCalculator {
return findSuperTypeConstructorsAndIntersectResult(explicitSupertypes, depth)
}
private fun TypeSystemCommonSuperTypesContext.findErrorTypeInSupertypesIfItIsNeeded(types: List<SimpleTypeMarker>): SimpleTypeMarker? {
if (isErrorTypeAllowed) return null
for (type in types) {
collectAllSupertypes(type).firstOrNull { it.isError() }?.let { return it.toErrorType() }
}
return null
}
private fun TypeSystemCommonSuperTypesContext.findSuperTypeConstructorsAndIntersectResult(
types: List<SimpleTypeMarker>,
depth: Int