[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 kotlinTypeRefiner = null
) )
val computedType = if (classifier is TypeAliasDescriptor) return if (classifier is TypeAliasDescriptor)
classifier.underlyingType.withAbbreviation(simpleType) classifier.underlyingType.withAbbreviation(simpleType)
else else
simpleType simpleType
return if (isDefinitelyNotNullType)
computedType.makeSimpleTypeDefinitelyNotNullOrNotNull()
else
computedType
} }
internal fun findClassOrTypeAlias( internal fun findClassOrTypeAlias(
@@ -28,7 +28,6 @@ abstract class CirSimpleType : CirType(), CirHasVisibility {
abstract val classifierId: CirClassifierId abstract val classifierId: CirClassifierId
abstract val arguments: List<CirTypeProjection> abstract val arguments: List<CirTypeProjection>
abstract val isMarkedNullable: Boolean abstract val isMarkedNullable: Boolean
abstract val isDefinitelyNotNullType: Boolean
} }
data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType() data class CirFlexibleType(val lowerBound: CirSimpleType, val upperBound: CirSimpleType) : CirType()
@@ -39,8 +39,7 @@ object CirTypeFactory {
type = create(projection.type) type = create(projection.type)
) )
}, },
isMarkedNullable = abbreviation.isMarkedNullable, isMarkedNullable = abbreviation.isMarkedNullable
isDefinitelyNotNullType = abbreviation.isDefinitelyNotNullType
) )
} }
@@ -48,16 +47,14 @@ object CirTypeFactory {
classifierId: CirClassifierId, classifierId: CirClassifierId,
visibility: Visibility, visibility: Visibility,
arguments: List<CirTypeProjection>, arguments: List<CirTypeProjection>,
isMarkedNullable: Boolean, isMarkedNullable: Boolean
isDefinitelyNotNullType: Boolean
): CirSimpleType { ): CirSimpleType {
return interner.intern( return interner.intern(
CirSimpleTypeImpl( CirSimpleTypeImpl(
classifierId = classifierId, classifierId = classifierId,
visibility = visibility, visibility = visibility,
arguments = arguments, arguments = arguments,
isMarkedNullable = isMarkedNullable, isMarkedNullable = isMarkedNullable
isDefinitelyNotNullType = isDefinitelyNotNullType
) )
) )
} }
@@ -14,8 +14,7 @@ data class CirSimpleTypeImpl(
override val classifierId: CirClassifierId, override val classifierId: CirClassifierId,
override val visibility: Visibility, // visibility of the classifier descriptor override val visibility: Visibility, // visibility of the classifier descriptor
override val arguments: List<CirTypeProjection>, override val arguments: List<CirTypeProjection>,
override val isMarkedNullable: Boolean, override val isMarkedNullable: Boolean
override val isDefinitelyNotNullType: Boolean
) : CirSimpleType() { ) : CirSimpleType() {
// See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode // See also org.jetbrains.kotlin.types.KotlinType.cachedHashCode
private var cachedHashCode = 0 private var cachedHashCode = 0
@@ -24,7 +23,6 @@ data class CirSimpleTypeImpl(
.appendHashCode(visibility) .appendHashCode(visibility)
.appendHashCode(arguments) .appendHashCode(arguments)
.appendHashCode(isMarkedNullable) .appendHashCode(isMarkedNullable)
.appendHashCode(isDefinitelyNotNullType)
override fun hashCode(): Int { override fun hashCode(): Int {
var currentHashCode = cachedHashCode var currentHashCode = cachedHashCode
@@ -42,7 +40,6 @@ data class CirSimpleTypeImpl(
&& classifierId == other.classifierId && classifierId == other.classifierId
&& visibility == other.visibility && visibility == other.visibility
&& arguments == other.arguments && arguments == other.arguments
&& isDefinitelyNotNullType == other.isDefinitelyNotNullType
} }
else -> false else -> false
} }
@@ -164,8 +164,7 @@ private class DeprecatedAnnotationCommonizer : Commonizer<CirAnnotation, CirAnno
classifierId = CirClassifierIdFactory.createForClass(classId), classifierId = CirClassifierIdFactory.createForClass(classId),
visibility = Visibilities.PUBLIC, visibility = Visibilities.PUBLIC,
arguments = emptyList(), arguments = emptyList(),
isMarkedNullable = false, isMarkedNullable = false
isDefinitelyNotNullType = false
) )
private fun CirAnnotation.getDeprecationMessage(): String? = constantValueArguments.getString(PROPERTY_NAME_MESSAGE) 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 val bId = b.classifierId
if (a !== b) { if (a !== b) {
if (a.arguments.size != b.arguments.size if (a.arguments.size != b.arguments.size || a.isMarkedNullable != b.isMarkedNullable) {
|| a.isMarkedNullable != b.isMarkedNullable
|| a.isDefinitelyNotNullType != b.isDefinitelyNotNullType
) {
return false return false
} }