Skip to content

Fix NoSymbol extractor #6843

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.

type NoSymbol = core.Symbols.NoSymbol.type

def matchNoSymbol(symbol: Symbol)(implicit ctx: Context): Boolean = symbol ne core.Symbols.NoSymbol
def matchNoSymbol(symbol: Symbol)(implicit ctx: Context): Boolean = symbol eq core.Symbols.NoSymbol

//
// FLAGS
Expand Down
19 changes: 19 additions & 0 deletions tests/run-macros/no-symbol/1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import scala.quoted._
import scala.deriving._

case class Foo(i: Int)
case class Box[A](x: A)

object Macro {
inline def foo[T](implicit inline t: Type[T]): String =
${ fooImpl }

def fooImpl[T](implicit t: Type[T], q: QuoteContext): Expr[String] = {
import q.tasty._
t.unseal.symbol match {
case IsClassDefSymbol(self) => '{ "symbol" }
case NoSymbol() => '{ "no symbol" }
case _ => '{ "match error" }
}
}
}
6 changes: 6 additions & 0 deletions tests/run-macros/no-symbol/2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {
def main(args: Array[String]): Unit = {
assert(Macro.foo[Foo] == "symbol")
assert(Macro.foo[Box] == "no symbol")
}
}