-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and spliceshow-i-fixed-ititype:bug
Milestone
Description
Compiler version
3.0.1-RC1
Minimized code
MainMacro.scala
import scala.quoted.*
case class Wrapper[T](t: T) extends MainMacro[T]
trait MainMacro[U] { this: Wrapper[U] =>
inline def showTypeRepr: String = ${ MainMacro.showTypeReprImpl[U]}
}
object MainMacro {
def showTypeReprImpl[U: Type](using Quotes): Expr[String] = {
import quotes.reflect.*
val tpe = TypeRepr.of[U]
Expr(tpe.toString)
}
}
Test1.scala
object TestData {
case class Person(name: String, age: Int)
}
class Test1 {
import TestData.*
// Notice that without inline does not work also
inline def in(fun: => Any): Any = fun
in {
Wrapper(Person("a", 1)).showTypeRepr
}
}
Output
$ mkdir classes
$ scalac -3.0.2-RC1 -d classes MainMacro.scala
$ scalac -3.0.2-RC1 -d classes -cp classes Test1.scala
-- Error: Test1.scala:13:28 ----------------------------------------------------
13 | Wrapper(Person("a", 1)).showTypeRepr
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Cannot call macro class Person defined in the same source file
| This location contains code that was inlined from Test1.scala:13
1 error found
Expectation
It should compile, I guess.
adamw, kitlangton and ChouUn
Metadata
Metadata
Assignees
Labels
area:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and spliceshow-i-fixed-ititype:bug