Skip to content

Commit

Permalink
Rename FunctionTypeI#getSubTypes to getDirectSubTypes.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=160461241
  • Loading branch information
shicks authored and brad4d committed Jun 29, 2017
1 parent e625c6a commit b9f92fc
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/AmbiguateProperties.java
Expand Up @@ -302,7 +302,7 @@ private void computeRelatedTypes(TypeI type) {
// A class/interface is related to its subclasses/implementors. // A class/interface is related to its subclasses/implementors.
FunctionTypeI constructor = type.toMaybeObjectType().getConstructor(); FunctionTypeI constructor = type.toMaybeObjectType().getConstructor();
if (constructor != null) { if (constructor != null) {
for (FunctionTypeI subType : constructor.getSubTypes()) { for (FunctionTypeI subType : constructor.getDirectSubTypes()) {
addRelatedInstance(subType, related); addRelatedInstance(subType, related);
} }
} }
Expand Down
Expand Up @@ -891,7 +891,7 @@ private Iterable<? extends TypeI> getTypeAlternatives(TypeI type) {
FunctionTypeI constructor = objType != null ? objType.getConstructor() : null; FunctionTypeI constructor = objType != null ? objType.getConstructor() : null;
if (constructor != null && constructor.isInterface()) { if (constructor != null && constructor.isInterface()) {
List<TypeI> list = new ArrayList<>(); List<TypeI> list = new ArrayList<>();
for (FunctionTypeI impl : constructor.getSubTypes()) { for (FunctionTypeI impl : constructor.getDirectSubTypes()) {
list.add(impl.getInstanceType()); list.add(impl.getInstanceType());
} }
return list.isEmpty() ? null : list; return list.isEmpty() ? null : list;
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/newtypes/JSType.java
Expand Up @@ -1867,7 +1867,7 @@ public final Node getSource() {
} }


@Override @Override
public final Collection<FunctionTypeI> getSubTypes() { public final Collection<FunctionTypeI> getDirectSubTypes() {
Preconditions.checkState(this.isConstructor() || this.isInterface()); Preconditions.checkState(this.isConstructor() || this.isInterface());
ImmutableList.Builder<FunctionTypeI> result = ImmutableList.builder(); ImmutableList.Builder<FunctionTypeI> result = ImmutableList.builder();
NominalType nt = NominalType nt =
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/rhino/FunctionTypeI.java
Expand Up @@ -81,7 +81,7 @@ public interface FunctionTypeI extends TypeI {
* null. This allows a downward traversal of the subtype graph. * null. This allows a downward traversal of the subtype graph.
*/ */
// TODO(sdh): change the name to getDirectSubTypes() // TODO(sdh): change the name to getDirectSubTypes()
Iterable<FunctionTypeI> getSubTypes(); Iterable<FunctionTypeI> getDirectSubTypes();


/** Gets the type of {@code this} in this function. */ /** Gets the type of {@code this} in this function. */
TypeI getTypeOfThis(); TypeI getTypeOfThis();
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/rhino/jstype/FunctionType.java
Expand Up @@ -1264,7 +1264,7 @@ public void clearCachedValues() {
} }


@Override @Override
public Iterable<FunctionTypeI> getSubTypes() { public Iterable<FunctionTypeI> getDirectSubTypes() {
return Iterables.concat( return Iterables.concat(
subTypes != null ? subTypes : ImmutableList.<FunctionTypeI>of(), subTypes != null ? subTypes : ImmutableList.<FunctionTypeI>of(),
this.registry.getDirectImplementors(this)); this.registry.getDirectImplementors(this));
Expand Down
Expand Up @@ -144,7 +144,7 @@ public void testExternSubTypes() throws Exception {
List<FunctionTypeI> subtypes = List<FunctionTypeI> subtypes =
ImmutableList.copyOf( ImmutableList.copyOf(
((ObjectType) getLastCompiler().getTypeRegistry().getType("Error")) ((ObjectType) getLastCompiler().getTypeRegistry().getType("Error"))
.getConstructor().getSubTypes()); .getConstructor().getDirectSubTypes());
for (FunctionTypeI type : subtypes) { for (FunctionTypeI type : subtypes) {
String typeName = type.getInstanceType().toString(); String typeName = type.getInstanceType().toString();
FunctionType typeInRegistry = ((ObjectType) getLastCompiler() FunctionType typeInRegistry = ((ObjectType) getLastCompiler()
Expand Down
10 changes: 5 additions & 5 deletions test/com/google/javascript/rhino/jstype/JSTypeTest.java
Expand Up @@ -6186,19 +6186,19 @@ public void testGetAndSetJSDocInfoWithNoType() throws Exception {
public void testObjectGetSubTypes() throws Exception { public void testObjectGetSubTypes() throws Exception {
assertTrue( assertTrue(
containsType( containsType(
OBJECT_FUNCTION_TYPE.getSubTypes(), googBar)); OBJECT_FUNCTION_TYPE.getDirectSubTypes(), googBar));
assertTrue( assertTrue(
containsType( containsType(
googBar.getSubTypes(), googSubBar)); googBar.getDirectSubTypes(), googSubBar));
assertFalse( assertFalse(
containsType( containsType(
googBar.getSubTypes(), googSubSubBar)); googBar.getDirectSubTypes(), googSubSubBar));
assertFalse( assertFalse(
containsType( containsType(
googSubBar.getSubTypes(), googSubBar)); googSubBar.getDirectSubTypes(), googSubBar));
assertTrue( assertTrue(
containsType( containsType(
googSubBar.getSubTypes(), googSubSubBar)); googSubBar.getDirectSubTypes(), googSubSubBar));
} }


public void testImplementingType() throws Exception { public void testImplementingType() throws Exception {
Expand Down

0 comments on commit b9f92fc

Please sign in to comment.