Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painless: Fix Bindings Bug #33274

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BindingTest(int state0, int state1) {
this.state = state0 + state1;
}

public int testAddWithState(int stateless) {
return stateless + state;
public int testAddWithState(int istateless, double dstateless) {
return istateless + state + (int)dstateless;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public void addPainlessBinding(Class<?> targetClass, String methodName, Class<?>
int methodTypeParametersSize = javaMethod.getParameterCount();

for (int typeParameterIndex = 0; typeParameterIndex < methodTypeParametersSize; ++typeParameterIndex) {
Class<?> typeParameter = typeParameters.get(typeParameterIndex);
Class<?> typeParameter = typeParameters.get(constructorTypeParametersSize + typeParameterIndex);

if (isValidType(typeParameter) == false) {
throw new IllegalArgumentException("type parameter [" + typeToCanonicalTypeName(typeParameter) + "] not found " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ class org.elasticsearch.painless.FeatureTest no_import {

# for testing
static {
int testAddWithState(int, int, int) bound_to org.elasticsearch.painless.BindingTest
int testAddWithState(int, int, int, double) bound_to org.elasticsearch.painless.BindingTest
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
public class BindingsTests extends ScriptTestCase {

public void testBasicBinding() {
assertEquals(15, exec("testAddWithState(4, 5, 6)"));
assertEquals(15, exec("testAddWithState(4, 5, 6, 0.0)"));
}

public void testRepeatedBinding() {
String script = "testAddWithState(4, 5, params.test)";
String script = "testAddWithState(4, 5, params.test, 0.0)";
Map<String, Object> params = new HashMap<>();
ExecutableScript.Factory factory = scriptEngine.compile(null, script, ExecutableScript.CONTEXT, Collections.emptyMap());
ExecutableScript executableScript = factory.newInstance(params);
Expand All @@ -48,7 +48,7 @@ public void testRepeatedBinding() {
}

public void testBoundBinding() {
String script = "testAddWithState(4, params.bound, params.test)";
String script = "testAddWithState(4, params.bound, params.test, 0.0)";
Map<String, Object> params = new HashMap<>();
ExecutableScript.Factory factory = scriptEngine.compile(null, script, ExecutableScript.CONTEXT, Collections.emptyMap());
ExecutableScript executableScript = factory.newInstance(params);
Expand Down