scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Change Scala 2 compiler to accept `using` in argument clauses

Open odersky opened this issue 3 years ago • 2 comments

We need to make progress on the translation of context bounds. A context bound currently translates to an implicit evidence parameter, but it should be a using clause. The best way to change this would be.

  1. A deprecation phase, where we warn when an implicit parameter stemming from a context bound is instantiated with an explicitly passed, plain (non-using) argument. We should also have an option to rewrite this automatically.

  2. After that, a change to the new behavior.

To make the deprecation phase compatible with the need to cross compile with Scala 2, we need to change the Scala 2 compiler to accept using clauses. See https://github.com/lampepfl/dotty/pull/15549#issuecomment-1170212699 for similar changes.

odersky avatar Jun 29 '22 17:06 odersky

As a warm-up, I'll take a quick swing at this by choking up on the bat.

This is just to accept f(using x) without further checks.

Edit: I see the issue is on dotty repo.

Edit: idly wondering if it currently says: Did you mean Using?

Edit: sadly, it does not suggest, Did you mean Using?

som-snytt avatar Jun 29 '22 17:06 som-snytt

The referenced PR is merged on Scala 2.

som-snytt avatar Jul 29 '22 02:07 som-snytt

To follow up, "choking up on the bat" in American baseball just means holding the "bat" that is used to strike the ball a bit further up the shaft, thereby enabling a quicker swing that may also be more precise and effective.

som-snytt avatar Dec 02 '22 16:12 som-snytt