diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Desugar.scala | 6 | ||||
-rw-r--r-- | tests/neg/enums.scala | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 3a3acb06c..cf128c26e 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -297,7 +297,11 @@ object desugar { // This is not watertight, but `extends AnyVal` will be replaced by `inline` later. val originalTparams = - if (isEnumCase && parents.isEmpty) reconstitutedEnumTypeParams(cdef.pos.startPos) + if (isEnumCase && parents.isEmpty) { + if (constr1.tparams.nonEmpty) + ctx.error(em"case with type parameters needs extends clause", constr1.tparams.head.pos) + reconstitutedEnumTypeParams(cdef.pos.startPos) + } else constr1.tparams val originalVparamss = constr1.vparamss val constrTparams = originalTparams.map(toDefParam) diff --git a/tests/neg/enums.scala b/tests/neg/enums.scala index 83311f37c..2dc8999fa 100644 --- a/tests/neg/enums.scala +++ b/tests/neg/enums.scala @@ -1,6 +1,7 @@ enum List[+T] { case Cons(x: T, xs: List[T]) case Nil // error: illegal enum value + case Snoc[U](xs: List[U], x: U) // error: case with type parameters needs extends clause // error // error // error } enum class X { |