Union type attributes for common super type calculation
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
db471ca61e
commit
56d817b49f
@@ -11,6 +11,9 @@
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.extensions.internal.typeResolutionInterceptorExtension"
|
||||
interface="org.jetbrains.kotlin.extensions.internal.TypeResolutionInterceptorExtension"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.extensions.TypeAttributeTranslatorExtension"
|
||||
interface="org.jetbrains.kotlin.extensions.TypeAttributeTranslatorExtension"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.diagnosticSuppressor"
|
||||
interface="org.jetbrains.kotlin.resolve.diagnostics.DiagnosticSuppressor"
|
||||
dynamic="true"/>
|
||||
|
||||
@@ -415,7 +415,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
return false
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getAnnotations(): List<AnnotationMarker> {
|
||||
override fun KotlinTypeMarker.getAttributes(): List<AnnotationMarker> {
|
||||
require(this is ConeKotlinType)
|
||||
return attributes.toList()
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
override fun SimpleTypeMarker.isPrimitiveType(): Boolean =
|
||||
this is IrSimpleType && irTypePredicates_isPrimitiveType()
|
||||
|
||||
override fun KotlinTypeMarker.getAnnotations(): List<AnnotationMarker> {
|
||||
override fun KotlinTypeMarker.getAttributes(): List<AnnotationMarker> {
|
||||
require(this is IrType)
|
||||
return this.annotations.map { object : AnnotationMarker, IrElement by it {} }
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.types.model.*
|
||||
object NewCommonSuperTypeCalculator {
|
||||
fun TypeSystemCommonSuperTypesContext.commonSuperType(types: List<KotlinTypeMarker>): KotlinTypeMarker {
|
||||
val maxDepth = types.maxOfOrNull { it.typeDepth() } ?: 0
|
||||
return commonSuperType(types, -maxDepth, true)
|
||||
return commonSuperType(types, -maxDepth, true).replaceTypeAttributes(unionTypeAttributes(types))
|
||||
}
|
||||
|
||||
private fun TypeSystemCommonSuperTypesContext.commonSuperType(
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ class PostponedArgumentInputTypesResolver(
|
||||
}
|
||||
}
|
||||
|
||||
val annotations = functionalTypesFromConstraints?.map { it.type.getAnnotations() }?.flatten()?.distinct()
|
||||
val annotations = functionalTypesFromConstraints?.map { it.type.getAttributes() }?.flatten()?.distinct()
|
||||
|
||||
val extensionFunctionTypePresentInConstraints = functionalTypesFromConstraints?.any { it.type.isExtensionFunctionType() } == true
|
||||
|
||||
|
||||
+5
-1
@@ -139,7 +139,11 @@ class MutableVariableWithConstraints private constructor(
|
||||
return false
|
||||
|
||||
return when (old.kind) {
|
||||
ConstraintKind.EQUALITY -> true
|
||||
ConstraintKind.EQUALITY -> {
|
||||
with(context) {
|
||||
old.type.getAttributes() == new.type.getAttributes()
|
||||
}
|
||||
}
|
||||
ConstraintKind.LOWER -> new.kind.isLower()
|
||||
ConstraintKind.UPPER -> new.kind.isUpper()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user