File tree Expand file tree Collapse file tree 5 files changed +48
-2
lines changed
library/src/scala/tasty/reflect Expand file tree Collapse file tree 5 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ trait CompilerInterface {
157157 /** Get module symbol if module is either defined in current compilation run or present on classpath. */
158158 def Context_requiredModule (self : Context )(path : String ): Symbol
159159
160- /** Get method symbol if method is either defined in current compilation run or present on classpath. */
160+ /** Get method symbol if method is either defined in current compilation run or present on classpath. Throws if the method has an overload. */
161161 def Context_requiredMethod (self : Context )(path : String ): Symbol
162162
163163 //
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ trait ContextOps extends Core {
1919 /** Get module symbol if module is either defined in current compilation run or present on classpath. */
2020 def requiredModule (path : String ): Symbol = internal.Context_requiredModule (self)(path)
2121
22- /** Get method symbol if method is either defined in current compilation run or present on classpath. */
22+ /** Get method symbol if method is either defined in current compilation run or present on classpath. Throws if the method has an overload. */
2323 def requiredMethod (path : String ): Symbol = internal.Context_requiredMethod (self)(path)
2424
2525 }
Original file line number Diff line number Diff line change 1+ java
2+ java.lang
3+ scala
4+ scala.collection
5+ java.lang.Object
6+ scala.Any
7+ scala.Any
8+ scala.AnyVal
9+ scala.Unit
10+ scala.Null
11+ scala.None
12+ scala.package$.Nil
13+ scala.collection.immutable.List$.empty
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+
3+ object Macro {
4+ inline def foo : String = $ { fooImpl }
5+ def fooImpl (given qctx : QuoteContext ): Expr [String ] = {
6+ import qctx .tasty .{given , _ }
7+ val list = List (
8+ rootContext.requiredPackage(" java" ),
9+ rootContext.requiredPackage(" java.lang" ),
10+ rootContext.requiredPackage(" scala" ),
11+ rootContext.requiredPackage(" scala.collection" ),
12+
13+ rootContext.requiredClass(" java.lang.Object" ),
14+ rootContext.requiredClass(" scala.Any" ),
15+ rootContext.requiredClass(" scala.AnyRef" ),
16+ rootContext.requiredClass(" scala.AnyVal" ),
17+ rootContext.requiredClass(" scala.Unit" ),
18+ rootContext.requiredClass(" scala.Null" ),
19+
20+ rootContext.requiredModule(" scala.None" ),
21+ rootContext.requiredModule(" scala.Nil" ),
22+
23+ rootContext.requiredMethod(" scala.List.empty" ),
24+ )
25+ Expr (list.map(_.fullName).mkString(" \n " ))
26+ }
27+ }
Original file line number Diff line number Diff line change 1+
2+ object Test {
3+ def main (args : Array [String ]): Unit = {
4+ println(Macro .foo)
5+ }
6+ }
You can’t perform that action at this time.
0 commit comments