Closed
Description
Compiler version
3.6.2
Minimized code
inline val msg: String = "abc"
trait E[T]
def f(using @annotation.implicitNotFound(msg) e: E[Int]): Unit = ()
@main def hello(): Unit = f
Output
[error] -- [E172] Type Error: Main.scala:5:27
[error] 5 |@main def hello(): Unit = f
[error] | ^
[error] | No given instance of type E[Int] was found for parameter e of method f
Expectation
The error No given instance of type E[Int] was found for parameter e of method f
is the default one that was supposed to be customized to abc
. The reason this happens is the : String
type annotation.
If you just do inline val msg = "abc"
then it will work as expected:
[error] -- [E172] Type Error: Main.scala:5:27
[error] 5 |@main def hello(): Unit = f
[error] | ^
[error] | abc
inline val msg = "abc"
worksinline val msg = "ab" + "c"
worksinline val msg: String = "abc"
does not work (!)inline val msg = "cba".reverse
does not work