Merge pull request #2423 from ericvergnaud/fix-illegal-dict-key

fix NPE
This commit is contained in:
Terence Parr 2018-11-25 09:08:45 -08:00 committed by GitHub
commit 8268fdd957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -352,7 +352,7 @@ namespace Antlr4.Runtime.Atn
for (int p = 0; p < parents.Length; p++) for (int p = 0; p < parents.Length; p++)
{ {
PredictionContext parent = parents[p]; PredictionContext parent = parents[p];
if (!uniqueParents.ContainsKey(parent)) if (parent!=null && !uniqueParents.ContainsKey(parent))
{ // don't replace { // don't replace
uniqueParents.Put(parent, parent); uniqueParents.Put(parent, parent);
} }
@ -360,7 +360,9 @@ namespace Antlr4.Runtime.Atn
for (int p = 0; p < parents.Length; p++) for (int p = 0; p < parents.Length; p++)
{ {
parents[p] = uniqueParents.Get(parents[p]); PredictionContext parent = parents[p];
if (parent!=null)
parents[p] = uniqueParents.Get(parent);
} }
} }