TL&DR: Is it possible to (locally?) disable path-dependent typing? I'd like to issue a single import statement similar to import x._, but to make C refer to X#C rather than x.C (X being the type of x)?
I have a bunch of types:
class Button[M] { ... }
class Label[M] { ... }
...
And I happen to use them together passing the same type argument to all of them:
class UseSite[M] (
btn1 : Button[M]
, btn2 : Button[M]
, lbl1 : Label[M]) {
...
}
I thought that it'd be nice to package all those types up so that I only need to pass the type parameter once:
class Swing[M] {
class Button { ... }
class Label { ...}
}
Then on the use site I'd like to be able to do this:
class WithSwing[M] {
val swing = new Swing[M]
import swing._
class UseSite(
btn1 : Button
, btn2 : Button
, lbl1 : Label) {
...
}
}
However, this does not work properly because of path-dependent typing: Button refers to swing.Button instead of Swing[M]#Button so the external code has a very hard time passing the correct arguments to the UseSite constructor.
Is there a nice way to make Button refer to Swing[M]#Button rather than to swing.Button?
One might imagine something like
to bring all the type members of type
Swing[M]into scope, but this doesn't exist (importexpects a value, not a type). For practical purposes, how about a type alias to reduce boiler-plate,