From 346b1802ee61db362e6d43e65cb9be3d046da7b8 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Tue, 21 Jun 2016 12:53:04 -0700 Subject: [PATCH] Quick fixes for using built in method writes. --- .../elasticsearch/painless/node/EListInit.java | 2 +- .../elasticsearch/painless/node/EMapInit.java | 3 +-- .../elasticsearch/painless/InitializerTests.java | 16 ++++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EListInit.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EListInit.java index cb4d2d3a216..aa9288cc43a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EListInit.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EListInit.java @@ -90,7 +90,7 @@ public class EListInit extends AExpression { for (AExpression value : values) { writer.dup(); value.write(writer, globals); - writer.invokeInterface(method.owner.type, method.method); + method.write(writer); writer.pop(); } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EMapInit.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EMapInit.java index c583bc79e52..c031087a34d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EMapInit.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EMapInit.java @@ -27,7 +27,6 @@ import org.elasticsearch.painless.Locals; import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -114,7 +113,7 @@ public class EMapInit extends AExpression { writer.dup(); key.write(writer, globals); value.write(writer, globals); - writer.invokeInterface(method.owner.type, method.method); + method.write(writer); writer.pop(); } } diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/InitializerTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/InitializerTests.java index 282ad8a5f13..5d881632dee 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/InitializerTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/InitializerTests.java @@ -26,6 +26,7 @@ import java.util.Map; public class InitializerTests extends ScriptTestCase { + @SuppressWarnings({"unchecked", "rawtypes"}) public void testArrayInitializers() { int[] ints = (int[])exec("new int[] {}"); @@ -58,6 +59,7 @@ public class InitializerTests extends ScriptTestCase { assertEquals("aaaaaa", objects[3]); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testListInitializers() { List list = (List)exec("[]"); @@ -84,11 +86,12 @@ public class InitializerTests extends ScriptTestCase { assertEquals(4, list.size()); assertEquals(new Integer(2), list.get(0)); - assertEquals(new ArrayList(), list.get(1)); + assertEquals(new ArrayList(), list.get(1)); assertEquals("1aaa", list.get(2)); assertEquals("aaaaaa", list.get(3)); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testMapInitializers() { Map map = (Map)exec("[:]"); @@ -115,22 +118,23 @@ public class InitializerTests extends ScriptTestCase { assertEquals("aaaaaa", map.get("1aaa")); } + @SuppressWarnings({"unchecked", "rawtypes"}) public void testCrazyInitializer() { Map map = (Map)exec("int y = 2; int z = 3; Map x = [y*z : y + z, 's' : [y, [y : [[z], [], [:]]]], z : [z, 9]]; return x;"); - List list0 = new ArrayList<>(); + List list0 = new ArrayList(); list0.add(3); - List list1 = new ArrayList(); + List list1 = new ArrayList(); list1.add(list0); list1.add(new ArrayList()); list1.add(new HashMap()); - Map map0 = new HashMap<>(); + Map map0 = new HashMap(); map0.put(2, list1); - List list2 = new ArrayList(); + List list2 = new ArrayList(); list2.add(2); list2.add(map0); - List list3 = new ArrayList<>(); + List list3 = new ArrayList(); list3.add(3); list3.add(9);