Skip to content

Commit f91731d

Browse files
committed
Discover file name
1 parent 4ee44a3 commit f91731d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/src/scala/quoted/Toolbox.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ object Toolbox {
2525
* @return
2626
*/
2727
@forceInline def make(implicit settings: Settings): Toolbox = {
28-
// TODO find the name of the class that needs to be loaded. Maybe from a stack trace.
29-
30-
// We force inline to make forName use the classloader of the class at callsite
31-
val clazz = Class.forName("hello.Main")
28+
// Get the name of the class at call site
29+
val className = new Throwable().getStackTrace.head.getClassName
30+
// We inline to make forName use the classloader of the class at call site
31+
val clazz = Class.forName(className)
3232
val cl = clazz.getClassLoader
3333
make(cl)
3434
}

0 commit comments

Comments
 (0)