// If there is a reassignment to one of the enum's members, don't consider
// that a definition of a new property.
if (et != null && et.enumLiteralHasKey(pname)) {
return;
}
Namespace ns = currentScope.getNamespace(QualifiedName.fromNode(recv));
JSDocInfo jsdoc = NodeUtil.getBestJSDocInfo(declNode);
JSType propDeclType = getTypeAtPropDeclNode(declNode, jsdoc);
boolean isConst = isConst(declNode);
if (propDeclType != null || isConst) {
JSType previousPropType = ns.getPropDeclaredType(pname);
if (ns.hasProp(pname) &&
previousPropType != null &&
!suppressDupPropWarning(jsdoc, propDeclType, previousPropType)) {
warnings.add(JSError.make(declNode, REDECLARED_PROPERTY,
pname, ns.toString()));
return;
}
if (isConst && !mayWarnAboutNoInit(declNode) && propDeclType == null) {
propDeclType = inferConstTypeFromRhs(declNode);
}
ns.addProperty(pname, propDeclType, isConst);
declNode.putBooleanProp(Node.ANALYZED_DURING_GTI, true);
if (declNode.isGetProp() && isConst) {
declNode.putBooleanProp(Node.CONSTANT_PROPERTY_DEF, true);
}
} else {
// Try to infer the prop type, but don't say that the prop is declared.
Node initializer = NodeUtil.getInitializer(declNode);
JSType t = initializer == null
? null : simpleInferExprType(initializer);
if (t == null) {
t = JSType.UNKNOWN;
}
ns.addUndeclaredProperty(pname, t, false);
}
}