File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,18 @@ trait ArgsMacros {
64
64
}
65
65
66
66
object Util {
67
- def isSynthetic (using Quotes )(s : quotes.reflect.Symbol ) = isSyntheticName(getName(s))
67
+ def isSynthetic (using Quotes )(s : quotes.reflect.Symbol ) =
68
+ isSyntheticAlt(s)
69
+
70
+ def isSyntheticAlt (using Quotes )(s : quotes.reflect.Symbol ) = {
71
+ import quotes .reflect ._
72
+ s.flags.is(Flags .Synthetic ) || s.isClassConstructor || s.isLocalDummy || isScala2Macro(s)
73
+ }
74
+ def isScala2Macro (using Quotes )(s : quotes.reflect.Symbol ) = {
75
+ import quotes .reflect ._
76
+ (s.flags.is(Flags .Macro ) && s.owner.flags.is(Flags .Scala2x )) ||
77
+ (s.flags.is(Flags .Macro ) && ! s.flags.is(Flags .Inline ))
78
+ }
68
79
def isSyntheticName (name : String ) = {
69
80
name == " <init>" || (name.startsWith(" <local " ) && name.endsWith(" >" )) || name == " $anonfun" || name == " macro"
70
81
}
Original file line number Diff line number Diff line change
1
+ package sourcecode
2
+
3
+ object SpecialName {
4
+
5
+ def macroValRun () = {
6
+ def keyword (implicit name : sourcecode.Name ): String = name.value
7
+
8
+ val `macro` = keyword
9
+
10
+ assert(`macro` == " macro" )
11
+ }
12
+
13
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ object Tests{
18
18
EnumFull .run()
19
19
NoSynthetic .run()
20
20
Synthetic .run()
21
+ SpecialName .macroValRun()
21
22
ManualImplicit ()
22
23
TextTests ()
23
24
ArgsTests ()
You can’t perform that action at this time.
0 commit comments