-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Encode variances in parameter names #2103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This leads to a slight overall simplification, harmonizes pickle format with internal representation, and makes MethodTypes and PolyTypes more similar to each other. I believe the change is useful as it is, but in particular it is a useful step for an eventual unification of MethodTypes and PolyTypes.
That's a very nice simplification! |
@@ -241,6 +241,12 @@ object desugar { | |||
* class C { type v C$T; type v T = C$T } | |||
*/ | |||
def typeDef(tdef: TypeDef)(implicit ctx: Context): Tree = { | |||
val name = | |||
if (tdef.name.hasVariance && tdef.mods.is(Param)) { | |||
ctx.error(em"type parameter name may not start with `+' or `-'", tdef.pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even allowed by the parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ++, -- are legal parameter names.
class PolyType(val paramNames: List[TypeName], val variances: List[Int])( | ||
/** A type lambda of the form `[X_0 B_0, ..., X_n B_n] => T` | ||
* This is used both as a type of a polymorphic method and as a type of | ||
* a higher-kidned type parameter. Variances are encoded in parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: kidned -> kinded
and fix typo
It was a red herring. Symbolic names are expanded anyway to $plus / $minus, so they can't be confused with a variance prefix.
Superseded by #2121 |
This leads to a slight overall simplification, harmonizes pickle
format with internal representation, and makes MethodTypes and
PolyTypes more similar to each other.
I believe the change is useful as it is, but in particular it is
a useful step for an eventual unification of MethodTypes and
PolyTypes.