diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 0b50276fb4e2..233e8883a6a2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -878,7 +878,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit tree.selector match { case EmptyTree => val (protoFormals, _) = decomposeProtoFunction(pt, 1) - val unchecked = pt <:< defn.PartialFunctionType + val unchecked = pt.isRef(defn.PartialFunctionClass) typed(desugar.makeCaseLambda(tree.cases, protoFormals.length, unchecked) withPos tree.pos, pt) case _ => val sel1 = typedExpr(tree.selector) @@ -2251,7 +2251,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit * tree that went unreported. A scenario where this happens is i1802.scala. */ def ensureReported(tp: Type) = tp match { - case err: ErrorType if !ctx.reporter.hasErrors => ctx.error(err.msg, tree.pos) + case err: ErrorType if !ctx.reporter.errorsReported => ctx.error(err.msg, tree.pos) case _ => } diff --git a/tests/neg/ensureReported.scala b/tests/neg/ensureReported.scala new file mode 100644 index 000000000000..b40f8837511c --- /dev/null +++ b/tests/neg/ensureReported.scala @@ -0,0 +1,6 @@ +object AnonymousF { + val f = { + case l @ List(1) => // error: missing parameter type // error: Ambiguous overload + Some(l) + } +} diff --git a/tests/patmat/i3206.scala b/tests/patmat/i3206.scala new file mode 100644 index 000000000000..72283f45bfba --- /dev/null +++ b/tests/patmat/i3206.scala @@ -0,0 +1,5 @@ +object Test { + val foo: PartialFunction[Option[Int], Int] = { + case Some(x) => x + } +} diff --git a/tests/patmat/partial-function.check b/tests/patmat/partial-function.check deleted file mode 100644 index fdfa33c052a8..000000000000 --- a/tests/patmat/partial-function.check +++ /dev/null @@ -1 +0,0 @@ -10: Pattern Match Exhaustivity: CC(_, B2)