Fix union related failures.
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
a98e2c4e03
commit
13bff10567
@@ -136,7 +136,7 @@ interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeF
|
||||
|
||||
fun unionTypeAttributes(types: List<KotlinTypeMarker>): List<AnnotationMarker>
|
||||
|
||||
fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker
|
||||
fun KotlinTypeMarker.replaceCustomAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker
|
||||
}
|
||||
|
||||
// This interface is only used to declare that implementing class is supposed to be used as a TypeSystemInferenceExtensionContext component
|
||||
|
||||
@@ -10,9 +10,9 @@ import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute<AnnotationsTypeAttribute>() {
|
||||
override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute = this
|
||||
override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
|
||||
|
||||
override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute = this
|
||||
override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
|
||||
|
||||
override fun add(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute {
|
||||
if (other == null) return this
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSignedOrUnsignedNumberType as classicIsSignedOrUnsignedNumberType
|
||||
@@ -644,12 +645,13 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return (types as List<KotlinType>).map { it.unwrap().attributes }.reduce { x, y -> x.union(y) }.toList()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker {
|
||||
override fun KotlinTypeMarker.replaceCustomAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker {
|
||||
require(this is KotlinType)
|
||||
if (newAttributes.isEmpty()) return this
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val attributes = (newAttributes as List<TypeAttribute<*>>).filterNot { it is AnnotationsTypeAttribute }.toMutableList()
|
||||
attributes.addIfNotNull(this.attributes.annotationsAttribute)
|
||||
return this.unwrap().replaceAttributes(
|
||||
TypeAttributes.create(newAttributes as List<TypeAttribute<*>>)
|
||||
TypeAttributes.create(attributes)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user