From 3d708ac19b19abb7d3cdfcd8cd95e32154891fbf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 22 Dec 2019 18:31:17 +0100 Subject: [PATCH] Fix #7808: Weaken an assertion in Typer --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/neg/i7808.scala | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i7808.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 87c5c93db675..1ba54324aa06 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2548,7 +2548,7 @@ class Typer extends Namer adapt(tree, pt, ctx.typerState.ownedVars) private def adapt1(tree: Tree, pt: Type, locked: TypeVars)(implicit ctx: Context): Tree = { - assert(pt.exists && !pt.isInstanceOf[ExprType]) + assert(pt.exists && !pt.isInstanceOf[ExprType] || ctx.reporter.errorsReported) def methodStr = err.refStr(methPart(tree).tpe) def readapt(tree: Tree)(implicit ctx: Context) = adapt(tree, pt, locked) diff --git a/tests/neg/i7808.scala b/tests/neg/i7808.scala new file mode 100644 index 000000000000..96297c91b4a7 --- /dev/null +++ b/tests/neg/i7808.scala @@ -0,0 +1,10 @@ +object A { + { + val a: Int = 1 + object a { // error + this match { + case _ => () + } + } + } +} \ No newline at end of file