Skip to content

Fix #8067: Don't constrain with types of wrong kinds #8130

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 31 commits into from
Jan 31, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 29, 2020

The example got into a pickle since it tried to constrain a type variable
A[_] with a type (G[_] => G[String]). It should have rejected this outright since
A if of kind * -> * and the bound is of kind (* -> *) -> *.

Instead the constraint addition succeeded and the compiler got into a dead-end
with it afterwards.

Based on #8082. Only last two commits are new.

 + refactoring: account for Bivariance
 + refactpring: collect variance related ops in Variances,
   move Variances to core.
This is meant as a better alternative to encode variances in parameter names.
Encode them instead in the upper bound lambda of a TypeBounds type.

For now, we also encode them in the alias of a Typealias type, but
this will be dropped one we pass to structural lambda variance.
The old encoding using semantic parameter name is still in place. The
new recording inside TypeBounds exists alongside the old one.
Needs to be passed as a parameter since Namer does not construct
a bounds immediately.
These can hopefully be revived once the variance changes have completed
... unless they are on the right hand side of type bounds or
match aliases or they are type aliases where some variance is
given explicitly with a `+` or `-`.
Type lambdas don't print with variances anymore
Since variances are associated conceptually with higher-kinded type variables,
it makes no sense to write them on type lambdas. I believe it's better to disallow
writing variances there because it will only need to variance-bike-shedding otherwise.
A refinement type would previously qualify as an `isRef` of
Any, AnyKind, or AnyRef. Often that is not what was intended.
Break out `isAny`, `isAnyKind`, and `isAnyRef` methods for
tests that don't go through refinements.
The example got into a pickle since it tried to constrain a type variable
A[_] with a type (G[_] => G[String]). It should have rejected this outright.
Instead the constraint addition succeeded and the compiler got into a dead-end
with it afterwards.
make it work for al kinds of ParamInfos.
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

 - Need to take of AnyKind
 - need to also copmare results
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.

Last three commits LGTM, so this PR is good to go once #8082 gets in.

@odersky odersky merged commit bbd0c5f into scala:master Jan 31, 2020
@odersky odersky deleted the fix-#8067 branch January 31, 2020 14:53
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