FIR: support DefinitelyNotNull types

#KT-49465 Fixed
This commit is contained in:
Mikhael Bogdanov
2022-01-26 12:32:56 +01:00
parent bd31cbaebf
commit 15e08893aa
53 changed files with 1092 additions and 133 deletions
@@ -485,6 +485,33 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() {
}
is FirFunctionTypeRef -> createFunctionalType(typeRef) to null
is FirDynamicTypeRef -> ConeKotlinErrorType(ConeUnsupportedDynamicType()) to null
is FirIntersectionTypeRef -> {
val (leftType, leftDiagnostic) = resolveType(
typeRef.leftType
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
scopeClassDeclaration,
areBareTypesAllowed,
isOperandOfIsOperator,
useSiteFile,
supertypeSupplier
)
val (rightType, _) = resolveType(
typeRef.rightType
?: return ConeKotlinErrorType(ConeSimpleDiagnostic("Problem during processing intersection type")) to null,
scopeClassDeclaration,
areBareTypesAllowed,
isOperandOfIsOperator,
useSiteFile,
supertypeSupplier
)
if (rightType.isAny && leftType is ConeTypeParameterType) {
ConeDefinitelyNotNullType(leftType) to leftDiagnostic //how properly concat (leftDiagnostic + rightDiagnostic)?
} else {
ConeKotlinErrorType(ConeUnsupported("Intersection types are not supported yet", typeRef.source)) to null
}
}
else -> error(typeRef.render())
}
}