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