File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ sealed trait Expr1
2
+ sealed trait Literal extends Expr1
3
+
4
+ case class ArrayLiter (elems : List [Expr1 ]) extends Literal
5
+
6
+ sealed trait SemanticType {
7
+ type T // the type with which a literal of this semanticType is represented
8
+ }
9
+ case object SemanticInt extends SemanticType {
10
+ type T = Int
11
+ }
12
+
13
+ case class SemanticArray [U <: SemanticType ](dim : Int ) extends SemanticType {
14
+ type T = List [U ]
15
+ }
16
+
17
+ sealed trait Expr2 [+ T ]
18
+ class Liter [T <: SemanticType ](val ty : T , val value : ty.T ) extends Expr2 [T ]
19
+
20
+ def typecheckArrayLiter (
21
+ a : ArrayLiter
22
+ ): Liter [SemanticArray [SemanticType ]] = {
23
+ val x : List [Expr2 [SemanticInt .type ]] = List ()
24
+ Liter (SemanticArray [SemanticInt .type ], x) // error // error
25
+ }
You can’t perform that action at this time.
0 commit comments