Giter Club home page Giter Club logo

Comments (6)

mielientiev avatar mielientiev commented on August 26, 2024

@propensive
I can reproduce it with sbt
I guess it's a bug in macros.scala#getModule in Class.forName(s"$typeName$$")
My assumptions is: Class.forName(s"$typeName$$") tries to instantiate class in compile time. But interpolator wasn't compiled yet and JVM couldn't load the class

from contextual.

propensive avatar propensive commented on August 26, 2024

I think the class must be compiled then, because the method is being called from an instance of it, though it might be that it's a different classloader. Could you check whether the classloader that's being used in the macro (which doesn't find the class) is the same one as the one that's used if you call Class.forName in the REPL?

from contextual.

mkotsbak avatar mkotsbak commented on August 26, 2024

Same issue in ScalaFiddle: https://scalafiddle.io/sf/WOGG0M5/1

from contextual.

propensive avatar propensive commented on August 26, 2024

Thanks for the additional datapoint, @mkotsbak!

from contextual.

propensive avatar propensive commented on August 26, 2024

Thanks for the really clear example, @volth! I'll see if I can work out what's going on...

from contextual.

tues avatar tues commented on August 26, 2024

@volth: I think you need to compile Hello2.scala and hex.scala separately:
http://docs.scala-lang.org/overviews/macros/overview.html#using-macros-with-the-command-line-scala-compiler

So something like:

libs=$(dirname $(dirname $(readlink -f `which scala`)))/lib
classpath=/home/user/.m2/repository/com/propensive/contextual_2.11/1.0.1/contextual_2.11-1.0.1.jar:/home/user/.m2/repository/org/typelevel/macro-compat_2.11/1.1.1/macro-compat_2.11-1.1.1.jar:$libs/scala-compiler.jar:$libs/scala-reflect.jar
                  
scalac -d hex.jar \
  -Xplugin /home/user/.m2/repository/org/scalamacros/paradise_2.11.11/2.1.0/paradise_2.11.11-2.10..jar \
  -cp $classpath \
  contextual/examples/src/main/scala/contextual/examples/hex.scala

scalac -d zzz.jar \
  -Xplugin /home/user/.m2/repository/org/scalamacros/paradise_2.11.11/2.1.0/paradise_2.11.11-2.1.0.jar \
  -cp $classpath:hex.jar \
  Hello2.scala

from contextual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.