17
17
package com .google .javascript .jscomp ;
18
18
19
19
import static com .google .common .truth .Truth .assertThat ;
20
- import static com .google .javascript .jscomp .CompilerTestCase .lines ;
21
20
import static com .google .javascript .jscomp .TypeValidator .TYPE_MISMATCH_WARNING ;
22
21
23
22
import com .google .common .annotations .GwtIncompatible ;
@@ -1811,7 +1810,7 @@ public void testDisambiguateProperties2() {
1811
1810
options .setRemoveDeadCode (true );
1812
1811
options .setRemoveAbstractMethods (true );
1813
1812
test (options ,
1814
- LINE_JOINER . join (
1813
+ lines (
1815
1814
"/** @const */ var goog = {};" ,
1816
1815
"goog.abstractMethod = function() {};" ,
1817
1816
"/** @interface */ function I() {}" ,
@@ -1820,7 +1819,7 @@ public void testDisambiguateProperties2() {
1820
1819
"/** @override */ Foo.prototype.a = goog.abstractMethod;" ,
1821
1820
"/** @constructor @extends Foo */ function Bar() {}" ,
1822
1821
"/** @override */ Bar.prototype.a = function(x) {};" ),
1823
- LINE_JOINER . join (
1822
+ lines (
1824
1823
"var goog={};" ,
1825
1824
"goog.abstractMethod = function() {};" ,
1826
1825
"function I(){}" ,
@@ -1830,6 +1829,35 @@ public void testDisambiguateProperties2() {
1830
1829
"Bar.prototype.a=function(x){};" ));
1831
1830
}
1832
1831
1832
+ public void testDisambiguatePropertiesWithPropertyInvalidationError () {
1833
+ CompilerOptions options = createCompilerOptions ();
1834
+ options .setClosurePass (true );
1835
+ options .setCheckTypes (true );
1836
+ options .setDisambiguateProperties (true );
1837
+ options .setPropertyInvalidationErrors (
1838
+ ImmutableMap .of ("a" , CheckLevel .ERROR ));
1839
+ options .setRemoveDeadCode (true );
1840
+ options .setRemoveAbstractMethods (true );
1841
+ test (options ,
1842
+ lines (
1843
+ "function fn(x){return x.a;}" ,
1844
+ "/** @interface */ function I() {}" ,
1845
+ "I.prototype.a = function(x) {};" ,
1846
+ "/** @constructor @implements {I} */ function Foo() {}" ,
1847
+ "/** @override */ Foo.prototype.a = function(x) {};" ,
1848
+ "/** @constructor @extends Foo */ function Bar() {}" ,
1849
+ "/** @override */ Bar.prototype.a = function(x) {};" ),
1850
+ lines (
1851
+ "function fn(x){return x.a;}" ,
1852
+ "function I(){}" ,
1853
+ "I.prototype.a=function(x){};" ,
1854
+ "function Foo(){}" ,
1855
+ "Foo.prototype.a = function(x) {};" ,
1856
+ "function Bar(){}" ,
1857
+ "Bar.prototype.a=function(x){};" ),
1858
+ DisambiguateProperties .Warnings .INVALIDATION );
1859
+ }
1860
+
1833
1861
public void testMarkPureCalls () {
1834
1862
String testCode = "function foo() {} foo();" ;
1835
1863
CompilerOptions options = createCompilerOptions ();
0 commit comments