-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Apologies if I'm doing something stupid but I think this code should work?
Dotty version is 0.25.0-bin-20200516-9450bf2-NIGHTLY
.
Minimized code
// Show.scala
trait Show[T] {
def show(t: T): String
}
object Show {
inline def deriveWithMacro[T]: Show[T] = ${ impl[T] }
import quoted._
def impl[T](using ctx: QuoteContext, tpe: Type[T]): Expr[Show[T]] =
'{
new Show[$tpe] {
def show(t: $tpe): String = "TODO"
}
}
}
// Foo.scala
case class Foo(x: String)
object Bar {
println(Show.deriveWithMacro[Foo].show(Foo("")))
}
Output
[error] 4 | println(Show.deriveWithMacro[Foo].show(Foo("")))
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^
[error] | object creation impossible, since def show(t: T): String is not defined
[error] | (Note that T does not match Foo)
[error] | This location contains code that was inlined from Show.scala:13
[error] | This location contains code that was inlined from Show.scala:13
[error] one error found
[error] (muService / Compile / compileIncremental) Compilation failed
Expectation
No compile error, prints TODO