[FIR] Support intersection types in some type context methods

This commit is contained in:
Dmitriy Novozhilov
2020-01-27 17:27:47 +03:00
parent 57a1342aac
commit ff3116f0ed
2 changed files with 9 additions and 14 deletions
@@ -134,10 +134,10 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
if (predicate(this)) return true
val flexibleType = this.asFlexibleType()
val flexibleType = this as? ConeFlexibleType
if (flexibleType != null
&& (flexibleType.lowerBound().containsInternal(predicate, visited)
|| flexibleType.upperBound().containsInternal(predicate, visited))
&& (flexibleType.lowerBound.containsInternal(predicate, visited)
|| flexibleType.upperBound.containsInternal(predicate, visited))
) {
return true
}
@@ -148,18 +148,10 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
) {
return true
}
/*
TODO:
TypeConstructor typeConstructor = type.getConstructor();
if (typeConstructor instanceof IntersectionTypeConstructor) {
IntersectionTypeConstructor intersectionTypeConstructor = (IntersectionTypeConstructor) typeConstructor;
for (KotlinType supertype : intersectionTypeConstructor.getSupertypes()) {
if (contains(supertype, isSpecialType, visited)) return true;
}
return false;
if (this is ConeIntersectionType) {
return this.intersectedTypes.any { it.containsInternal(predicate, visited) }
}
*/
repeat(argumentsCount()) { index ->
val argument = getArgument(index)
@@ -417,7 +417,10 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
if (this is ConeTypeParameterType /* || is TypeVariable */)
return hasNullableSuperType(type)
// TODO: Intersection types
if (this is ConeIntersectionType && intersectedTypes.any { it.isNullableType() }) {
return true
}
return false
}