diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 8de5da6eb390..0df47f91c254 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1128,7 +1128,7 @@ object desugar { case TypeDef(_, rhs) => def rhsOK(tree: Tree): Boolean = tree match { case bounds: TypeBoundsTree => !bounds.alias.isEmpty - case _: Template => false + case _: Template | _: MatchTypeTree => false case LambdaTypeTree(_, body) => rhsOK(body) case _ => true } diff --git a/tests/neg/6890.scala b/tests/neg/6890.scala new file mode 100644 index 000000000000..0f540a847a7b --- /dev/null +++ b/tests/neg/6890.scala @@ -0,0 +1,3 @@ +object Test { + opaque type A[T] = T match { case Int => Int } // error: Modifier `opaque` is not allowed for this definition +}