You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/05/03 09:57:46 UTC
[groovy] branch master updated: GROOVY-9099: Throw a better
exception when validating native method reference fails(closes #914)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 9ef5c5b GROOVY-9099: Throw a better exception when validating native method reference fails(closes #914)
9ef5c5b is described below
commit 9ef5c5bd0875f503bbb23b08b0f0bbbdd3b30fb9
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri May 3 17:57:34 2019 +0800
GROOVY-9099: Throw a better exception when validating native method reference fails(closes #914)
---
.../asm/sc/StaticTypesMethodReferenceExpressionWriter.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
index a635edb..1fe3772 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
@@ -18,7 +18,6 @@
*/
package org.codehaus.groovy.classgen.asm.sc;
-import groovy.lang.GroovyRuntimeException;
import groovy.lang.Tuple;
import groovy.lang.Tuple2;
import org.codehaus.groovy.ast.ClassHelper;
@@ -36,6 +35,7 @@ import org.codehaus.groovy.classgen.asm.BytecodeHelper;
import org.codehaus.groovy.classgen.asm.MethodReferenceExpressionWriter;
import org.codehaus.groovy.classgen.asm.WriterController;
import org.codehaus.groovy.runtime.ArrayTypeUtils;
+import org.codehaus.groovy.syntax.RuntimeParserException;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -100,15 +100,16 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
addSyntheticMethodForConstructorReference(methodRefName, typeOrTargetRefType, parametersWithExactType);
}
+ // TODO move the `findMethodRefMethod` and checking to `StaticTypeCheckingVisitor`
MethodNode methodRefMethod = findMethodRefMethod(methodRefName, parametersWithExactType, typeOrTargetRef, isConstructorReference);
if (null == methodRefMethod) {
- throw new GroovyRuntimeException("Failed to find the expected method["
+ throw new RuntimeParserException("Failed to find the expected method["
+ methodRefName + "("
+ Arrays.stream(parametersWithExactType)
.map(e -> e.getType().getName())
.collect(Collectors.joining(","))
- + ")] in the type[" + typeOrTargetRefType.getName() + "]");
+ + ")] in the type[" + typeOrTargetRefType.getName() + "]", methodReferenceExpression);
}
methodRefMethod.putNodeMetaData(ORIGINAL_PARAMETERS_WITH_EXACT_TYPE, parametersWithExactType);
@@ -119,7 +120,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
if (!isClassExpr) {
if (isConstructorReference) {
// TODO move the checking code to the Parrot parser
- throw new GroovyRuntimeException("Constructor reference must be className::new");
+ throw new RuntimeParserException("Constructor reference must be className::new", methodReferenceExpression);
}
if (methodRefMethod.isStatic()) {