scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Import given #12999

Closed som-snytt closed 3 weeks ago

som-snytt commented 1 month ago

Reproduction steps

Scala version: 2.13.14

under -Xsource:3-cross, import ExecutionContext.Implicits.given is ignored rather than taken as *.

Problem

If cross-compiling, I don't want *, even if scala 2 must approximate given.

Also, it would probably be easy to just make given actually work in imports.

SethTisue commented 1 month ago

I don't understand why simply ignoring the import should be considered wrong?

eed3si9n commented 1 month ago

The semantics of import ExecutionContext.Implicits.given in Scala 3 is that it imports the implicits into the scope, so I guess you might consider treating it as import ExecutionContext.Implicits._ to match the energy?

som-snytt commented 1 month ago

Yes, for cross compiling, I think at least take given as star; with the caveat of course that it mustn't break imports, import x.{given, *} must not introduce ambiguities.

If I were cross compiling, I would not want to write Implicits.{given, *} for dotty.

som-snytt commented 1 month ago

reminder

import-given.scala:13: error: value given is not a member of object T
  import T.given

and under -Xsource:3

import-given.scala:14: error: given requires a wildcard selector
  import T.{foo, given}