-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathannot-refining-sub.scala
92 lines (83 loc) · 4.92 KB
/
annot-refining-sub.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import compiletime.ops.int.+
class annot1(a: Any) extends scala.annotation.RefiningAnnotation
class annot2(a: Any, b: Any) extends scala.annotation.RefiningAnnotation
class annot3(a: Any, b: Any = 3) extends scala.annotation.RefiningAnnotation
class annot4[Int] extends scala.annotation.RefiningAnnotation
class Box[T](val a: Int)
case class Box2[T](val a: Int)
class Box3:
type T
def id[T](x: T): T = x
type BoxAlias = Box[Int]
type Box2Alias = Box2[Int]
object O:
val d: Int = 42
def main =
val c: Int = 42
val o: O.type = O
val v1: Int @annot1(1) = ??? : Int @annot1(1)
val v2: Int @annot1(c) = ??? : Int @annot1(c)
val v3: Int @annot1(O.d) = ??? : Int @annot1(O.d)
val v4: Int @annot1(O.d) = ??? : Int @annot1(o.d)
val v5: Int @annot1((1, 2)) = ??? : Int @annot1((1, 2))
val v6: Int @annot1(1 + 2) = ??? : Int @annot1(1 + 2)
val v7: Int @annot1(1 + 2) = ??? : Int @annot1(2 + 1) // error: no constant folding
val v8: Int @annot1(1 + c) = ??? : Int @annot1(1 + c)
val v9: Int @annot1(1 + c) = ??? : Int @annot1(c + 1) // error: no algebraic simplification
val v10: Int @annot1(Box(1)) = ??? : Int @annot1(Box(1))
val v11: Int @annot1(Box(c)) = ??? : Int @annot1(Box(c))
val v12: Int @annot1(Box2(1)) = ??? : Int @annot1(Box2(1))
val v13: Int @annot1(Box2(c)) = ??? : Int @annot1(Box2(c))
val v14: Int @annot1(c: Int) = ??? : Int @annot1(c: Int)
val v15: Int @annot1(c) = ??? : Int @annot1(c: Int) // error
val v16: Int @annot1(c: Int) = ??? : Int @annot1(c) // error
val v17: Int @annot1(id[Int]) = ??? : Int @annot1(id[Int])
val v18: Int @annot1(id[Int]) = ??? : Int @annot1(id[String]) // error
val v19: Int @annot1(id[Any]) = ??? : Int @annot1(id[Int]) // error
val v20: Int @annot1(Box(1)) = ??? : Int @annot1(Box(1): BoxAlias) // error
val v21: Int @annot1(Box(c): BoxAlias) = ??? : Int @annot1(Box(c)) // error
val v22: Int @annot1(Box2(1)) = ??? : Int @annot1(Box2(1): Box2Alias) // error
val v23: Int @annot1(Box2(c): Box2Alias) = ??? : Int @annot1(Box2(c)) // error
val v24: Int @annot1(Box3()) = ??? : Int @annot1(Box3())
val v25: Int @annot1(??? : Box3 {type T = Int}) = ??? : Int @annot1(??? : Box3 {type T = Int})
val v26: Int @annot1(??? : Box3 {type T = Int}) = ??? : Int @annot1(??? : Box3 {type T = String}) // error
val v27: Int @annot1(??? : Box3 {type T = Int}) = ??? : Int @annot1(??? : Box3) // error
val v28: Int @annot1(a=c) = ??? : Int @annot1(a=c)
val v29: Int @annot1(a=c) = ??? : Int @annot1(c)
val v30: Int @annot1(c) = ??? : Int @annot1(a=c)
val v31: Int @annot1((d: Int) => d) = ??? : Int @annot1((d: Int) => d)
val v32: Int @annot1((d: Int) => d) = ??? : Int @annot1((e: Int) => e)
val v33: Int @annot1((e: Int) => e) = ??? : Int @annot1((d: Int) => d)
val v34: Int @annot1((d: Int) => d + 1) = ??? : Int @annot1((e: Int) => e + 1)
val v35: Int @annot1((d: Int) => id(d)) = ??? : Int @annot1((e: Int) => id(e))
val v36: Int @annot1((d: Int) => id[d.type]) = ??? : Int @annot1((e: Int) => id[e.type])
val v37: Int @annot1((d: Box3) => id[d.T]) = ??? : Int @annot1((e: Box3) => id[e.T])
val v38: Int @annot1((d: Int) => (d: Int) => d) = ??? : Int @annot1((e: Int) => (e: Int) => e)
val v39: Int @annot1((d: Int) => ((e: Int) => e)(2)) = ??? : Int @annot1((e: Int) => ((e: Int) => e)(2))
val v40: Int @annot2(1, 2) = ??? : Int @annot2(1, 2)
val v41: Int @annot2(c, c) = ??? : Int @annot2(c, c)
val v42: Int @annot2(c, c) = ??? : Int @annot2(a=c, b=c)
val v43: Int @annot2(a=c, c) = ??? : Int @annot2(c, b=c)
val v44: Int @annot2(a=c, b=c) = ??? : Int @annot2(c, c)
val v45: Int @annot3(1) = ??? : Int @annot3(1)
val v46: Int @annot3(c) = ??? : Int @annot3(c)
val v47: Int @annot3(1) = ??? : Int @annot3(1, 3) // error: default arg tree is different, fix in the future?
val v48: Int @annot3(1, 3) = ??? : Int @annot3(1) // error: same as above
val v49: Int @annot3(c) = ??? : Int @annot3(c, 3) // error: same as above
val v50: Int @annot3(c, 3) = ??? : Int @annot3(c) // error: same as above
val v51: Int @annot4[1] = ??? : Int @annot4[1]
val v52: Int @annot4[c.type] = ??? : Int @annot4[c.type]
val v53: Int @annot4[O.d.type] = ??? : Int @annot4[O.d.type]
val v54: Int @annot4[O.d.type] = ??? : Int @annot4[o.d.type]
val v55: Int @annot4[Int] = ??? : Int @annot4[Int]
val v56: Int @annot4[Int] = ??? : Int @annot4[1] // error
val v57: Int @annot4[(1, 2)] = ??? : Int @annot4[(1, 2)]
val v58: Int @annot4[1 + 2] = ??? : Int @annot4[1 + 2]
val v59: Int @annot4[1 + 2] = ??? : Int @annot4[2 + 1]
val v60: Int @annot4[1 + c.type] = ??? : Int @annot4[1 + c.type]
val v61: Int @annot4[1 + c.type] = ??? : Int @annot4[c.type + 1] // error
val v62: Int @annot4[Box[Int]] = ??? : Int @annot4[Box[Int]]
val v63: Int @annot4[Box[String]] = ??? : Int @annot4[Box[Int]] // error
val v64: Int @annot4[Box2[Int]] = ??? : Int @annot4[Box2[Int]]
val v65: Int @annot4[Box2[String]] = ??? : Int @annot4[Box2[Int]] // error
val v66: Int @annot4[1] = ??? : Int @annot4[Int] // error