ensureTable();
table.put(id, b);
}
private void updateType(NBinding b, NNode loc, NType type, NBinding.Kind kind) {
NType curType = b.followType();
if (!isNewType(curType, type)) {
if (loc != null
&& !(loc instanceof NUrl)
&& !b.getDefs().contains(loc)) {
Indexer.idx.putLocation(loc, b);
}
return;
}
if (loc != null && !b.getRefs().contains(loc)) {
b.addDef(loc);
b.setProvisional(false);
}
// The union ordering matters here. If they're two different unknown
// types, union() points the first one to the second one. We want to
// keep the binding's existing type iff its table contains provisional
// attribute bindings that we need to look up later.
NType btype = b.getType();
NType t1, t2;
if (btype.isUnknownType() && !btype.getTable().isEmpty()) {
t1 = type;
t2 = btype;
} else {
t1 = btype;
t2 = type;
}
NType newType = NUnionType.union(t1, t2);
b.setType(newType);
if (curType.isUnknownType()) {
b.setKind(kind);
}