From 63fe1c089f798a8806f15ae971118c1fa25f2e33 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 8 Feb 2023 10:06:24 +0100 Subject: [PATCH] Add regression tests Closes #16842 --- tests/neg/i16842.scala | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/neg/i16842.scala diff --git a/tests/neg/i16842.scala b/tests/neg/i16842.scala new file mode 100644 index 000000000000..1e7e5cc14339 --- /dev/null +++ b/tests/neg/i16842.scala @@ -0,0 +1,25 @@ +sealed trait Expr1 +sealed trait Literal extends Expr1 + +case class ArrayLiter(elems: List[Expr1]) extends Literal + +sealed trait SemanticType { + type T // the type with which a literal of this semanticType is represented +} +case object SemanticInt extends SemanticType { + type T = Int +} + +case class SemanticArray[U <: SemanticType](dim: Int) extends SemanticType { + type T = List[U] +} + +sealed trait Expr2[+T] +class Liter[T <: SemanticType](val ty: T, val value: ty.T) extends Expr2[T] + +def typecheckArrayLiter( + a: ArrayLiter +): Liter[SemanticArray[SemanticType]] = { + val x: List[Expr2[SemanticInt.type]] = List() + Liter(SemanticArray[SemanticInt.type], x) // error // error +}