diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-07-27 15:24:46 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-08-04 17:49:56 +0200 |
commit | e131424b45881ac8446235f255c8f637602857ac (patch) | |
tree | 81f9b79756b2b90256f16d751a2aa2e610f9fcc1 | |
parent | 5d00b5940a9c91b6d9e13fea625d406ce53cc60c (diff) | |
download | scala-e131424b45881ac8446235f255c8f637602857ac.tar.gz scala-e131424b45881ac8446235f255c8f637602857ac.tar.bz2 scala-e131424b45881ac8446235f255c8f637602857ac.zip |
Work around weird AbstractMethodError
Could not figure it out, so resorting to brain dumping.
something with private classes and defaults,
the default getter will be in the private companion module,
but there's no accessor to get the module???
maybe something related to make non-private of the accessor?
while running the repl or, e.g., the test presentation/ide-t1000567
AbstractMethodError: scala.tools.nsc.interactive.Global$$anon$5.scala$tools$nsc$typechecker$Contexts$$BufferingReporter()Lscala/tools/nsc/typechecker/Contexts$BufferingReporter$;
at scala.tools.nsc.typechecker.Contexts$Context.makeSilent(Contexts.scala:518)
in progress minimal repro:
```
package a
class Reporter
class Global {
lazy val analyzer = new {
val global: Global.this.type = Global.this
} with Analyzer
}
trait Analyzer extends AnyRef with Contexts {
val global : Global
}
trait Contexts { self: Analyzer =>
// the accessor to get to ContextReporter's companion object
// to get the default for x is not emitted for some reason
// the expected accessor is the non-private version
// `def scala$tools$nsc$typechecker$Contexts$$BufferingReporter: scala.tools.nsc.typechecker.Contexts#BufferingReporter$`
// (as seen in the AbstractMethodError's message)
abstract class ContextReporter(x: Any = null) extends Reporter
private class ThrowingReporter extends ContextReporter
class Context(a: Any, private[this] var _reporter: ContextReporter = new ThrowingReporter) {
def reporter = _reporter
}
object NoContext extends Context(null)
}
package b
trait ReplGlobal extends a.Global {
// this anon class corresponds to scala.tools.nsc.interactive.Global$$anon$5 in the above AbstractMethodError
override lazy val analyzer = new {
val global: ReplGlobal.this.type = ReplGlobal.this
} with a.Analyzer { }
}
```
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index fd9d1de88e..6573102e86 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -1312,13 +1312,13 @@ trait Contexts { self: Analyzer => final def clearAllWarnings(): Unit = warningBuffer.clear() } - private class ImmediateReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[(Position, String)] = null) extends ContextReporter(_errorBuffer, _warningBuffer) { + private[typechecker] class ImmediateReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[(Position, String)] = null) extends ContextReporter(_errorBuffer, _warningBuffer) { override def makeBuffering: ContextReporter = new BufferingReporter(errorBuffer, warningBuffer) protected def handleError(pos: Position, msg: String): Unit = reporter.error(pos, msg) } - private class BufferingReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[(Position, String)] = null) extends ContextReporter(_errorBuffer, _warningBuffer) { + private[typechecker] class BufferingReporter(_errorBuffer: mutable.LinkedHashSet[AbsTypeError] = null, _warningBuffer: mutable.LinkedHashSet[(Position, String)] = null) extends ContextReporter(_errorBuffer, _warningBuffer) { override def isBuffering = true override def issue(err: AbsTypeError)(implicit context: Context): Unit = errorBuffer += err @@ -1337,12 +1337,12 @@ trait Contexts { self: Analyzer => * * TODO: get rid of it, use ImmediateReporter and a check for reporter.hasErrors where necessary */ - private class ThrowingReporter extends ContextReporter { + private[typechecker] class ThrowingReporter extends ContextReporter { protected def handleError(pos: Position, msg: String): Unit = throw new TypeError(pos, msg) } /** Used during a run of [[scala.tools.nsc.typechecker.TreeCheckers]]? */ - private class CheckingReporter extends ContextReporter { + private[typechecker] class CheckingReporter extends ContextReporter { protected def handleError(pos: Position, msg: String): Unit = onTreeCheckerError(pos, msg) } |