Skip to content

Commit bc26ebc

Browse files
committed
GROOVY-11359: SC: add bug error for invocation of makeCallSite
1 parent c6bca93 commit bc26ebc

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ public void generateCallSiteArray() {
128128

129129
@Override
130130
public void makeCallSite(final Expression receiver, final String message, final Expression arguments, final boolean safe, final boolean implicitThis, final boolean callCurrent, final boolean callStatic) {
131+
throw new GroovyBugError(
132+
"at line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
133+
"On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" +
134+
"StaticTypesCallSiteWriter#makeCallSite should not have been called. Call site lacked method target for static compilation.\n" +
135+
"Please try to create a simple example reproducing this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY");
131136
}
132137

133138
@Override
@@ -578,11 +583,11 @@ public void makeSingleArgumentCall(final Expression receiver, final String messa
578583
if (rType!=null && trySubscript(receiver, message, arguments, rType, aType, safe)) {
579584
return;
580585
}
581-
// todo: more cases
586+
// TODO: more cases
582587
throw new GroovyBugError(
583-
"At line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
588+
"at line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
584589
"On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" +
585-
"This method should not have been called. Please try to create a simple example reproducing\n" +
590+
"This method should not have been called. Please try to create a simple example reproducing " +
586591
"this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY");
587592
}
588593

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.codehaus.groovy.classgen.asm.sc.bugs
20+
21+
import groovy.transform.stc.StaticTypeCheckingTestCase
22+
import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
23+
24+
final class Groovy11359 extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
25+
26+
void testMakeCallSite() {
27+
config.optimizationOptions.put(config.INVOKEDYNAMIC, Boolean.FALSE)
28+
29+
def err = shouldFail {
30+
shell.evaluate '''import static org.codehaus.groovy.ast.tools.GeneralUtils.*
31+
32+
@ASTTest(phase=INSTRUCTION_SELECTION, value={
33+
// generate `String m() { return new String("") }`
34+
node.addMethod("m", 1, STRING_TYPE, params(), null, returnS(ctorX(STRING_TYPE, constX(""))))
35+
})
36+
class C { }
37+
'''
38+
}
39+
assert err =~ 'Call site lacked method target for static compilation'
40+
}
41+
}

0 commit comments

Comments
 (0)