-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi there,
I have a question regarding SI-7046 "won't fix". I am not sure this is
the same issue. I have the following problem with macros and
`knownDirectSubclasses`:
// built.sbt
scalaVersion := "2.11.0-M7"
resolvers += Resolver.sonatypeRepo("snapshots")
libraryDependencies += "org.scala-lang" % "scala-reflect" %
scalaVersion.value
addCompilerPlugin("org.scala-lang.plugins" % "macro-paradise" %
"2.0.0-SNAPSHOT" cross CrossVersion.full)
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature")
// src/main/scala/de/sciss/macrotest
package de.sciss.macrotest
import scala.reflect.macros.Context
import language.experimental.macros
object Format {
def apply[A](): Unit = macro applyImpl[A]
def applyImpl[A: c.WeakTypeTag](c: Context)(): c.Expr[Unit] = {
import c.universe._
val aTpeW = c.weakTypeOf[A]
val aClazz = aTpeW.typeSymbol.asClass
val subs = aClazz.knownDirectSubclasses
println(subs.mkString("--- sub classes:\n '", "'\n '",
"'\n---"))
c.Expr[Unit](EmptyTree)
}
}
// src/test/scala/de/sciss/macrotest
package de.sciss.macrotest
object Baz {
Format[Foo]()
}
sealed trait Foo
case class Bar() extends Foo
Running `sbt test:compile`, this shows that when compiling the body of
`Baz`, there are no known sub classes of `Foo`. If I change the order to
package de.sciss.macrotest
sealed trait Foo
case class Bar() extends Foo
object Baz {
Format[Foo]()
}
Then it correctly prints type `Bar`.
So my questions are: is this SI-7046? will this behaviour be fix? Or:
is there a work around _for the design of the macro_ (not requiring
hoops on the use site)?
Thanks, .hh.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
Comment: GPGTools -
http://gpgtools.org
Comment: Using GnuPG with Thunderbird -
http://www.enigmail.net/
iQIcBAEBAgAGBQJSpt7HAAoJEKZFmaPaYk6QWl0P/jGxJRoxMk9p9phqNdyrv5x8
hkCKGAqBWojf601UWVJGV4MHD7xivE1kV3cnwJwn7rPYpZ1kjYZrfvU+OVHYQojZ
T6Aznw2Q9Re11xPXnjAUKbDT1/wmw6kLG9GR23oiok45EH/2pig38oqPGBOfTtlq
TiVBSKSmc639sScwQ1ZCUMAPuGejkQdP6WO0NKDwl//9faZhfdIaqioG1UCpU8xn
4i9NTvKv1fv6EjXdkIawRRh+W/B4LRaU9egVkmPjcAX4wcjat/ZveOUimODmgtcb
N/jdAxjo0WRsZriA5JWIMtL586kr/M07rQlQ3JaPukoejH8ErjwAj4zfeUx1bvaG
jM5UAtaIgLD5sBF9vw9Zr7WZuJxAwYD7pv7xOBVHnkcZoxsTwGqvQ5+m21pthjKa
XvnPvA6KxQUdSTQcYsmEGfo58CnhsADPN1fNIniYWMeoMHURmb1grwzC83LCEYNu
2AxiyWXFkLbOhcb/J3Ca9G+l6oz8ahkz8VbyicVeQiFhP/cY50/avjd1V5gFde1S
vxCaLqAvMVSQWM61GHWvkNNyVXnCcxZQr89kF4pQ2Bb1AkWHlwbmbmLG8HmwHdyV
Azc4nGg4Da3AtXZOWxvC9WRbtuqKqD/pXfFYuuYNl5zfofUbEyRwGgIN86ZgZPOG
MuIg9w2JwrUW7LdHQKXI
=AnBW
-----END PGP SIGNATURE-----