No need to produce error types when RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED is reported
This commit is contained in:
+6
-8
@@ -522,18 +522,16 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
SimpleFunctionDescriptor functionDescriptor = context.trace.get(FUNCTION, labelTargetElement);
|
||||
if (functionDescriptor != null) {
|
||||
expectedType = DescriptorUtils.getFunctionExpectedReturnType(functionDescriptor, labelTargetElement);
|
||||
boolean inLambdaWithNoExplicitType = expectedType == TypeUtils.NO_EXPECTED_TYPE;
|
||||
if (inLambdaWithNoExplicitType) {
|
||||
// expectedType is NO_EXPECTED_TYPE iff the return type of the corresponding function descriptor is not computed yet
|
||||
// our temporary policy is to prohibit returns in this case. It mostly applies to local returns in lambdas
|
||||
context.trace.report(RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
}
|
||||
else if (functionDescriptor != containingFunctionDescriptor) {
|
||||
if (functionDescriptor != containingFunctionDescriptor) {
|
||||
// Qualified, non-local
|
||||
context.trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
resultType = ErrorUtils.createErrorType(RETURN_NOT_ALLOWED_MESSAGE);
|
||||
}
|
||||
else if (expectedType == TypeUtils.NO_EXPECTED_TYPE) {
|
||||
// expectedType is NO_EXPECTED_TYPE iff the return type of the corresponding function descriptor is not computed yet
|
||||
// our temporary policy is to prohibit returns in this case. It mostly applies to local returns in lambdas
|
||||
context.trace.report(RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED.on(expression));
|
||||
}
|
||||
}
|
||||
else {
|
||||
context.trace.report(NOT_A_RETURN_LABEL.on(expression, expression.getLabelName()));
|
||||
|
||||
Reference in New Issue
Block a user