Browse Source

Fixed NPE caused by Statement#getReturnType returning Null

kindlich 5 years ago
parent
commit
f85ee75d6f
No known key found for this signature in database

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/BlockStatement.java View File

7
 
7
 
8
 import java.util.Arrays;
8
 import java.util.Arrays;
9
 import java.util.List;
9
 import java.util.List;
10
+import java.util.Objects;
10
 import java.util.function.Consumer;
11
 import java.util.function.Consumer;
11
 import java.util.stream.Collectors;
12
 import java.util.stream.Collectors;
12
 
13
 
96
 	public StoredType getReturnType() {
97
 	public StoredType getReturnType() {
97
 		final List<StoredType> collect = Arrays.stream(statements)
98
 		final List<StoredType> collect = Arrays.stream(statements)
98
 				.map(Statement::getReturnType)
99
 				.map(Statement::getReturnType)
100
+				.filter(Objects::nonNull)
99
 				.distinct()
101
 				.distinct()
100
 				.collect(Collectors.toList());
102
 				.collect(Collectors.toList());
101
 		if(collect.isEmpty())
103
 		if(collect.isEmpty())

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/statement/ReturnStatement.java View File

11
 import org.openzen.zenscript.codemodel.expression.Expression;
11
 import org.openzen.zenscript.codemodel.expression.Expression;
12
 import org.openzen.zenscript.codemodel.expression.ExpressionTransformer;
12
 import org.openzen.zenscript.codemodel.expression.ExpressionTransformer;
13
 import org.openzen.zenscript.codemodel.scope.TypeScope;
13
 import org.openzen.zenscript.codemodel.scope.TypeScope;
14
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
14
 import org.openzen.zenscript.codemodel.type.StoredType;
15
 import org.openzen.zenscript.codemodel.type.StoredType;
15
 
16
 
16
 /**
17
 /**
28
 	
29
 	
29
 	@Override
30
 	@Override
30
 	public StoredType getReturnType() {
31
 	public StoredType getReturnType() {
31
-		return value.type;
32
+		return value != null ? value.type : BasicTypeID.VOID.stored();
32
 	}
33
 	}
33
 	
34
 	
34
 	@Override
35
 	@Override

Loading…
Cancel
Save