@@ -47,7 +47,9 @@ add_specs suite_builder =
47
47
ab = make_a_and_b
48
48
a2 = id_a ab
49
49
a2.is_a A . should_be_true
50
- a2.is_a B . should_be_false
50
+ a2.is_a B . should_be_true # B is a hidden type
51
+ Test.expect_panic No_Such_Method (a2.b_method)
52
+
51
53
52
54
# Passing a2 to a function expecting B fails because B part was hidden
53
55
Test.expect_panic Type_Error (id_b a2)
@@ -61,7 +63,8 @@ add_specs suite_builder =
61
63
ab = make_a_and_b
62
64
a2 = ab:A
63
65
a2.is_a A . should_be_true
64
- a2.is_a B . should_be_false
66
+ a2.is_a B . should_be_true # B is hidden type
67
+ Test.expect_panic No_Such_Method (a2.b_method)
65
68
66
69
# Passing a2 to a function expecting B fails because B part was hidden
67
70
Test.expect_panic Type_Error (id_b a2)
@@ -75,7 +78,8 @@ add_specs suite_builder =
75
78
b2 = id_b ab
76
79
a2 = b2:A
77
80
a2.is_a A . should_be_true
78
- a2.is_a B . should_be_false
81
+ a2.is_a B . should_be_true # B is hidden type
82
+ Test.expect_panic No_Such_Method (a2.b_method)
79
83
80
84
a2.a_method.should_equal "A method"
81
85
Test.expect_panic No_Such_Method (a2.b_method)
@@ -84,10 +88,11 @@ add_specs suite_builder =
84
88
ab = make_a_and_b
85
89
a2 = id_a ab
86
90
b2 = a2:B
87
- b2.is_a A . should_be_false
88
- b2.is_a B . should_be_true
89
91
92
+ b2.is_a B . should_be_true
93
+ b2.is_a A . should_be_true # A is hidden type
90
94
Test.expect_panic No_Such_Method (b2.a_method)
95
+
91
96
b2.b_method.should_equal "B method"
92
97
# We can still explicitly cast back to A
93
98
(b2:A).a_method.should_equal "A method"
@@ -98,13 +103,15 @@ add_specs suite_builder =
98
103
ab_as_a : A ->
99
104
ab_as_a.a_method . should_equal "A method"
100
105
ab_as_a.is_a A . should_be_true
101
- ab_as_a.is_a B . should_be_false
106
+ ab_as_a.is_a B . should_be_true # B is hidden type
107
+ Test.expect_panic No_Such_Method (ab_as_a.b_method)
102
108
_ -> Test.fail "Expected ab to go to `: A` branch"
103
109
104
110
case ab of
105
111
ab_as_b : B ->
106
112
ab_as_b.b_method . should_equal "B method"
107
- ab_as_b.is_a A . should_be_false
113
+ ab_as_b.is_a A . should_be_true # A is hidden type
114
+ Test.expect_panic No_Such_Method (ab_as_b.a_method)
108
115
ab_as_b.is_a B . should_be_true
109
116
_ -> Test.fail "Expected ab to go to `: B` branch"
110
117
@@ -141,12 +148,13 @@ add_specs suite_builder =
141
148
142
149
# We hide A&B parts by casting to C
143
150
c = abc:C
144
- c.is_a A . should_be_false
145
- c.is_a B . should_be_false
146
- c.is_a C . should_be_true
147
151
152
+ c.is_a A . should_be_true # A is a hidden type
148
153
Test.expect_panic No_Such_Method (c.a_method)
154
+ c.is_a B . should_be_true # B is a hidden type
149
155
Test.expect_panic No_Such_Method (c.b_method)
156
+ c.is_a C . should_be_true
157
+
150
158
c.c_method . should_equal "C method"
151
159
152
160
# But because the structure was not lost, only hidden, we can cast back to A/B
@@ -269,7 +277,7 @@ add_specs suite_builder =
269
277
r.a_method . should_equal "A method"
270
278
r.b_method . should_equal "B method"
271
279
272
- group_builder.specify "calling `.catch` on an intersection type should not lose even the hidden refinements" pending=dispatch_pending <|
280
+ group_builder.specify "calling `.catch` on an intersection type should not lose even the hidden refinements" <|
273
281
ab = make_a_and_b
274
282
x = ab:A
275
283
r = x.catch Any _->"catched"
@@ -283,7 +291,7 @@ add_specs suite_builder =
283
291
y.a_method . should_equal "A method"
284
292
y.b_method . should_equal "B method"
285
293
286
- group_builder.specify "calling `.throw_on_warning` on an intersection type should not lose even the hidden refinements" pending=dispatch_pending <|
294
+ group_builder.specify "calling `.throw_on_warning` on an intersection type should not lose even the hidden refinements" <|
287
295
ab = make_a_and_b
288
296
x = ab:A
289
297
r = x.throw_on_warning
@@ -306,7 +314,7 @@ add_specs suite_builder =
306
314
y.b_method . should_equal "B method"
307
315
Problems.expect_only_warning Illegal_State y
308
316
309
- group_builder.specify "removing warnings from an intersection type should not lose even the hidden refinements" pending=dispatch_pending <|
317
+ group_builder.specify "removing warnings from an intersection type should not lose even the hidden refinements" <|
310
318
ab = make_a_and_b
311
319
x1 = Warning.attach (Illegal_State.Error "my warning") (ab:A)
312
320
x2 = (Warning.attach (Illegal_State.Error "my warning") ab):A
0 commit comments