File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed 
main/java/org/springframework/core 
testFixtures/java/org/springframework/core/testfixture/nullness 
java/org/springframework/core 
kotlin/org/springframework/core Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -181,10 +181,10 @@ private static class KotlinDelegate {
181181
182182		public  static  Nullness  forMethodReturnType (Method  method ) {
183183			KFunction <?> function  = ReflectJvmMapping .getKotlinFunction (method );
184- 			if  (function  != null  && function .getReturnType (). isMarkedNullable () ) {
185- 				return  Nullness .NULLABLE ;
184+ 			if  (function  != null  && ReflectJvmMapping . getJavaType ( function .getReturnType ()) !=  void . class ) {
185+ 				return  ( function . getReturnType (). isMarkedNullable () ?  Nullness .NULLABLE  :  Nullness . NON_NULL ) ;
186186			}
187- 			return  Nullness .NON_NULL ;
187+ 			return  Nullness .UNSPECIFIED ;
188188		}
189189
190190		public  static  Nullness  forParameter (Executable  executable , int  parameterIndex ) {
Original file line number Diff line number Diff line change @@ -377,6 +377,13 @@ void customNullableField() throws NoSuchFieldException {
377377		Assertions .assertThat (nullness ).isEqualTo (Nullness .NULLABLE );
378378	}
379379
380+ 	@ Test 
381+ 	void  voidClassMethod () throws  NoSuchMethodException  {
382+ 		var  method  = JSpecifyProcessor .class .getMethod ("voidClassProcess" );
383+ 		var  nullness  = Nullness .forMethodReturnType (method );
384+ 		Assertions .assertThat (nullness ).isEqualTo (Nullness .UNSPECIFIED );
385+ 	}
386+ 
380387	// Primitive types 
381388
382389	@ Test 
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ class NullnessKotlinTests {
3737		Assertions .assertThat(nullness).isEqualTo(Nullness .NULLABLE )
3838	}
3939
40+ 	@Test
41+ 	fun  unitReturnType () {
42+ 		val  method =  ::unit.javaMethod!! 
43+ 		val  nullness =  Nullness .forMethodReturnType(method)
44+ 		Assertions .assertThat(nullness).isEqualTo(Nullness .UNSPECIFIED )
45+ 	}
46+ 
4047	@Test
4148	fun  nullableParameter () {
4249		val  method =  ::nullable.javaMethod!! 
@@ -78,4 +85,7 @@ class NullnessKotlinTests {
7885	@Suppress(" unused_parameter" 
7986	fun  nonNull (nonNull :  String ): String  =  " foo" 
8087
88+ 	fun  unit () {
89+ 	}
90+ 
8191}
Original file line number Diff line number Diff line change @@ -37,5 +37,9 @@ public interface JSpecifyProcessor {
3737	@ NullMarked 
3838	@ NonNull  String  nonNullMarkedProcess ();
3939
40+ 	@ NullMarked 
4041	void  voidProcess ();
42+ 
43+ 	@ NullMarked 
44+ 	void  voidClassProcess ();
4145}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments