@@ -3898,6 +3898,40 @@ void methodReferenceVarargs() {
3898
3898
tc .reset ();
3899
3899
}
3900
3900
3901
+ @ Test
3902
+ void nullSafeInvocationOfNonStaticVoidWrapperMethod () {
3903
+ // non-static method, no args, Void return
3904
+ expression = parser .parseExpression ("new %s()?.oneVoidWrapper()" .formatted (TestClass5 .class .getName ()));
3905
+
3906
+ assertCantCompile (expression );
3907
+
3908
+ TestClass5 ._i = 0 ;
3909
+ expression .getValue ();
3910
+ assertThat (TestClass5 ._i ).isEqualTo (1 );
3911
+
3912
+ TestClass5 ._i = 0 ;
3913
+ assertCanCompile (expression );
3914
+ expression .getValue ();
3915
+ assertThat (TestClass5 ._i ).isEqualTo (1 );
3916
+ }
3917
+
3918
+ @ Test
3919
+ void nullSafeInvocationOfStaticVoidWrapperMethod () {
3920
+ // static method, no args, Void return
3921
+ expression = parser .parseExpression ("T(%s)?.twoVoidWrapper()" .formatted (TestClass5 .class .getName ()));
3922
+
3923
+ assertCantCompile (expression );
3924
+
3925
+ TestClass5 ._i = 0 ;
3926
+ expression .getValue ();
3927
+ assertThat (TestClass5 ._i ).isEqualTo (1 );
3928
+
3929
+ TestClass5 ._i = 0 ;
3930
+ assertCanCompile (expression );
3931
+ expression .getValue ();
3932
+ assertThat (TestClass5 ._i ).isEqualTo (1 );
3933
+ }
3934
+
3901
3935
@ Test
3902
3936
void methodReference () {
3903
3937
TestClass5 tc = new TestClass5 ();
@@ -5712,8 +5746,19 @@ public void reset() {
5712
5746
5713
5747
public void one () { i = 1 ; }
5714
5748
5749
+ public Void oneVoidWrapper () {
5750
+ _i = 1 ;
5751
+ this .i = 1 ;
5752
+ return null ;
5753
+ }
5754
+
5715
5755
public static void two () { _i = 1 ; }
5716
5756
5757
+ public static Void twoVoidWrapper () {
5758
+ _i = 1 ;
5759
+ return null ;
5760
+ }
5761
+
5717
5762
public String three () { return "hello" ; }
5718
5763
public long four () { return 3277700L ; }
5719
5764
0 commit comments