-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5976: Don't assume T <:< (=>T)
.
#5981
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
It's incorrect to assume `T <:< => T` since, taken as parameters, the erasure of the two types is different: `|T|` vs `Function1`. To compenate, we need to `widenExpr` in various places.
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.
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:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Add" instead of "Added")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
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.
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:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Add" instead of "Added")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
Align lub/glb with the changes to subtyping.
@@ -603,7 +603,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic => | |||
* argument trees. | |||
*/ | |||
class ApplicableToTreesDirectly(methRef: TermRef, targs: List[Type], args: List[Tree], resultType: Type)(implicit ctx: Context) extends ApplicableToTrees(methRef, targs, args, resultType)(ctx) { | |||
override def argOK(arg: TypedArg, formal: Type): Boolean = argType(arg, formal) <:< formal | |||
override def argOK(arg: TypedArg, formal: Type): Boolean = argType(arg, formal) <:< formal.widenExpr |
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.
Do we have some guarantee that the result of argType
cannot be an ExprType here ? Even if we do, it seems more regular to widen both sides.
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.
The case we dropped in TypeComparer is where the RHS is an ExprType. => T
was never a subtype of T
.
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.
Right, but if both argType
and formal
are => T
, then argOK
used to return true but will return false now that we widen formal
.
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.
I see. I believe argTypes are never ExprTypes. They might be TermRefs with an underlying ExprType. But we skip the ExprType when we do a widen on these. lub
also does widen
, not widenExpr
. So I think we are good.
@@ -98,7 +98,7 @@ object Implicits { | |||
else if (mt.paramInfos.lengthCompare(1) == 0 && { | |||
var formal = widenSingleton(mt.paramInfos.head) | |||
if (approx) formal = wildApprox(formal) | |||
ctx.test(implicit ctx => argType relaxed_<:< formal) | |||
ctx.test(implicit ctx => argType relaxed_<:< formal.widenExpr) |
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.
Same question here.
I'm wondering if we should introduce a |
I had a look at it. We have 8 occurrences of the pattern |
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.
I'd still be in favor of having widened_<:<
and widenedFrozen_<:<
, but I guess we can always go that route later if we find more cases where widening is needed.
It's incorrect to assume
T <:< (=> T)
since, taken as parameters,the erasure of the two types is different:
|T|
vsFunction1
.To compenate, we need to
widenExpr
in various places.