-
Notifications
You must be signed in to change notification settings - Fork 21
Wildcards should infer bounds #11491
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
Comments
I ran into this while upgrading Slick, too. The code is not correct in the first place. The bounds in the return type of Previously the compiler ignored the bad bounds and everything worked fine but now they leak into type inference and get reported as errors. The underlying bug in my opinion is that the return type of |
I disagree. If |
Given |
In fact, being able to write |
There have been previous attempts in this area. This looks like a good thread to pull: scala/scala#3471. For Scala 3 cross-building, it would be good to implement the same logic as dotty, but this is not exactly trivial, nor a blocker for 2.13.0. |
Duplicate of #1786 |
I agree that #1786 is indeed very similar to this issue. But keep in mind that the code example from this issue DOES compile in scala 2.11 and 2.12. I think that it is very likely that other will encounter this issue when upgrading from scala 2.12 to 2.13. Also this issue had the milestone 2.13.1, shouldn't #1786 receive the same milestone as it is considered a duplicate? |
We’ll investigate if a fix is feasible for 2.13.1, so I’ll reopen this for the more limited scope of the problem. This regressed due to a fix for another more insidious problem due to the way this was originally implemented (type var inheriting constraints from its origin type param) |
|
I assume (actually not sure anymore) this is why it regressed: scala/scala#6789 |
So we have a puzzle of making sure #10819 and this both do not regress: scala> def id[T <: AnyVal](x: T): T = x
id: [T <: AnyVal](x: T)T
scala> id(1 + 1) - 1
res0: Int = 1 |
hmm, also seems related to #11480 |
moved to Backlog, as the linked PRs seem to have stalled |
on Gitter @er1c reports that the following compiles on 2.11, 2.12, and Dotty, but not on 2.13: def foo[T]: Set[Class[_ <: T]] = bar(??? : Class[T])
def bar[T](clazz: Class[T]): Set[Class[_ <: T]] = ??? I'm not certain it's actually the “same” problem, but it's at least in that same territory where type inference, bounds, and existentials overlap the workaround is to give inference a little extra help: |
might scala/scala3#8955 be related? |
well, overloads aren't in play in this ticket |
I don't know what I was thinking. I swear it made sense when I posted it! |
The following code compiles on scala 2.12.8, but it does not compile on scala 2.13.0-RC1
This fails with the following errors
Oddly enough the code does compile when changing the body of
def test
toIt appears that this somehow changes the inferred types which makes it typecheck again...
The text was updated successfully, but these errors were encountered: