Comments (6)
@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.
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.
Same issue in ScalaFiddle: https://scalafiddle.io/sf/WOGG0M5/1
from contextual.
Thanks for the additional datapoint, @mkotsbak!
from contextual.
Thanks for the really clear example, @volth! I'll see if I can work out what's going on...
from contextual.
@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)
- How does type embedding work? HOT 1
- Don't depend on scala-compiler
- Scala 2.13 release HOT 4
- Error macro has not been expanded in Scala 2.13.0 HOT 2
- 'scala.reflect.macros.whitebox.Context' is missing from the classpath
- Outdated docs
- The latest Fury layer doesn't contain classes from the data module
- Check version 2.0.0 works correctly HOT 1
- Embedding custom types not working with version 2.0.0 HOT 7
- contextual version 3.0.0 prints interpolated text during compile HOT 4
- Represent substitution types with an `enum` HOT 1
- Offer type refinements on return types HOT 2
- Use `Text` instead of `String` in the Contextual API
- Check if there is a reason why `Interpolator` methods cannot be `protected`
- Provide a simpler `Verifier` type for interpolations without substitutions
- Obviate need to specify companion object twice
- Offer better error message when failing to substitute `Nothing`
- Make it easier to refine the return type
- Make `PositionalError` a top-level class
- Consider using `boundary`/`break` to avoid throwing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contextual.