Skip to content

Commit

Permalink
fixed files form Closure #54
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent d4f20ad commit 51617b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,13 @@ void maybeDeclareQualifiedName(NodeTraversal t, JSDocInfo info,
// then they are responsible for making sure that the object literal's
// implicit prototype is set up appropriately. We just obey
// the @extends tag.
if (!qVar.isTypeInferred()) {
ObjectType qVarType = ObjectType.cast(qVar.getType());
if (qVarType != null &&
rhsValue != null &&
rhsValue.getType() == Token.OBJECTLIT) {
typeRegistry.resetImplicitPrototype(
rhsValue.getJSType(), qVarType.getImplicitPrototype());
} else if (!qVar.isTypeInferred()) {
// If the programmer has declared that F inherits from Super,
// and they assign F.prototype to some arbitrary expression,
// there's not much we can do. We just ignore the expression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ public void setPrototypeBasedOn(ObjectType baseType) {
//
// In the second case, we just use the anonymous object as the prototype.
if (baseType.hasReferenceName() ||
baseType.isUnknownType() ||
isNativeObjectType() ||
baseType.isFunctionPrototypeType() ||
!(baseType instanceof PrototypeObjectType)) {
Expand All @@ -363,14 +362,18 @@ public boolean setPrototype(PrototypeObjectType prototype) {
return false;
}

boolean replacedPrototype = prototype != null;
PrototypeObjectType oldPrototype = this.prototype;
boolean replacedPrototype = oldPrototype != null;

this.prototype = prototype;
this.prototypeSlot = new SimpleSlot("prototype", prototype, true);
this.prototype.setOwnerFunction(this);

if (oldPrototype != null) {
// Disassociating the old prototype makes this easier to debug--
// we don't have to worry about two prototypes running around.
oldPrototype.setOwnerFunction(null);
}

if (isConstructor() || isInterface()) {
FunctionType superClass = getSuperClassConstructor();
Expand Down

0 comments on commit 51617b4

Please sign in to comment.