-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Match Type producing a List in all cases is not always recognized as List but as IterableOnce #11729
Comments
The issue is that the compiler keeps Return's type variable around for too long, you can fix it by specifying it ( |
ah, so I guess we end up with |
I have a similar example, looks like a similar issue Codetype Boxed[X] = X match
case Box[t] => Box[t]
case Any => Box[X]
def box[X](x: X): Boxed[X] = x match
case b: Box[t] => b
case x: Any => Box(x)
case class Box[A](a:A):
def map[B](f: A => B): Box[B] = Box(f(a))
object Test:
box(box(1)).map(_ + 1) Output
Expected outputThe following snippet does work, so I expect the above to behave the same object Test:
box(1).map(_ + 1)
val b = box(1)
val bb = box(b)
bb.map(_ + 1) when I modify the match type declaration to: type Boxed[X] <: Box[?] = X match
case Box[t] => Box[t]
case Any => Box[X] the line box(1).map(_ + 1) gives the error
|
Fix scala#9769 Fix scala#9833 Fix scala#10389 Fix scala#10897 Fix scala#11163 Fix scala#11556 Fix scala#12474 Fix scala#10994 Fix scala#11729
Compiler version 3.0.0-RC1
Minimized code
Output
Expectation
This should work. the same way as
The text was updated successfully, but these errors were encountered: