Skip to content

Commit

Permalink
Small cleanups in OTI.
Browse files Browse the repository at this point in the history
- Inline a method with a misleading name.
- Remove an unused return value from a method.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187649153
  • Loading branch information
dimvar authored and Tyler Breisacher committed Mar 3, 2018
1 parent d998998 commit 3ead2ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
22 changes: 6 additions & 16 deletions src/com/google/javascript/jscomp/TypeInference.java
Expand Up @@ -435,7 +435,12 @@ private FlowScope traverse(Node n, FlowScope scope) {
case EXPR_RESULT:
scope = traverseChildren(n, scope);
if (n.getFirstChild().isGetProp()) {
ensurePropertyDeclared(n.getFirstChild());
Node getprop = n.getFirstChild();
ObjectType ownerType = ObjectType.cast(
getJSType(getprop.getFirstChild()).restrictByNotNullOrUndefined());
if (ownerType != null) {
ensurePropertyDeclaredHelper(getprop, ownerType);
}
}
break;

Expand Down Expand Up @@ -724,21 +729,6 @@ private void ensurePropertyDefined(Node getprop, JSType rightType) {
}
}

/**
* Defines a declared property if it has not been defined yet.
*
* This handles the case where a property is declared on an object where
* the object type is inferred, and so the object type will not
* be known in {@code TypedScopeCreator}.
*/
private void ensurePropertyDeclared(Node getprop) {
ObjectType ownerType = ObjectType.cast(
getJSType(getprop.getFirstChild()).restrictByNotNullOrUndefined());
if (ownerType != null) {
ensurePropertyDeclaredHelper(getprop, ownerType);
}
}

/**
* Declares a property on its owner, if necessary.
* @return True if a property was declared.
Expand Down
15 changes: 5 additions & 10 deletions src/com/google/javascript/rhino/jstype/JSTypeRegistry.java
Expand Up @@ -1673,21 +1673,16 @@ public ObjectType createAnonymousObjectType(JSDocInfo info) {

/**
* Set the implicit prototype if it's possible to do so.
* @return True if we were able to set the implicit prototype successfully,
* false if it was not possible to do so for some reason. There are
* a few different reasons why this could fail: for example, numbers
* can't be implicit prototypes, and we don't want to change the implicit
* prototype if other classes have already subclassed this one.
*/
public boolean resetImplicitPrototype(
JSType type, ObjectType newImplicitProto) {
* There are a few different reasons why this could be a no-op: for example,
* numbers can't be implicit prototypes, and we don't want to change the implicit prototype
* if other classes have already subclassed this one.
*/
public void resetImplicitPrototype(JSType type, ObjectType newImplicitProto) {
if (type instanceof PrototypeObjectType) {
PrototypeObjectType poType = (PrototypeObjectType) type;
poType.clearCachedValues();
poType.setImplicitPrototype(newImplicitProto);
return true;
}
return false;
}

/**
Expand Down

0 comments on commit 3ead2ff

Please sign in to comment.