Last active
August 29, 2015 14:26
-
-
Save retronym/3f8b68abe7817a722a8a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
scala> import scala.tools.nsc._, reporters._; val reporter = new StoreReporter; val settings = new Settings(); settings.processArgumentString("-usejavacp -Ystop-after:refchecks"); val global = new Global(settings, reporter) | |
import scala.tools.nsc._ | |
import reporters._ | |
reporter: scala.tools.nsc.reporters.StoreReporter = scala.tools.nsc.reporters.StoreReporter@5e18a6a7 | |
settings: scala.tools.nsc.Settings = | |
Settings { | |
-d = . | |
-Ystop-after = List(refchecks) | |
-usejavacp = true | |
-encoding = UTF-8 | |
} | |
global: scala.tools.nsc.Global = scala.tools.nsc.Global@505e483f | |
scala> {val run = new global.Run; run.compileSources(global.newSourceFile("class X { val x: Int = 42 }") :: Nil); println(reporter.infos); println(run.units.toList.head.body); reporter.reset()} | |
Set() | |
package <empty> { | |
class X extends scala.AnyRef { | |
def <init>(): X = { | |
X.super.<init>(); | |
() | |
}; | |
private[this] val x: Int = 42; | |
<stable> <accessor> def x: Int = X.this.x | |
} | |
} | |
scala> {val run = new global.Run; run.compileSources(global.newSourceFile("class X { val x: Int = this }") :: Nil); println(reporter.infos); println(run.units.toList.head.body); reporter.reset()} | |
Set(pos: source-<console>,line-1,offset=23 type mismatch; | |
found : X | |
required: Int ERROR) | |
package <empty> { | |
class X extends scala.AnyRef { | |
def <init>(): X = { | |
X.super.<init>(); | |
() | |
}; | |
private[this] val x: Int = this; | |
<stable> <accessor> def x: Int = X.this.x | |
} | |
} | |
scala> {val run = new global.Run; run.compileSources(global.newSourceFile("class X { val x: Int = 42 }") :: Nil); println(reporter.infos); println(global.show(run.units.toList.head.body, printTypes = true)); reporter.reset()} | |
Set() | |
package <empty>{<empty>.type} { | |
class X extends scala.AnyRef { | |
def <init>(): X = { | |
X.super.<init>{()Object}(){Object}; | |
(){Unit} | |
}{Unit}; | |
private[this] val x: Int = 42{Int(42)}; | |
<stable> <accessor> def x: Int = X.this.x{Int} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment