20 lines
666 B
Diff
20 lines
666 B
Diff
# UNDF: UNDF-2026-000000370
|
||
--- a/src/compiler/crystal/semantic/restrictions.cr
|
||
+++ b/src/compiler/crystal/semantic/restrictions.cr
|
||
@@ -1051,7 +1051,7 @@ module Crystal
|
||
|
||
types = [] of Type
|
||
- discarded = [] of Type
|
||
+ discarded = Set(Type).new # O(1) membership; avoids O(T×O) in union restriction loop
|
||
other_types.each do |other_type|
|
||
self.union_types.each do |type|
|
||
next if discarded.includes?(type)
|
||
|
||
restricted = type.restrict(other_type, context)
|
||
if restricted
|
||
types << restricted
|
||
- discarded << type
|
||
+ discarded.add type
|
||
end
|
||
end
|
||
end
|