File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,9 +198,9 @@ def hash = [@bits, @spec].hash
198198 private
199199
200200 def spec_compatible? ( other )
201- return true if other . spec == Spec ::NONE # other is unspecialized (Any)
202- return true if @spec == Spec :: NONE && @bits == Bits :: Empty # self is Empty
203- @spec == other . spec || @spec == Spec :: NONE
201+ return true if other . spec == Spec ::NONE # other is unspecialized — supertype of all specs
202+ return true if @spec == other . spec # identical specialization
203+ false # unspecialized self is NOT subtype of specialized other
204204 end
205205 end
206206
@@ -1343,13 +1343,13 @@ def test_type_display_without_const
13431343 end
13441344
13451345 def test_const_type_subtype_of_unspecialized
1346+ # Fixnum[42] is more specific → it IS a subtype of plain Fixnum
13461347 assert Types ::Fixnum . with_const ( 42 ) <= Types ::Fixnum
13471348 end
13481349
1349- def test_unspecialized_subtype_of_const
1350- # Fixnum (unspecialized) <= Fixnum[42] is true because bits match
1351- # and spec_compatible allows NONE <= specific
1352- assert Types ::Fixnum <= Types ::Fixnum . with_const ( 42 )
1350+ def test_unspecialized_not_subtype_of_const
1351+ # Plain Fixnum is NOT a subtype of Fixnum[42] — it could be any fixnum
1352+ refute Types ::Fixnum <= Types ::Fixnum . with_const ( 42 )
13531353 end
13541354
13551355 # ── Display ──
You can’t perform that action at this time.
0 commit comments