Skip to content

Fix #4382: Disallow wildcard arguments for higher-kinded types #4423

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

Merged
merged 4 commits into from
May 1, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 30, 2018

This needed some follow-on work on how we encode Eq for enums, which could still be improved once we have typeclass derivation.

odersky added 4 commits April 30, 2018 20:35
Use typr printer instead.
…ents

Four existing test cases had to be reclassified to require -language:Scala2.
This previous encoding used a higher-kinded type applied to a wildcard argument,
which is no longer supported. The new encoding is a temporary fix. To get it right,
it's best if we can base it on the future typeclass derivation mechanism.
I don't have a test, but it makes more sense this way.
@odersky
Copy link
Contributor Author

odersky commented Apr 30, 2018

@Blaisorblade Between #4423 and #4422 that makes a co-ordinated swatting of wildcards. Great to have this!

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

@@ -366,6 +366,12 @@ object desugar {
(if (args.isEmpty) tycon else AppliedTypeTree(tycon, args))
.withPos(cdef.pos.startPos)

def isHK(tparam: Tree): Boolean = tparam match {
case TypeDef(_, LambdaTypeTree(tparams, body)) => true
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that's enough in general, e.g. enum Foo[F <: [X] => Any], but maybe we're ok with that since that's only a temporary solution.

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, I think the right solution cannot be done at Desugar, it needs full type information.

@odersky odersky merged commit 1c79982 into scala:master May 1, 2018
@allanrenucci allanrenucci deleted the fix-#4382 branch May 1, 2018 08:20
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.

2 participants