Skip to content

Instantly share code, notes, and snippets.

View xeno-by's full-sized avatar

Eugene Burmako xeno-by

View GitHub Profile
import scala.language.experimental.macros
import scala.language.higherKinds
import scala.reflect.macros.blackbox.Context
case class Wrapper[A](arr: Array[A])
object Wrapper {
def literal[A](as: A*): Wrapper[A] = macro Example.wrapperMacro[A, Wrapper]
}
09:40 ~/Projects/basis (master)$ git rev-parse HEAD
56e5646a92ee015c5ef0d2c00c70bbb645a32878
09:40 ~/Projects/basis (master)$ sbt
[info] Loading project definition from /Users/xeno_by/Projects/basis/project
[info] Set current project to basis (in build file:/Users/xeno_by/Projects/basis/)
> show scalaVersion
[info] text/*:scalaVersion
[info] 2.10.3
[info] form/*:scalaVersion
[info] 2.10.3
15:07 ~/Projects/SBT (palladium0)$ sbt-the-rebel-cut
[info] Loading project definition from /Users/xeno_by/Projects/sbt/project
[info] Set current project to root (in build file:/Users/xeno_by/Projects/sbt/)
> set every resolvers += Resolver.sonatypeRepo("snapshots")
[info] Defining */*:resolvers, {.}/*:resolvers
[info] The new values will be used by actions/*:externalResolvers, api/*:externalResolvers and 41 others.
[info] Run `last` for details.
[info] Reapplying settings...
Cyclic reference involving
*/*:resolvers
> scripted project/*
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_9_2-0.13.2-SNAPSHOT-sources.jar ...
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_9_3-0.13.2-SNAPSHOT-sources.jar ...
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_8_2-0.13.2-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Done packaging.
[info] Done packaging.
[info] :: delivering :: org.scala-sbt#control;0.13.2-SNAPSHOT :: 0.13.2-SNAPSHOT :: integration :: Sat Feb 15 15:16:14 CET 2014
[info] delivering ivy file to /Users/xeno_by/Projects/sbt/util/control/target/ivy-0.13.2-SNAPSHOT.xml
[info] :: delivering :: org.scala-sbt#sbt-launch;0.13.2-SNAPSHOT :: 0.13.2-SNAPSHOT :: integration :: Sat Feb 15 15:16:14 CET 2014
> scripted project/setting-macro
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_9_2-0.13.2-SNAPSHOT-sources.jar ...
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_9_3-0.13.2-SNAPSHOT-sources.jar ...
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/precompiled-2_8_2-0.13.2-SNAPSHOT-sources.jar ...
[info] Packaging /Users/xeno_by/Projects/sbt/compile/interface/target/precompiled_2.11.0-M8/compiler-interface-src-0.13.2-SNAPSHOT.jar ...
[info] Done packaging.
[info] Done packaging.
[info] Done packaging.
[info] Done packaging.
[info] :: delivering :: org.scala-sbt#collections;0.13.2-SNAPSHOT :: 0.13.2-SNAPSHOT :: integration :: Sat Feb 15 15:18:38 CET 2014
16:00 ~/Projects/SBT (palladium0)$ sbt-the-rebel-cut -v -scala-version 2.11.0-M8 -scala-home "$(scala-root)/build/pack" "scripted project/setting-macro"
No extra sbt options have been defined
Detected sbt version 0.13.1
Using /Users/xeno_by/.sbt/0.13.1 as sbt dir, -sbt-dir to override.
Using default jvm options
# Executing command line:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
-Dfile.encoding=UTF8
-XX:MaxPermSize=384m
-Xms512m
16:10 ~/Projects/SBT (palladium0)$ sbt-the-rebel-cut -v "scripted project/setting-macro"No extra sbt options have been defined
Detected sbt version 0.13.1
Using /Users/xeno_by/.sbt/0.13.1 as sbt dir, -sbt-dir to override.
Using default jvm options
# Executing command line:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
-Dfile.encoding=UTF8
-XX:MaxPermSize=384m
-Xms512m
-Xmx1536m
import scala.language.experimental.macros
import scala.reflect.macros.Context
import scala.annotation.StaticAnnotation
class csvTyped(val sample: String)(funcs: (String => Any)*) extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro Macros.impl
}
object Macros {
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
trait Universe {
type Tree
}
trait NscContext {
type Tree = universe.Tree
val universe: Universe
def macroApplication: Tree
}
// *** What we want to do ***
// Write a mini-cake that would take and return path-dependent universe artifacts
// retaining precise path-dependent types when returning values
trait Universe {
type Tree
}
object ru extends Universe {
class Tree