diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t8962.scala | 31 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index eb29ccf4e1..e278130437 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -330,7 +330,7 @@ trait Contexts { self: Analyzer => // if set, errors will not be reporter/thrown def bufferErrors = reporter.isBuffering - def reportErrors = !bufferErrors + def reportErrors = !(bufferErrors || reporter.isThrowing) // whether to *report* (which is separate from buffering/throwing) ambiguity errors def ambiguousErrors = this(AmbiguousErrors) @@ -1247,6 +1247,7 @@ trait Contexts { self: Analyzer => def makeImmediate: ContextReporter = this def makeBuffering: ContextReporter = this def isBuffering: Boolean = false + def isThrowing: Boolean = false /** Emit an ambiguous error according to context.ambiguousErrors * @@ -1384,6 +1385,7 @@ trait Contexts { self: Analyzer => * TODO: get rid of it, use ImmediateReporter and a check for reporter.hasErrors where necessary */ private[typechecker] class ThrowingReporter extends ContextReporter { + override def isThrowing = true protected def handleError(pos: Position, msg: String): Unit = throw new TypeError(pos, msg) } diff --git a/test/files/pos/t8962.scala b/test/files/pos/t8962.scala new file mode 100644 index 0000000000..4331c154ba --- /dev/null +++ b/test/files/pos/t8962.scala @@ -0,0 +1,31 @@ +package test.nestedcov + +sealed abstract class Outer[+A] +case class Let[+A](expr: Outer[Inner[A]]) extends Outer[A] + +sealed abstract class Inner[+A] + +sealed abstract class Outer2[+A, +B] +case class Let2[+A](expr: Outer2[Inner2[A], A]) extends Outer2[A, A] + +sealed abstract class Inner2[+A] + +sealed abstract class Outer3[+A, +B] +case class Let3[+A](expr: Outer3[A, A]) extends Outer3[A, A] + +object NestedCov { + def run[A](nc: Outer[A]) = nc match { + case Let(expr) => + expr : Outer[Inner[A]] + } + + def run2[A](nc: Outer2[A, A]) = nc match { + case Let2(expr) => + expr : Outer2[Inner2[A], A] + } + + def run3[A](nc: Outer3[A, A]) = nc match { + case Let3(expr) => + expr : Outer3[A, A] + } +} |