Added checking for missing return type in alternative signature.

This commit is contained in:
Evgeny Gerashchenko
2012-06-21 17:04:48 +04:00
parent f0857d0081
commit d897ba754d
5 changed files with 65 additions and 5 deletions
@@ -156,6 +156,26 @@ class AlternativeSignatureParsing {
return result;
}
static JetType computeAlternativeReturnType(@NotNull JetType autoType, @Nullable JetTypeReference altReturnTypeRef)
throws AlternativeSignatureMismatchException {
JetType altReturnType;
if (altReturnTypeRef == null) {
if (JetStandardClasses.isUnit(autoType)) {
altReturnType = autoType;
}
else {
throw new AlternativeSignatureMismatchException(String.format(
"Return type in alternative signature is missing, while in real signature it is '%s'",
DescriptorRenderer.TEXT.renderType(autoType)));
}
}
else {
altReturnType = computeAlternativeTypeFromAnnotation(altReturnTypeRef.getTypeElement(),
autoType);
}
return altReturnType;
}
static JavaDescriptorResolver.ValueParameterDescriptors computeAlternativeValueParameters(
JavaDescriptorResolver.ValueParameterDescriptors valueParameterDescriptors,
JetNamedFunction altFunDeclaration) throws AlternativeSignatureMismatchException {
@@ -1400,11 +1400,8 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
ValueParameterDescriptors altValueParameters = AlternativeSignatureParsing
.computeAlternativeValueParameters(valueParameterDescriptors, altFunDeclaration);
JetTypeReference returnTypeRef = altFunDeclaration.getReturnTypeRef();
JetType altReturnType = returnTypeRef != null
? AlternativeSignatureParsing.computeAlternativeTypeFromAnnotation(returnTypeRef.getTypeElement(),
returnType)
: returnType;
JetType altReturnType = AlternativeSignatureParsing.computeAlternativeReturnType(returnType,
altFunDeclaration.getReturnTypeRef());
List<TypeParameterDescriptor> altTypeParameters = AlternativeSignatureParsing
.computeAlternativeTypeParameters(methodTypeParameters, altFunDeclaration);
// if no exceptions were thrown, save alternative data