Skip to content

Commit 10d23a6

Browse files
committed
Add refining annotation subtyping test case
1 parent 7ac31d0 commit 10d23a6

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

tests/neg/annot-refining-sub.scala

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

0 commit comments

Comments
 (0)