use of org.yinwang.pysonar.types.DictType in project pysonar2 by yinwang0.
the class TypeInferencer method bind.
public void bind(@NotNull State s, Node target, @NotNull Type rvalue, Binding.Kind kind) {
if (target instanceof Name) {
bind(s, (Name) target, rvalue, kind);
} else if (target instanceof Tuple) {
bind(s, ((Tuple) target).elts, rvalue, kind);
} else if (target instanceof PyList) {
bind(s, ((PyList) target).elts, rvalue, kind);
} else if (target instanceof Attribute) {
setAttr(((Attribute) target), s, rvalue);
} else if (target instanceof Subscript) {
Subscript sub = (Subscript) target;
Type sliceType = sub.slice == null ? null : visit(sub.slice, s);
Type valueType = visit(sub.value, s);
if (valueType instanceof ListType) {
ListType t = (ListType) valueType;
t.setElementType(UnionType.union(t.eltType, rvalue));
} else if (valueType instanceof DictType) {
DictType t = (DictType) valueType;
if (sliceType != null) {
t.setKeyType(UnionType.union(t.keyType, sliceType));
}
t.setValueType(UnionType.union(t.valueType, rvalue));
}
} else if (target != null) {
addWarningToNode(target, "invalid location for assignment");
}
}
Aggregations