14 lines
1.1 KiB
Diff
14 lines
1.1 KiB
Diff
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
|
|
index abcdef00..cwe407fix 100644
|
|
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
|
|
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
|
|
@@ -464,7 +464,11 @@ trait RefChecks {
|
|
//Console.println(infoString(member) + " overrides " + infoString(other) + " in " + clazz);//DEBUG
|
|
|
|
/* Is the intersection between given two lists of overridden symbols empty? */
|
|
- def intersectionIsEmpty(syms1: List[Symbol], syms2: List[Symbol]) = !syms1.exists(syms2.contains)
|
|
+ // CWE-407 fix: syms2.contains on List[Symbol] is O(|syms2|) per call.
|
|
+ // extendedOverriddenSymbols returns O(D) symbols (D = hierarchy depth).
|
|
+ // Original: O(|syms1| x |syms2|) = O(D^2) per pair checked in checkAllOverrides.
|
|
+ // Fix: convert syms2 to a Set[Symbol] once — O(|syms2|) — then O(1) per lookup.
|
|
+ def intersectionIsEmpty(syms1: List[Symbol], syms2: List[Symbol]) = { val s2 = syms2.toSet; !syms1.exists(s2.contains) }
|