diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-10-28 19:12:29 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-10-28 19:23:50 +1000 |
commit | 8f9e9c893893084129ea423ef7ff5d3e79074622 (patch) | |
tree | d5cd3fb7dd0ed963f468ce1e8bbfaaf1016b79e0 /src | |
parent | 7664e25eed8ae4547f1cfd774b62a7b6a4baf8b5 (diff) | |
download | scala-8f9e9c893893084129ea423ef7ff5d3e79074622.tar.gz scala-8f9e9c893893084129ea423ef7ff5d3e79074622.tar.bz2 scala-8f9e9c893893084129ea423ef7ff5d3e79074622.zip |
SI-8941 Deterministic tests for pres. compiler idempotency
A retrospective test case which covers typechecking idempotency which
was introduced in 0b78a0196 / 148736c3df. It also tests the
implicit class handling, which was fixed in the previous commit.
It is difficult to test this using existing presentation compiler
testing infrastructure, as one can't control at which point during
the first typechecking the subesquent work item will be noticed.
Instead, I've created a test with a custom subclass of
`interactive.Global` that allows precise, deterministic control
of when this happens. It overrides `signalDone`, which is called
after each tree is typechecked, and watches for a defintion with
a well known name. At that point, it triggers a targetted typecheck
of the tree marked with a special comment.
It is likely that this approach can be generalized to a reusable
base class down the track. In particular, I expect that some of
the nasty interactive ScalaDoc bugs could use this single-threaded
approach to testing the presentation compiler.
Diffstat (limited to 'src')
-rw-r--r-- | src/interactive/scala/tools/nsc/interactive/Global.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index e308bc3bf0..7df809b6ff 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -64,6 +64,8 @@ trait InteractiveAnalyzer extends Analyzer { // that case the definitions that were already attributed as // well as any default parameters of such methods need to be // re-entered in the current scope. + // + // Tested in test/files/presentation/t8941b override def enterExistingSym(sym: Symbol, tree: Tree): Context = { if (sym != null && sym.owner.isTerm) { enterIfNotThere(sym) @@ -737,7 +739,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } } - private def reloadSource(source: SourceFile) { + private[interactive] def reloadSource(source: SourceFile) { val unit = new RichCompilationUnit(source) unitOfFile(source.file) = unit toBeRemoved -= source.file @@ -786,7 +788,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } /** A fully attributed tree located at position `pos` */ - private def typedTreeAt(pos: Position): Tree = getUnit(pos.source) match { + private[interactive] def typedTreeAt(pos: Position): Tree = getUnit(pos.source) match { case None => reloadSources(List(pos.source)) try typedTreeAt(pos) |