Skip to content

Commit f14fb6e

Browse files
lauraharkercopybara-github
authored andcommitted
Serialize prototype and instance type instead of implicit prototype
Ambiguation needs to access a class's prototype to know the owner type of its member functions, and needs to know instance type and prototypes of constructors that are never explicitly new'd in the AST PiperOrigin-RevId: 325901890
1 parent 0ca5300 commit f14fb6e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/com/google/javascript/jscomp/colors/ObjectColor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.auto.value.AutoValue;
2020
import com.google.common.collect.ImmutableCollection;
21+
import javax.annotation.Nullable;
2122

2223
/**
2324
* A user-defined object type. For now each type is defined by a unique class name and file source.
@@ -49,6 +50,13 @@ public ImmutableCollection<Color> getAlternates() {
4950

5051
public abstract String getFilename();
5152

53+
// given `function Foo() {}` or `class Foo {}`, color of Foo.prototype. null otherwise.
54+
@Nullable
55+
public abstract Color getPrototype();
56+
57+
@Nullable
58+
public abstract Color getInstanceColor();
59+
5260
@Override
5361
public abstract boolean isInvalidating();
5462

@@ -61,6 +69,10 @@ public abstract static class Builder {
6169

6270
public abstract Builder setInvalidating(boolean value);
6371

72+
public abstract Builder setPrototype(Color prototype);
73+
74+
public abstract Builder setInstanceColor(Color instanceColor);
75+
6476
public abstract ObjectColor build();
6577
}
6678

0 commit comments

Comments
 (0)