Added checking for missing return type in alternative signature.
This commit is contained in:
+20
@@ -156,6 +156,26 @@ class AlternativeSignatureParsing {
|
|||||||
return result;
|
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(
|
static JavaDescriptorResolver.ValueParameterDescriptors computeAlternativeValueParameters(
|
||||||
JavaDescriptorResolver.ValueParameterDescriptors valueParameterDescriptors,
|
JavaDescriptorResolver.ValueParameterDescriptors valueParameterDescriptors,
|
||||||
JetNamedFunction altFunDeclaration) throws AlternativeSignatureMismatchException {
|
JetNamedFunction altFunDeclaration) throws AlternativeSignatureMismatchException {
|
||||||
|
|||||||
+2
-5
@@ -1400,11 +1400,8 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
|
|
||||||
ValueParameterDescriptors altValueParameters = AlternativeSignatureParsing
|
ValueParameterDescriptors altValueParameters = AlternativeSignatureParsing
|
||||||
.computeAlternativeValueParameters(valueParameterDescriptors, altFunDeclaration);
|
.computeAlternativeValueParameters(valueParameterDescriptors, altFunDeclaration);
|
||||||
JetTypeReference returnTypeRef = altFunDeclaration.getReturnTypeRef();
|
JetType altReturnType = AlternativeSignatureParsing.computeAlternativeReturnType(returnType,
|
||||||
JetType altReturnType = returnTypeRef != null
|
altFunDeclaration.getReturnTypeRef());
|
||||||
? AlternativeSignatureParsing.computeAlternativeTypeFromAnnotation(returnTypeRef.getTypeElement(),
|
|
||||||
returnType)
|
|
||||||
: returnType;
|
|
||||||
List<TypeParameterDescriptor> altTypeParameters = AlternativeSignatureParsing
|
List<TypeParameterDescriptor> altTypeParameters = AlternativeSignatureParsing
|
||||||
.computeAlternativeTypeParameters(methodTypeParameters, altFunDeclaration);
|
.computeAlternativeTypeParameters(methodTypeParameters, altFunDeclaration);
|
||||||
// if no exceptions were thrown, save alternative data
|
// if no exceptions were thrown, save alternative data
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package test;
|
||||||
|
|
||||||
|
import jet.runtime.typeinfo.KotlinSignature;
|
||||||
|
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
public class ReturnTypeMissing {
|
||||||
|
@KotlinSignature("fun foo(a : String)")
|
||||||
|
public int foo(String a) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
public open class ReturnTypeMissing : Object() {
|
||||||
|
public open fun foo(p0 : String?) : Int {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace test
|
||||||
|
|
||||||
|
public open class test.ReturnTypeMissing : java.lang.Object {
|
||||||
|
public final /*constructor*/ fun <init>(): test.ReturnTypeMissing
|
||||||
|
public open fun foo(/*0*/ p0: jet.String?): jet.Int
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user