-
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
Problem with Type of Tuple.map
(was: type inference regression)
#15992
Comments
I think we'll need a bisect on this one |
Bisect points to 46e3d77 |
Minimized: def widen[T](x: T): T = x
def f[T <: Tuple](t: T): Unit =
val tl: Tuple.Map[T, List] = widen(t).map([X] => (x: X) => List(x)) |
I think the new behavior is correct, unfortunately.
Previous to 46e3d77 the approximation logic had holes, that's why this case was overlooked. 46e3d77 was done to fix weird error messages but we see here that it fixes a soundness problem as well. |
I use Specifically, without the val tl: Tuple.Map[T, List] = t.map([X] => (x: X) => List(x))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Found: <root>.this.scala.Tuple.Map[(t : T), List]
Required: <root>.this.scala.Tuple.Map[T, scala.this.package.List]
where: T is a type in method f with bounds <: <root>.this.scala.Tuple which is expected behavior too? It's very hard to do anything nontrivial with the new |
After digging deeper it looks like a fundamental problem with Tuple.map to me, which was only hidden by a hole in asSeenFrom. To recap: t.map([X] => (x: X) => List(x)) is of type
(t: T).map([X] => (x: X) => List(x)) (which is essentially what Tuple.Map[?1: T, List] The problem seems to be that /** Called on a tuple `(a1, ..., an)`, returns a new tuple `(f(a1), ..., f(an))`.
* The result is typed as `(F[A1], ..., F[An])` if the tuple type is fully known.
* If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
* to be the cons type.
*/
inline def map[F[_]](f: [t] => t => F[t]): Map[this.type, F] =
runtime.Tuples.map(this, f).asInstanceOf[Map[this.type, F]] So the result is Also the doc comment is ill-formed and incomplete, so that needs to be fixed as well. |
Tuple.map
(was: type inference regression)
@anatoliykmetyuk Is your fix complete? Is there a reason why it wasn't put into a pr? |
This provides a way forward to fixing the signatures of some tuple methods, and removes the inlining from the tuple methods. Optimization will be implemented later directly on these method calls, which avoids unnecessary complications due to inlining artifacts. Old definitions are made tasty compatible and just delegate to the new representation. Fixes scala#12721 Fixes scala#15992 Fixes scala#16207
This provides a way forward to fixing the signatures of some tuple methods, and removes the inlining from the tuple methods. Optimization will be implemented later directly on these method calls, which avoids unnecessary complications due to inlining artifacts. Old definitions are made tasty compatible and just delegate to the new representation. Fixes scala#12721 Fixes scala#15992 Fixes scala#16207
This provides a way forward to fixing the signatures of some tuple methods, and removes the inlining from the tuple methods. Optimization will be implemented later directly on these method calls, which avoids unnecessary complications due to inlining artifacts. Old definitions are made tasty compatible and just delegate to the new representation. Fixes scala#12721 Fixes scala#15992 Fixes scala#16207
It seems we've fixed int in 3.5.0. |
Fixed in #19954 - not yet sure if it would be back portable, it seems to depend on the Scala 3.4 match type changes. |
The fix cannot be backported to the LTS - it does course regressions, probably due to missing PR backports and what's important it does not fix this issue. I'm closing this issue as there is nothing more we can do in the LTS line and it's already fixed in the Next line |
Compiler version
Works fine in 3.2.0, fails in 3.2.1-RC1-bin-20220904-b5fea82-NIGHTLY
Minimized code
Output
Expectation
Work as defined in 3.2.0.
The text was updated successfully, but these errors were encountered: