java-topology/defects/crystal/patch/crystal-0002-restrictions-discarded-set.patch

20 lines
666 B
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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