diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java index a96153e49..81882a462 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java +++ b/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java @@ -151,7 +151,7 @@ public class Array2DHashSet implements Set { public boolean equals(Object o) { if (o == this) return true; if ( !(o instanceof Array2DHashSet) || o==null ) return false; - Array2DHashSet other = (Array2DHashSet)o; + Array2DHashSet other = (Array2DHashSet)o; if ( other.size() != size() ) return false; boolean same = this.containsAll(other); return same; @@ -224,7 +224,9 @@ public class Array2DHashSet implements Set { if ( bucket==null ) continue; for (T o : bucket) { if ( o==null ) break; - a[i++] = (U)o; + @SuppressWarnings("unchecked") // array store will check this + U targetElement = (U)o; + a[i++] = targetElement; } } return a; @@ -253,10 +255,10 @@ public class Array2DHashSet implements Set { @Override public boolean containsAll(Collection collection) { if ( collection instanceof Array2DHashSet ) { - Array2DHashSet s = (Array2DHashSet)collection; - for (T[] bucket : s.buckets) { + Array2DHashSet s = (Array2DHashSet)collection; + for (Object[] bucket : s.buckets) { if ( bucket==null ) continue; - for (T o : bucket) { + for (Object o : bucket) { if ( o==null ) break; if ( !this.contains(o) ) return false; }