diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java index 8c1507c7164..0201132ac27 100644 --- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java +++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java @@ -128,6 +128,11 @@ public void generateCallSiteArray() { @Override public void makeCallSite(final Expression receiver, final String message, final Expression arguments, final boolean safe, final boolean implicitThis, final boolean callCurrent, final boolean callStatic) { + throw new GroovyBugError( + "at line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" + + "On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" + + "StaticTypesCallSiteWriter#makeCallSite should not have been called. Call site lacked method target for static compilation.\n" + + "Please try to create a simple example reproducing this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY"); } @Override @@ -578,11 +583,11 @@ public void makeSingleArgumentCall(final Expression receiver, final String messa if (rType!=null && trySubscript(receiver, message, arguments, rType, aType, safe)) { return; } - // todo: more cases + // TODO: more cases throw new GroovyBugError( - "At line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" + + "at line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" + "On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" + - "This method should not have been called. Please try to create a simple example reproducing\n" + + "This method should not have been called. Please try to create a simple example reproducing " + "this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY"); } diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy11359.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy11359.groovy new file mode 100644 index 00000000000..bbeff366f2f --- /dev/null +++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy11359.groovy @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.codehaus.groovy.classgen.asm.sc.bugs + +import groovy.transform.stc.StaticTypeCheckingTestCase +import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport + +final class Groovy11359 extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport { + + void testMakeCallSite() { + config.optimizationOptions.put(config.INVOKEDYNAMIC, Boolean.FALSE) + + def err = shouldFail { + shell.evaluate '''import static org.codehaus.groovy.ast.tools.GeneralUtils.* + + @ASTTest(phase=INSTRUCTION_SELECTION, value={ + // generate `String m() { return new String("") }` + node.addMethod("m", 1, STRING_TYPE, params(), null, returnS(ctorX(STRING_TYPE, constX("")))) + }) + class C { } + ''' + } + assert err =~ 'Call site lacked method target for static compilation' + } +}