Skip to content
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

Encode variances in parameter names #2103

Closed
wants to merge 5 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 14, 2017

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.

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.
@DarkDimius
Copy link
Contributor

DarkDimius commented Mar 14, 2017

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)
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: kidned -> kinded

It was a red herring. Symbolic names are expanded anyway to $plus / $minus,
so they can't be confused with a variance prefix.
@odersky odersky mentioned this pull request Mar 19, 2017
@odersky
Copy link
Contributor Author

odersky commented Apr 6, 2017

Superseded by #2121

@odersky odersky closed this Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants