Add support for attribute serialization.
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
f2a351367c
commit
d444978ebf
+1
-1
@@ -104,7 +104,7 @@ class CapturedType(
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): CapturedType =
|
||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations.toAttributes())
|
||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations.toDefaultAttributes())
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAttributes)
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.types.model.FlexibleTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeArgumentListMarker
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
/**
|
||||
* [KotlinType] has only two direct subclasses: [WrappedType] and [UnwrappedType].
|
||||
@@ -54,7 +53,7 @@ sealed class KotlinType : Annotated, KotlinTypeMarker {
|
||||
abstract val memberScope: MemberScope
|
||||
abstract val attributes: TypeAttributes
|
||||
override val annotations: Annotations
|
||||
get() = attributes.toAnnotations()
|
||||
get() = attributes.toDefaultAnnotations()
|
||||
|
||||
abstract fun unwrap(): UnwrappedType
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ object KotlinTypeFactory {
|
||||
if (annotations.isEmpty())
|
||||
it
|
||||
else
|
||||
SimpleTypeWithAttributes(it, annotations.toAttributes())
|
||||
SimpleTypeWithAttributes(it, annotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -209,7 +209,7 @@ object KotlinTypeFactory {
|
||||
if (annotations.isEmpty())
|
||||
it
|
||||
else
|
||||
SimpleTypeWithAttributes(it, annotations.toAttributes())
|
||||
SimpleTypeWithAttributes(it, annotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -113,12 +113,12 @@ class TypeAttributes private constructor(attributes: List<TypeAttribute<*>>) : A
|
||||
get() = Companion
|
||||
}
|
||||
|
||||
fun TypeAttributes.toAnnotations(): Annotations =
|
||||
fun TypeAttributes.toDefaultAnnotations(): Annotations =
|
||||
DefaultTypeAttributesTranslator.toAnnotations(this)
|
||||
|
||||
fun Annotations.toAttributes(): TypeAttributes = DefaultTypeAttributesTranslator.toAttributes(this)
|
||||
fun Annotations.toDefaultAttributes(): TypeAttributes = DefaultTypeAttributesTranslator.toAttributes(this)
|
||||
|
||||
fun TypeAttributes.replaceAnnotations(newAnnotations: Annotations): TypeAttributes {
|
||||
val withoutCustom = (custom?.let { this.remove(it) } ?: this)
|
||||
return withoutCustom.add(newAnnotations.toAttributes())
|
||||
return withoutCustom.add(newAnnotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class NewCapturedType(
|
||||
get() = ErrorUtils.createErrorScope("No member resolution should be done on captured type!", true)
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
NewCapturedType(captureStatus, constructor, lowerType, newAnnotations.toAttributes(), isMarkedNullable)
|
||||
NewCapturedType(captureStatus, constructor, lowerType, newAnnotations.toDefaultAttributes(), isMarkedNullable)
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
NewCapturedType(captureStatus, constructor, lowerType, newAttributes, isMarkedNullable)
|
||||
|
||||
Reference in New Issue
Block a user