This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *** 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18:09 ~/Projects/210x/sandbox (2.10.x)$ scala | |
Welcome to Scala version 2.10.5-20140326-123924-c74e1325ff (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_40). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val tpe1 = typeOf[Some[Int]] | |
tpe1: reflect.runtime.universe.Type = scala.Some[Int] | |
scala> val tpe2a = typeOf[Option[_]] | |
tpe2a: reflect.runtime.universe.Type = scala.Option[_] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17:19 ~/Projects/Master/sandbox (master)$ st | |
[[syntax trees at end of typer]] // Test.scala | |
package <empty> { | |
abstract trait B extends scala.AnyRef; | |
class C1 extends scala.AnyRef { | |
def <init>(): C1 = { | |
C1.super.<init>(); | |
() | |
}; | |
scala.this.Predef.println(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17:20 ~/Projects/Master/sandbox (master)$ st | |
[[syntax trees at end of typer]] // Test.scala | |
package <empty> { | |
abstract trait B extends scala.AnyRef; | |
class C1 extends scala.AnyRef { | |
def <init>(): C1 = { | |
C1.super.<init>(); | |
() | |
}; | |
private[this] val x1: C1 = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] when verifying Template.this.parents.length.!=(0).&&(Template.this.parents.tail.exists(((x$3) => x$3.argss.nonEmpty))).`unary_!` | |
[info] found that Template.this.parents.length is not equal to 0 | |
[info] and also Template.this.parents.tail.forall(((x$3) => x$3.argss.nonEmpty.`unary_!`)) is false | |
[info] context is Template(List(),List(Parent(Ident(),List(List())), Parent(Ident(),List(List()))),Self(None,None),List()) | |
[info] when verifying !(parents.length != 0 && parents.tail.exists((_.argss.nonEmpty))) | |
[info] found that parents.length is not equal to 0 | |
[info] and also parents.tail.forall(_.argss.empty) is false | |
[info] context is Template(List(),List(Parent(Ident(),List(List())), Parent(Ident(),List(List()))),Self(None,None),List()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReflectCompilationUnit { | |
type Icode | |
def icodes: List[Icode] = Nil | |
} | |
class CompilerCompilationUnit extends ReflectCompilationUnit { | |
type Icode = compiler.Icode | |
override val icodes: List[Icode] = ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReflectTypechecker { self => | |
type UnaffiliatedMacroContext <: scala.reflect.moved.macros.contexts.Context | |
type MacroContext = UnaffiliatedMacroContext { val universe: self.global.type } | |
def newContext(): MacroContext = new ReflectMacroContext().asInstanceOf[MacroContext] | |
} | |
class CompilerTypechecker extends ReflectTypechecker { | |
override type UnaffiliatedMacroContext = scala.reflect.macros.contexts.Context | |
override def newContext(): MacroContext = new CompilerMacroContext().asInstanceOf[MacroContext] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@clean | |
def foo = bar | |
// expands into | |
def foo = WartRemover.clean(bar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11:42 ~/Projects/211x/sandbox (2.11.x)$ cat Test.scala | |
import scala.reflect.runtime.universe._ | |
import scala.reflect.runtime.{currentMirror => cm} | |
import scala.tools.reflect.ToolBox | |
import scala.tools.reflect.Eval | |
object Test extends App { | |
val tb = cm.mkToolBox(options = "-Ydump-classes .") | |
println(tb.eval(q"123")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] --- scala-maven-plugin:3.1.7-SNAPSHOT:compile (scala-compile-first) @ scala --- | |
[WARNING] Zinc server is not available at port 3030 - reverting to normal incremental compile | |
[INFO] Using incremental compilation | |
[WARNING] extra args for zinc are ignored in non-server mode | |
[INFO] 'compiler-interface' not yet compiled for Scala 2.11.2. Compiling... | |
/var/folders/bq/rz89jq0x4f13cm4sk6ss08l80000gn/T/sbt_3f3e9cfe/CompilerInterface.scala:246: error: recursive method rootLoader needs result type | |
override def rootLoader = if(resident) newPackageLoaderCompat(rootLoader)(compiler.classPath) else super.rootLoader | |
^ | |
/var/folders/bq/rz89jq0x4f13cm4sk6ss08l80000gn/T/sbt_3f3e9cfe/CompilerInterface.scala:246: error: value rootLoader is not a member of scala.tools.nsc.backend.JavaPlatform | |
override def rootLoader = if(resident) newPackageLoaderCompat(rootLoader)(compiler.classPath) else super.rootLoader |