@@ -47,7 +47,9 @@ add_specs suite_builder =
4747 ab = make_a_and_b
4848 a2 = id_a ab
4949 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+
5153
5254 # Passing a2 to a function expecting B fails because B part was hidden
5355 Test.expect_panic Type_Error (id_b a2)
@@ -61,7 +63,8 @@ add_specs suite_builder =
6163 ab = make_a_and_b
6264 a2 = ab:A
6365 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)
6568
6669 # Passing a2 to a function expecting B fails because B part was hidden
6770 Test.expect_panic Type_Error (id_b a2)
@@ -75,7 +78,8 @@ add_specs suite_builder =
7578 b2 = id_b ab
7679 a2 = b2:A
7780 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)
7983
8084 a2.a_method.should_equal "A method"
8185 Test.expect_panic No_Such_Method (a2.b_method)
@@ -84,10 +88,11 @@ add_specs suite_builder =
8488 ab = make_a_and_b
8589 a2 = id_a ab
8690 b2 = a2:B
87- b2.is_a A . should_be_false
88- b2.is_a B . should_be_true
8991
92+ b2.is_a B . should_be_true
93+ b2.is_a A . should_be_true # A is hidden type
9094 Test.expect_panic No_Such_Method (b2.a_method)
95+
9196 b2.b_method.should_equal "B method"
9297 # We can still explicitly cast back to A
9398 (b2:A).a_method.should_equal "A method"
@@ -98,13 +103,15 @@ add_specs suite_builder =
98103 ab_as_a : A ->
99104 ab_as_a.a_method . should_equal "A method"
100105 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)
102108 _ -> Test.fail "Expected ab to go to `: A` branch"
103109
104110 case ab of
105111 ab_as_b : B ->
106112 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)
108115 ab_as_b.is_a B . should_be_true
109116 _ -> Test.fail "Expected ab to go to `: B` branch"
110117
@@ -141,12 +148,13 @@ add_specs suite_builder =
141148
142149 # We hide A&B parts by casting to C
143150 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
147151
152+ c.is_a A . should_be_true # A is a hidden type
148153 Test.expect_panic No_Such_Method (c.a_method)
154+ c.is_a B . should_be_true # B is a hidden type
149155 Test.expect_panic No_Such_Method (c.b_method)
156+ c.is_a C . should_be_true
157+
150158 c.c_method . should_equal "C method"
151159
152160 # But because the structure was not lost, only hidden, we can cast back to A/B
@@ -269,7 +277,7 @@ add_specs suite_builder =
269277 r.a_method . should_equal "A method"
270278 r.b_method . should_equal "B method"
271279
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" <|
273281 ab = make_a_and_b
274282 x = ab:A
275283 r = x.catch Any _->"catched"
@@ -283,7 +291,7 @@ add_specs suite_builder =
283291 y.a_method . should_equal "A method"
284292 y.b_method . should_equal "B method"
285293
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" <|
287295 ab = make_a_and_b
288296 x = ab:A
289297 r = x.throw_on_warning
@@ -306,7 +314,7 @@ add_specs suite_builder =
306314 y.b_method . should_equal "B method"
307315 Problems.expect_only_warning Illegal_State y
308316
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" <|
310318 ab = make_a_and_b
311319 x1 = Warning.attach (Illegal_State.Error "my warning") (ab:A)
312320 x2 = (Warning.attach (Illegal_State.Error "my warning") ab):A
0 commit comments