-
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
Support contextual dependent extensions #9530
Comments
Here's the second example if we write-out the extension method and given: trait Scope:
type Expr
object test:
given G(using s: Scope) as AnyRef:
extension (expr: s.Expr)
def show = "expr"
def f(using s: Scope)(expr: s.Expr) =
G(using s).extension_show(expr) This will give the following error:
Why becomes clear when we look at the expansion after typer: result of ../new/test.scala after typer:
package <empty> {
trait Scope() extends Object {
type Expr >: Nothing <: Any
}
final lazy module val test: test$ = new test$()
final module class test$() extends Object(), _root_.scala.Serializable {
this: test.type =>
class G(using s: Scope) extends AnyRef() {
protected given val s: Scope
extension (expr: G.this.s.Expr) def show: String = "expr"
}
final given def G(using s: Scope): test.G = new test.G()(using s)
def f(using s: Scope)(expr: s.Expr): String =
test.G(using s).extension_show(expr)
}
} The given def only knows that it returns a |
Closed
Scala3doc is using these kinds of extensions. To support it we have to make some complex workarounds. |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Dec 28, 2020
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Dec 31, 2020
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 1, 2021
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 4, 2021
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 5, 2021
nicolasstucki
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Jan 5, 2021
nicolasstucki
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Jan 5, 2021
nicolasstucki
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Jan 5, 2021
nicolasstucki
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Jan 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minimized example
We should support
or the less performant
Expectation
One of those should be supported to be able to encode
which does work and has several use cases.
The text was updated successfully, but these errors were encountered: