Skip to content

Commit

Permalink
[NTI] Improve InlineProperties in NTI-only build, to match OTI.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173940373
  • Loading branch information
dimvar authored and brad4d committed Oct 31, 2017
1 parent a933e16 commit ffb2649
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/com/google/javascript/jscomp/InlineProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ private void invalidateProperty(String propName) {
*/
private boolean maybeStoreCandidateValue(TypeI type, String propName, Node value) {
checkNotNull(value);
if (type.toMaybeObjectType() != null) {
type = type.toMaybeObjectType().withoutStrayProperties();
}
if (!props.containsKey(propName)
&& !invalidatingTypes.isInvalidating(type)
&& NodeUtil.isImmutableValue(value)
Expand Down
22 changes: 22 additions & 0 deletions test/com/google/javascript/jscomp/InlinePropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ public void testConstInstanceProp4() {
"new C().foo;\n"));
}

public void testConstInstanceProp5() {
test(
LINE_JOINER.join(
"/** @constructor */",
"function Foo() {",
" /** @type {?number} */",
" this.a = 1;",
" /** @type {number} */",
" this.b = 2;",
"}",
"var x = (new Foo).b;"),
LINE_JOINER.join(
"/** @constructor */",
"function Foo() {",
" /** @type {?number} */",
" this.a = 1;",
" /** @type {number} */",
" this.b = 2;",
"}",
"var x = (new Foo, 2);"));
}


public void testConstClassProps1() {
// Inline constant class properties,
Expand Down

0 comments on commit ffb2649

Please sign in to comment.