Skip to content
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

fix scala 2 macros in traits with type parameters #18663

Merged
merged 1 commit into from
Oct 12, 2023
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ object SymDenotations {

/** Is this a Scala 2 macro defined */
final def isScala2MacroInScala3(using Context): Boolean =
is(Macro, butNot = Inline) && is(Erased)
is(Macro, butNot = Inline) && flagsUNSAFE.is(Erased) // flag is set initially for macros - we check if it's a scala 2 macro before completing the type constructor so do not force the info to check the flag
// Consider the macros of StringContext as plain Scala 2 macros when
// compiling the standard library with Dotty.
// This should be removed on Scala 3.x
Expand Down
14 changes: 14 additions & 0 deletions tests/pos-macros/i16630.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import scala.language.experimental.macros
import scala.quoted.{Quotes, Expr, Type}

trait TraitWithTypeParam[A]:
inline def foo: Option[A] = ${ MacrosImpl.fooImpl[A] }
def foo: Option[A] = macro MacrosImpl.compatFooImpl[A]

object MacrosImpl:
def fooImpl[A: Type](using quotes: Quotes): Expr[Option[A]] = ???
def compatFooImpl[A: c.WeakTypeTag](c: Context): c.Tree = ???

trait Context:
type WeakTypeTag[A]
type Tree
Loading