Dotty: Support implicitNotFound on parameters, like Scala 2.13.0-M5

Created on 22 Aug 2018  路  3Comments  路  Source: lampepfl/dotty

typer scala2 help wanted enhancement low

Most helpful comment

Trying to tackle that right now!

All 3 comments

Trying to tackle that right now!

How should this be handled with dotty's using syntax?
Instead of the old style

def foo(implicit @implicitNotFound("custom error") bar: Bar)

we can straightforwardly get

def foo(using @implicitNotFound("custom error") bar: Bar)

but what if we wanted to skip the name of the implicit parameter?
Should we then annotate the type itself instead, like

def foo(using Bar @implicitNotFound("custom error"))

?
If yes, then should we align the syntax with the parameter name to the one without it, like

def foo(using bar: Bar @implicitNotFound("custom error"))

?
Or should we require that the parameter name is always present when the annotation is used?

Also, as we would like to get rid of implicit keyword by replacing it with givens and usings, should the annotation be renamed to something like givenNotFound? That could be also just an alias.
@smarter @odersky

Should we then annotate the type itself instead, like

Putting the annotation on the type would make sense, but it means that the annotation leaks into error messages which involve the type of this parameter, it might be possible to tweak error message reporting to avoid that; I think we should support both but for an initial PR it's fine to just support what scalac supports.

Also, as we would like to get rid of implicit keyword by replacing it with givens and usings, should the annotation be renamed to something like givenNotFound? That could be also just an alias.

Yes probably, but this isn't the only reference to "implicit" in the standard library. I suggest leaving the names alone for now and we can discuss how they should be updated in 3.1 when we update the standard library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcku picture mcku  路  3Comments

dwijnand picture dwijnand  路  3Comments

fommil picture fommil  路  3Comments

milessabin picture milessabin  路  3Comments

adamgfraser picture adamgfraser  路  3Comments