Skip to content

Commit bafb0d8

Browse files
Merge pull request #9986 from dotty-staging/handle-string-context-intrinsic-macro-definitions
Handle StringContext intrinsic macro definitions compiled with Dotty
2 parents 2f5b5fd + 292d964 commit bafb0d8

File tree

2 files changed

+497
-1
lines changed

2 files changed

+497
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,15 @@ class TreeUnpickler(reader: TastyReader,
584584
if sym.isOpaqueAlias then sym.setFlag(Deferred)
585585
val isScala2MacroDefinedInScala3 = flags.is(Macro, butNot = Inline) && flags.is(Erased)
586586
ctx.owner match {
587-
case cls: ClassSymbol if !isScala2MacroDefinedInScala3 => cls.enter(sym)
587+
case cls: ClassSymbol if !isScala2MacroDefinedInScala3 || cls == defn.StringContextClass =>
588+
// Enter all members of classes that are not Scala 2 macros.
589+
//
590+
// For `StringContext`, enter `s`, `f` and `raw`
591+
// These definitions will be entered when defined in Scala 2. It is fine to enter them
592+
// as they are intrinsic macros and are specially handled by the compiler.
593+
// Dual macro definitions will not work on `StringContext` as we would enter the symbol twice.
594+
// But dual macros will never be needed for those definitions due to their intinsic nature.
595+
cls.enter(sym)
588596
case _ =>
589597
}
590598
registerSym(start, sym)

0 commit comments

Comments
 (0)