You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 1.0, our TypeName modeling is largely based on JavaPoet's. This mostly works, but falls short in some ways that don't map well onto Kotlin's own semantics.
Problems:
WildcardTypeName extends TypeName, whereas Kotlin offers KTypeProjection and it is not a subtype
TypeName is currently sealed, but KType is not and I think it's clear they want to keep the option open
There is currently no support for intersection types
ParameterizedTypeName extends TypeName, but Kotlin doesn't differentiate these. KType contains a classifier and arguments.
Semantics do not currently line up
Proposal:
Replace WildcardTypeName with a projection type that does not extend TypeName.
class `KpTypeProjection(val variance:KModifier?, val type:TypeName?)`
Model TypeName more like KType, inline away ParameterizedTypeName.
interfaceKpType {
val classifier:KpClassifier// KpClass or KpTypeParameterval arguments:List<KpTypeProjection>
val isMarkedNullable:Boolean
}
Introduce IntersectionTypeName for intersection types. This should also cover definitely non-nullable types
Introduce upperBounds to KpTypeParameter, allowing support for intersection types
Introduce KType.makeNotNull(), which returns a special-case KpType that adds this extra notation. This matches how Kotlin handles it internally, as it's just a flag on the proto.
(WIP, not ready for review yet)
In 1.0, our
TypeName
modeling is largely based on JavaPoet's. This mostly works, but falls short in some ways that don't map well onto Kotlin's own semantics.Problems:
WildcardTypeName
extendsTypeName
, whereas Kotlin offersKTypeProjection
and it is not a subtypeTypeName
is currentlysealed
, butKType
is not and I think it's clear they want to keep the option openParameterizedTypeName
extendsTypeName
, but Kotlin doesn't differentiate these. KType contains a classifier and arguments.Proposal:
WildcardTypeName
with a projection type that does not extendTypeName
.TypeName
more likeKType
, inline awayParameterizedTypeName
.IntroduceIntersectionTypeName
for intersection types. This should also cover definitely non-nullable typesupperBounds
toKpTypeParameter
, allowing support for intersection typesKType.makeNotNull()
, which returns a special-caseKpType
that adds this extra notation. This matches how Kotlin handles it internally, as it's just a flag on the proto.TypeName
no longer sealed.Then common types could be implemented as such
KpClass
Generics
Intersection types
The text was updated successfully, but these errors were encountered: