Skip to content

Commit

Permalink
GROOVY-11359: SC: add bug error for invocation of makeCallSite
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 24, 2024
1 parent c6bca93 commit bc26ebc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
}
}

0 comments on commit bc26ebc

Please sign in to comment.