Minor. use when instead of if sequence.

This commit is contained in:
Stanislav Erokhin
2017-02-07 15:30:21 +03:00
parent b616ef0a40
commit 58c2466a52
@@ -102,9 +102,10 @@ object NewKotlinTypeChecker : KotlinTypeChecker {
} }
fun transformToNewType(type: SimpleType): SimpleType { fun transformToNewType(type: SimpleType): SimpleType {
val constructor = type.constructor
when (constructor) {
// Type itself can be just SimpleTypeImpl, not CapturedType. see KT-16147 // Type itself can be just SimpleTypeImpl, not CapturedType. see KT-16147
if (type.constructor is CapturedTypeConstructor) { is CapturedTypeConstructor -> {
val constructor = type.constructor as CapturedTypeConstructor
val lowerType = constructor.typeProjection.check { it.projectionKind == Variance.IN_VARIANCE }?.type?.unwrap() val lowerType = constructor.typeProjection.check { it.projectionKind == Variance.IN_VARIANCE }?.type?.unwrap()
// it is incorrect calculate this type directly because of recursive star projections // it is incorrect calculate this type directly because of recursive star projections
@@ -116,15 +117,16 @@ object NewKotlinTypeChecker : KotlinTypeChecker {
return newCapturedType return newCapturedType
} }
if (type.constructor is IntersectionTypeConstructor && type.isMarkedNullable) { is IntegerValueTypeConstructor -> {
val newSuperTypes = type.constructor.supertypes.map { it.makeNullable() } val newConstructor = IntersectionTypeConstructor(constructor.supertypes.map { TypeUtils.makeNullableAsSpecified(it, type.isMarkedNullable) })
return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, type.memberScope)
}
is IntersectionTypeConstructor -> if (type.isMarkedNullable) {
val newSuperTypes = constructor.supertypes.map { it.makeNullable() }
val newConstructor = IntersectionTypeConstructor(newSuperTypes) val newConstructor = IntersectionTypeConstructor(newSuperTypes)
return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, newConstructor.createScopeForKotlinType()) return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, newConstructor.createScopeForKotlinType())
} }
if (type.constructor is IntegerValueTypeConstructor) {
val newConstructor = IntersectionTypeConstructor(type.constructor.supertypes.map { TypeUtils.makeNullableAsSpecified(it, type.isMarkedNullable) })
return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, type.memberScope)
} }
return type return type