make explicit that graphs must be EmptyContext, never null (Coverity)

This commit is contained in:
Terence Parr 2013-08-31 16:29:40 -07:00
parent 0ac47437bc
commit 9420672520
1 changed files with 3 additions and 1 deletions

View File

@ -173,8 +173,10 @@ public abstract class PredictionContext {
boolean rootIsWildcard,
DoubleKeyMap<PredictionContext,PredictionContext,PredictionContext> mergeCache)
{
assert a!=null && b!=null; // must be empty context, never null
// share same graph if both same
if ( (a==null&&b==null) || a==b || (a!=null&&a.equals(b)) ) return a;
if ( a==b || a.equals(b) ) return a;
if ( a instanceof SingletonPredictionContext && b instanceof SingletonPredictionContext) {
return mergeSingletons((SingletonPredictionContext)a,