[Commonizer] Remove isDefinitelyNotNullType from CirSimpleType

This commit is contained in:
Dmitriy Dolovov
2020-07-09 10:05:31 +07:00
parent 4d21455e72
commit 3af937ea9a
6 changed files with 7 additions and 23 deletions
@@ -132,15 +132,10 @@ internal fun CirSimpleType.buildType(
kotlinTypeRefiner = null
)
val computedType = if (classifier is TypeAliasDescriptor)
return if (classifier is TypeAliasDescriptor)
classifier.underlyingType.withAbbreviation(simpleType)
else
simpleType
return if (isDefinitelyNotNullType)
computedType.makeSimpleTypeDefinitelyNotNullOrNotNull()
else
computedType
}
internal fun findClassOrTypeAlias(
@@ -28,7 +28,6 @@ abstract class CirSimpleType : CirType(), CirHasVisibility {
abstract val classifierId: CirClassifierId
abstract val arguments: List<CirTypeProjection>
abstract val isMarkedNullable: Boolean
abstract val isDefinitelyNotNullType: Boolean
}
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType()
@@ -39,8 +39,7 @@ object CirTypeFactory {
type = create(projection.type)
)
},
isMarkedNullable = abbreviation.isMarkedNullable,
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType
isMarkedNullable = abbreviation.isMarkedNullable
)
}
@@ -48,16 +47,14 @@ object CirTypeFactory {
classifierId: CirClassifierId,
visibility: Visibility,
arguments: List<CirTypeProjection>,
isMarkedNullable: Boolean,
isDefinitelyNotNullType: Boolean
isMarkedNullable: Boolean
): CirSimpleType {
return interner.intern(
CirSimpleTypeImpl(
classifierId = classifierId,
visibility = visibility,
arguments = arguments,
isMarkedNullable = isMarkedNullable,
isDefinitelyNotNullType = isDefinitelyNotNullType
isMarkedNullable = isMarkedNullable
)
)
}
@@ -14,8 +14,7 @@ data class CirSimpleTypeImpl(
override val classifierId: CirClassifierId,
override val visibility: Visibility, // visibility of the classifier descriptor
override val arguments: List<CirTypeProjection>,
override val isMarkedNullable: Boolean,
override val isDefinitelyNotNullType: Boolean
override val isMarkedNullable: Boolean
) : CirSimpleType() {
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
private var cachedHashCode = 0
@@ -24,7 +23,6 @@ data class CirSimpleTypeImpl(
.appendHashCode(visibility)
.appendHashCode(arguments)
.appendHashCode(isMarkedNullable)
.appendHashCode(isDefinitelyNotNullType)
override fun hashCode(): Int {
var currentHashCode = cachedHashCode
@@ -42,7 +40,6 @@ data class CirSimpleTypeImpl(
&& classifierId == other.classifierId
&& visibility == other.visibility
&& arguments == other.arguments
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
}
else -> false
}
@@ -164,8 +164,7 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
classifierId = CirClassifierIdFactory.createForClass(classId),
visibility = Visibilities.PUBLIC,
arguments = emptyList(),
isMarkedNullable = false,
isDefinitelyNotNullType = false
isMarkedNullable = false
)
private fun CirAnnotation.getDeprecationMessage(): String? = constantValueArguments.getString(PROPERTY_NAME_MESSAGE)
@@ -40,10 +40,7 @@ private fun areSimpleTypesEqual(cache: CirClassifiersCache, a: CirSimpleType, b:
val bId = b.classifierId
if (a !== b) {
if (a.arguments.size != b.arguments.size
|| a.isMarkedNullable != b.isMarkedNullable
|| a.isDefinitelyNotNullType != b.isDefinitelyNotNullType
) {
if (a.arguments.size != b.arguments.size || a.isMarkedNullable != b.isMarkedNullable) {
return false
}