File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
compiler/src/dotty/tools/dotc/util Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ class SparseIntArray:
2828
2929 def update (index : Int , value : Value ): Unit =
3030 require(index >= 0 )
31- while capacity <= index do grow()
31+ while capacity <= index do
32+ require(root.level < MaxLevels , " array index too large, maximum is 2^30 - 1" )
33+ grow()
3234 if ! root.update(index, value) then siz += 1
3335
3436 /** Remove element at `index` if it is present
@@ -76,6 +78,7 @@ object SparseIntArray:
7678
7779 private inline val NodeSizeLog = 5
7880 private inline val NodeSize = 1 << NodeSizeLog
81+ private inline val MaxLevels = 5 // max size is 2 ^ ((MaxLevels + 1) * NodeSizeLog) = 2 ^ 30
7982
8083 /** The exposed representation. Should be used just for nodeCount and
8184 * low-level toString.
You can’t perform that action at this time.
0 commit comments