@@ -750,6 +750,100 @@ public void testMethodReferences() {
750
750
assertThat (table .getReferences (method )).hasSize (3 );
751
751
}
752
752
753
+ @ Test
754
+ public void testMethodReferencesNullableClass () {
755
+ SymbolTable table =
756
+ createSymbolTable (
757
+ lines (
758
+ "class DomHelper { method() {} }" ,
759
+ "let /** ?DomHelper */ helper;" ,
760
+ "helper.method();" ));
761
+
762
+ Symbol method = getGlobalVar (table , "DomHelper.prototype.method" );
763
+ assertThat (table .getReferences (method )).hasSize (2 );
764
+ }
765
+
766
+ @ Test
767
+ public void testMethodReferencesNullableInterface () {
768
+ SymbolTable table =
769
+ createSymbolTable (
770
+ lines (
771
+ "/** @interface */ class DomHelper { method() {} }" ,
772
+ "let /** ?DomHelper */ helper;" ,
773
+ "helper.method();" ));
774
+
775
+ Symbol method = getGlobalVar (table , "DomHelper.prototype.method" );
776
+ assertThat (table .getReferences (method )).hasSize (2 );
777
+ }
778
+
779
+ @ Test
780
+ public void testMethodReferencesNullableRecord () {
781
+ SymbolTable table =
782
+ createSymbolTable (
783
+ lines (
784
+ "/** @record */ function DomHelper() {}" ,
785
+ "DomHelper.prototype.method = function() {};" ,
786
+ "let /** ?DomHelper */ helper;" ,
787
+ "helper.method();" ));
788
+
789
+ Symbol method = getGlobalVar (table , "DomHelper.prototype.method" );
790
+ assertThat (table .getReferences (method )).hasSize (2 );
791
+ }
792
+
793
+ @ Test
794
+ public void testRecordInheritance () {
795
+ SymbolTable table =
796
+ createSymbolTable (
797
+ lines (
798
+ "/** @record */ function DomHelper() {}" ,
799
+ "DomHelper.prototype.method = function() {};" ,
800
+ "" ,
801
+ "/** @record @extends {DomHelper} */ function DomHelper2() {}" ,
802
+ "DomHelper2.prototype.method2 = function() {};" ,
803
+ "" ,
804
+ "let /** ?DomHelper2 */ helper;" ,
805
+ "helper.method();" ));
806
+
807
+ Symbol method = getGlobalVar (table , "DomHelper.prototype.method" );
808
+ assertThat (table .getReferences (method )).hasSize (2 );
809
+ }
810
+
811
+ @ Test
812
+ public void testUnionType () {
813
+ SymbolTable table =
814
+ createSymbolTable (
815
+ lines (
816
+ "class First { method() {} }" ,
817
+ "class Second { method() {} }" ,
818
+ "let /** !Second|!First */ obj;" ,
819
+ "obj.method();" ));
820
+
821
+ assertThat (table .getReferences (getGlobalVar (table , "First.prototype.method" ))).hasSize (2 );
822
+ assertThat (table .getReferences (getGlobalVar (table , "Second.prototype.method" ))).hasSize (2 );
823
+ }
824
+
825
+ @ Test
826
+ public void testMultipleInterfaceInheritance () {
827
+ SymbolTable table =
828
+ createSymbolTable (
829
+ lines (
830
+ "/** @interface */" ,
831
+ "class First { doFirst() {} }" ,
832
+ "" ,
833
+ "/** @interface */" ,
834
+ "class Second { doSecond() {} }" ,
835
+ "" ,
836
+ "/** @interface @extends {First} @extends {Second} */" ,
837
+ "class Third {}" ,
838
+ "" ,
839
+ "let /** !Third */ obj;" ,
840
+ "obj.doFirst();" ,
841
+ "obj.doSecond();" ));
842
+
843
+ assertThat (table .getReferences (getGlobalVar (table , "First.prototype.doFirst" ))).hasSize (2 );
844
+ assertThat (table .getReferences (getGlobalVar (table , "Second.prototype.doSecond" ))).hasSize (2 );
845
+ }
846
+
753
847
@ Test
754
848
public void testSuperClassMethodReferences () {
755
849
SymbolTable table =
@@ -1737,7 +1831,7 @@ public void testDuplicatedWindowExternsMergedWithWindowPrototype() {
1737
1831
}
1738
1832
assertThat (refsPerFile ).containsExactly ("in1" , 2 , "externs1" , 1 );
1739
1833
}
1740
-
1834
+
1741
1835
private void assertSymmetricOrdering (Ordering <Symbol > ordering , Symbol first , Symbol second ) {
1742
1836
assertThat (ordering .compare (first , first )).isEqualTo (0 );
1743
1837
assertThat (ordering .compare (second , second )).isEqualTo (0 );
0 commit comments