Scala 2 regression: F-bounds + wildcard
See original GitHub issueCompiler version
- 3.0.0
- 3.0.1
- 3.0.2-RC1
Minimized code
object Blah {
trait DomZipper[F[_], X, A, Self[G[_], B] <: DomZipper[G, X, B, Self]]
def apply[Fast[f[_], a] <: DomZipper[f, _, a, Fast]] = () // error
}
object Blah1 {
trait DomZipper[X, A, Self[B] <: DomZipper[X, B, Self]]
def apply[Fast[a] <: DomZipper[_, a, Fast]] = () // error
}
object Blah2 {
trait DomZipper[F[_], X, Self[G[_]] <: DomZipper[G, X, Self]]
def apply[Fast[f[_]] <: DomZipper[f, _, Fast]] = () // error
def apply1[Fast[f[_]] <: DomZipper[f, _, Fast]] = () // error
}
object Blah3 {
trait DomZipper[F[_], Self[G[_]] <: DomZipper[G, Self]]
def apply[Fast[f[_]] <: DomZipper[f, Fast]] = () // ok
}
object Blah4 {
trait DomZipper[Self <: DomZipper[Self]]
def apply[Fast <: DomZipper[Fast]] = () // ok
}
object Blah5 {
trait DomZipper[F[_], A, Self[G[_], B] <: DomZipper[G, B, Self]]
def apply[Fast[f[_], a] <: DomZipper[f, a, Fast]] = () // ok
}
object Blah6 {
trait DomZipper[F[_], X, A, Self[G[_], B] <: DomZipper[G, X, B, Self]]
def apply[Fast[f[_], a] <: DomZipper[f, X, a, Fast], X] = () // ok
}
Output
[error] -- [E057] Type Mismatch Error: a.scala:3:48
[error] 3 | def apply[Fast[f[_], a] <: DomZipper[f, _, a, Fast]] = () // error
[error] | ^
[error] |Type argument Fast does not conform to upper bound [G[_$2], B] =>> Blah.DomZipper[G, Blah.DomZipper[f, ?, a, Fast]#X, B, Fast]
[error] -- [E057] Type Mismatch Error: a.scala:8:39
[error] 8 | def apply[Fast[a] <: DomZipper[_, a, Fast]] = () // error
[error] | ^
[error] |Type argument Fast does not conform to upper bound [B] =>> Blah1.DomZipper[Blah1.DomZipper[?, a, Fast]#X, B, Fast]
[error] -- [E057] Type Mismatch Error: a.scala:13:42
[error] 13 | def apply[Fast[f[_]] <: DomZipper[f, _, Fast]] = () // error
[error] | ^
[error] |Type argument Fast does not conform to upper bound [G[_$5]] =>> Blah2.DomZipper[G, Blah2.DomZipper[f, ?, Fast]#X, Fast]
[error] -- [E057] Type Mismatch Error: a.scala:15:43
[error] 15 | def apply1[Fast[f[_]] <: DomZipper[f, _, Fast]] = () // error
[error] | ^
[error] |Type argument Fast does not conform to upper bound [G[_$5]] =>> Blah2.DomZipper[G, Blah2.DomZipper[f, ?, Fast]#X, Fast]
[error] four errors found
Expectation
Compiles with Scala 2.12 and 2.13.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Regression in Scala 2.13.7 - cannot use wildcard for F- ...
Regression in Scala 2.13.7 - cannot use wildcard for F-bounded type ... [_$2] do not conform to trait Universe's type parameter bounds [T ......
Read more >Scala 3.0.1-RC2 – backports of critical bugfixes - EPFL
1. The reason for this release is that a regression with respect to 3.0.0 was introduced by PR #12519 which caused the compiler...
Read more >Generics and Wildcards in Java - Level Up Coding
This is as flexible as the Java method with type bounds because, in Scala, List is covariant and functions are covariant in their...
Read more >Scala list of any and list of something extending ...
2. Any is a symptom of bad design · 1. @user You can. · 1. @cchantep Generally yes, but for covariant F ,...
Read more >A Beginner's Guide to Scala, Object Orientation and ...
2. 1.4 Java to Scala Quick Comparison . ... 28.5 Lower and Upper Bounds. ... Also note that if you are a Java...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not going to fix all the f-bounds issues sorry 😃.
It’s a missing capture conversion. The error message is
Essentially it needs to argue that for each version of
Fast
there is one specific first argument ofX
. I am not even sure this is true. Scala 2 handles these wildcards differently and in ways where we know that there are soundness problems. The example is too complex for me to figure out whether this should be sound or not. So I don’t think I can help here. If someone else wants to step in, please re-open as needed.