Open lihaoyi opened 4 years ago
It's unlikely this will be fixed before Scala 3. I would be surprised if this is the first issue on this, I've encountered this weird rule many times: basically, in Scala 2, objects are part of their own implicit scope, but the same does not apply to val
s. shapeless
tells users to implement shapeless.Poly
as objects, not vals because of this limitation
Hmm that is interesting. I was reading the spec a bit closer.
if π is a type projection π#π, the parts of π as well as π itself;
If we consider f.Bar =:= f.type#Bar
then that would include f.type
and Bar
if π is a singleton type π.type, the parts of the type of π;
But the type of f: Foo
which would mean Foo#Qux
and not f.Qux
.
Notice how we lost the path dependent type when we widened f
.
How does dotty handle this?
Example in 2.13.1:
I would expect both examples to compile, but only the first one with
object f extends Foo
compiles while the second one withf: Foo
as a parameter fails. @smarter says that this works in Dotty, so I assume it's a bug in the Scala 2 compiler.Moving the implicit conv into the a companion object of Qux makes it get discovered in either case, but that doesn't work for me because the companion object is final and I need to override it in different subclasses of Foo (hence this whole trait thing in the first place)
I bumped into this trying to move all Scalatags implicits into the default implicit scope, to remove the need for wholesale
import module._
statements and improve the tidyness of local scope.Scalatags uses this module-as-function-parameter pattern to allow sharing HTML templates between a generating textual
String
s, modules generating livedom.Element
s in the browser via Scala.js, and a module generatingscalatags.VirtualDom
elements of arbitrary types (e.g. React nodes, Preact nodes) on either Scala-JVM and Scala.js.