diff options
author | owengray-google <owengray@google.com> | 2022-04-08 11:53:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 18:53:52 +0300 |
commit | 13746f4afacd72576515dd94ba1167546418421f (patch) | |
tree | b6fbb6b0fae435c3940a4d06bba8822f76a7e5bb /core/src/main/kotlin/model/Documentable.kt | |
parent | c81b39f966ce15f38afc8bea60f800fed9ea2473 (diff) | |
download | dokka-13746f4afacd72576515dd94ba1167546418421f.tar.gz dokka-13746f4afacd72576515dd94ba1167546418421f.tar.bz2 dokka-13746f4afacd72576515dd94ba1167546418421f.zip |
Rework AnnotationTarget to be stricter (#2414)
Diffstat (limited to 'core/src/main/kotlin/model/Documentable.kt')
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 13d04555..0f73c8e1 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -385,20 +385,18 @@ data class DTypeAlias( } sealed class Projection -sealed class Bound : Projection(), AnnotationTarget +sealed class Bound : Projection() data class TypeParameter( val dri: DRI, val name: String, val presentableName: String? = null, override val extra: PropertyContainer<TypeParameter> = PropertyContainer.empty() -) : Bound(), WithExtraProperties<TypeParameter> { +) : Bound(), AnnotationTarget, WithExtraProperties<TypeParameter> { override fun withNewExtras(newExtras: PropertyContainer<TypeParameter>): TypeParameter = copy(extra = extra) } -object Star : Projection() - -sealed class TypeConstructor : Bound() { +sealed class TypeConstructor : Bound(), AnnotationTarget { abstract val dri: DRI abstract val projections: List<Projection> abstract val presentableName: String? @@ -426,6 +424,39 @@ data class FunctionalTypeConstructor( copy(extra = newExtras) } +// kotlin.annotation.AnnotationTarget.TYPEALIAS +data class TypeAliased( + val typeAlias: Bound, + val inner: Bound, + override val extra: PropertyContainer<TypeAliased> = PropertyContainer.empty() +) : Bound(), AnnotationTarget, WithExtraProperties<TypeAliased> { + override fun withNewExtras(newExtras: PropertyContainer<TypeAliased>): TypeAliased = + copy(extra = newExtras) +} + +data class PrimitiveJavaType( + val name: String, + override val extra: PropertyContainer<PrimitiveJavaType> = PropertyContainer.empty() +) : Bound(), AnnotationTarget, WithExtraProperties<PrimitiveJavaType> { + override fun withNewExtras(newExtras: PropertyContainer<PrimitiveJavaType>): PrimitiveJavaType = + copy(extra = newExtras) +} + +data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : + Bound(), AnnotationTarget, WithExtraProperties<JavaObject> { + override fun withNewExtras(newExtras: PropertyContainer<JavaObject>): JavaObject = + copy(extra = newExtras) +} + +data class UnresolvedBound( + val name: String, + override val extra: PropertyContainer<UnresolvedBound> = PropertyContainer.empty() +) : Bound(), AnnotationTarget, WithExtraProperties<UnresolvedBound> { + override fun withNewExtras(newExtras: PropertyContainer<UnresolvedBound>): UnresolvedBound = + copy(extra = newExtras) +} + +// The following Projections are not AnnotationTargets; they cannot be annotated. data class Nullable(val inner: Bound) : Bound() sealed class Variance<out T : Bound> : Projection() { @@ -444,19 +475,10 @@ data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { override fun toString() = "" } -data class TypeAliased(val typeAlias: Bound, val inner: Bound) : Bound() -data class PrimitiveJavaType(val name: String) : Bound() +object Star : Projection() object Void : Bound() - -data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : Bound(), - WithExtraProperties<JavaObject> { - override fun withNewExtras(newExtras: PropertyContainer<JavaObject>): JavaObject = - copy(extra = newExtras) -} - object Dynamic : Bound() -data class UnresolvedBound(val name: String) : Bound() fun Variance<TypeParameter>.withDri(dri: DRI) = when (this) { is Contravariance -> Contravariance(TypeParameter(dri, inner.name, inner.presentableName)) |