Bug 408966: [1.8][inline] Invalid inline constant and inline temp refactorings using lambda expressions
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/in/TestInlineLambda.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/in/TestInlineLambda.java
new file mode 100644
index 0000000..d98d9a9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/in/TestInlineLambda.java
@@ -0,0 +1,58 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambda {
+ public static final FI fi = x -> x++;
+
+ static {
+ FI a = fi; // [1]
+ FI b;
+ b = fi; // [2]
+ }
+
+ private FI fun1() {
+ return fi; // [3]
+ }
+
+ FI[] c = new FI[] {fi, fi}; // [4]
+ FI[][] d = new FI[][] {{fi, fi}, {fi}}; // [5]
+ FI[] e = {fi, fi}; // [6]
+ FI[][] f = {{fi}, {fi}}; // [7]
+
+ int g = fun2(fi); // [8]
+ TestInlineLambda h = new TestInlineLambda(fi); // [9]
+ private int fun2(FI fi) {return 0;}
+ public TestInlineLambda(FI fi) {}
+
+ private void fun3() {
+ F f1 = (fi_p) -> fi; // [10]
+ F f2 = (fi_p) -> {
+ return fi; // [11]
+ };
+ boolean flag = true;
+ FI fi4 = flag ? fi : fi; // [12]
+ }
+
+ enum E {
+ E_C1(fi); // [13]
+ E(FI fi) {
+ }
+ }
+
+}
+
+enum E1 {
+ E_C1(TestInlineLambda.fi); // [14]
+ E1(FI fi) {
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/out/TestInlineLambda.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/out/TestInlineLambda.java
new file mode 100644
index 0000000..5656775
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test0/out/TestInlineLambda.java
@@ -0,0 +1,56 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambda {
+ static {
+ FI a = x -> x++; // [1]
+ FI b;
+ b = x -> x++; // [2]
+ }
+
+ private FI fun1() {
+ return x -> x++; // [3]
+ }
+
+ FI[] c = new FI[] {x -> x++, x -> x++}; // [4]
+ FI[][] d = new FI[][] {{x -> x++, x -> x++}, {x -> x++}}; // [5]
+ FI[] e = {x -> x++, x -> x++}; // [6]
+ FI[][] f = {{x -> x++}, {x -> x++}}; // [7]
+
+ int g = fun2(x -> x++); // [8]
+ TestInlineLambda h = new TestInlineLambda(x -> x++); // [9]
+ private int fun2(FI fi) {return 0;}
+ public TestInlineLambda(FI fi) {}
+
+ private void fun3() {
+ F f1 = (fi_p) -> x -> x++; // [10]
+ F f2 = (fi_p) -> {
+ return x -> x++; // [11]
+ };
+ boolean flag = true;
+ FI fi4 = flag ? x -> x++ : x -> x++; // [12]
+ }
+
+ enum E {
+ E_C1(x -> x++); // [13]
+ E(FI fi) {
+ }
+ }
+
+}
+
+enum E1 {
+ E_C1(x -> x++); // [14]
+ E1(FI fi) {
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/in/TestInlineLambda_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/in/TestInlineLambda_Cast.java
new file mode 100644
index 0000000..6d7af08
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/in/TestInlineLambda_Cast.java
@@ -0,0 +1,47 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambda_Cast {
+ public static final FI fi = x -> x++;
+
+ private FI fun3() {
+ F a = o -> null;
+ return a.bar(fi); // [1]
+ }
+
+ private Object fun5() {
+ Object o = fi; // [2]
+ F fx = (z) -> {
+ z = fi; // [3]
+ return null;
+ };
+
+ Object fi2;
+ fi2 = fi; // [4]
+
+ Object[] b = new Object[] { fi, fi }; // [5]
+ Object[][] c = new Object[][] { { fi }, { fi } }; // [6]
+ Object[] d = { fi, fi }; // [7]
+ Object[][] e = { { fi }, { fi } }; // [8]
+
+ System.out.println(fi); // [9]
+
+ Object fi4 = true ? fi : fi; // [10]
+ System.out.println(true ? fi : fi); // [11]
+
+ int x2 = fi.foo(10); // [12]
+
+ return fi; // [13]
+ }
+
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/out/TestInlineLambda_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/out/TestInlineLambda_Cast.java
new file mode 100644
index 0000000..fec18ab
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1/out/TestInlineLambda_Cast.java
@@ -0,0 +1,45 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambda_Cast {
+ private FI fun3() {
+ F a = o -> null;
+ return a.bar((FI) x -> x++); // [1]
+ }
+
+ private Object fun5() {
+ Object o = (FI) x -> x++; // [2]
+ F fx = (z) -> {
+ z = (FI) x -> x++; // [3]
+ return null;
+ };
+
+ Object fi2;
+ fi2 = (FI) x -> x++; // [4]
+
+ Object[] b = new Object[] { (FI) x -> x++, (FI) x -> x++ }; // [5]
+ Object[][] c = new Object[][] { { (FI) x -> x++ }, { (FI) x -> x++ } }; // [6]
+ Object[] d = { (FI) x -> x++, (FI) x -> x++ }; // [7]
+ Object[][] e = { { (FI) x -> x++ }, { (FI) x -> x++ } }; // [8]
+
+ System.out.println((FI) x -> x++); // [9]
+
+ Object fi4 = true ? (FI) x -> x++ : (FI) x -> x++; // [10]
+ System.out.println(true ? (FI) x -> x++ : (FI) x -> x++); // [11]
+
+ int x2 = ((FI) x -> x++).foo(10); // [12]
+
+ return (FI) x -> x++; // [13]
+ }
+
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/in/TestInlineMethodRef.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/in/TestInlineMethodRef.java
new file mode 100644
index 0000000..f75d50f
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/in/TestInlineMethodRef.java
@@ -0,0 +1,49 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRef {
+ public static final FI fi = TestInlineMethodRef::m;
+
+ private static int m(int x) {
+ return x++;
+ }
+
+ static {
+ FI a = fi; // [1]
+ FI b;
+ b = fi; // [2]
+ }
+
+ private FI fun1() {
+ return fi; // [3]
+ }
+
+ FI[] c = new FI[] {fi, fi}; // [4]
+ FI[][] d = new FI[][] {{fi, fi}, {fi}}; // [5]
+ FI[] e = {fi, fi}; // [6]
+ FI[][] f = {{fi}, {fi}}; // [7]
+
+ int g = fun2(fi); // [8]
+ TestInlineMethodRef h = new TestInlineMethodRef(fi); // [9]
+ private int fun2(FI fi) {return 0;}
+ public TestInlineMethodRef(FI fi) {}
+
+ private void fun3() {
+ F f1 = (fi_p) -> fi; // [10]
+ F f2 = (fi_p) -> {
+ return fi; // [11]
+ };
+ boolean flag = true;
+ FI fi4 = flag ? fi : fi; // [12]
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/out/TestInlineMethodRef.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/out/TestInlineMethodRef.java
new file mode 100644
index 0000000..9d9c601
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1000/out/TestInlineMethodRef.java
@@ -0,0 +1,47 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRef {
+ private static int m(int x) {
+ return x++;
+ }
+
+ static {
+ FI a = TestInlineMethodRef::m; // [1]
+ FI b;
+ b = TestInlineMethodRef::m; // [2]
+ }
+
+ private FI fun1() {
+ return TestInlineMethodRef::m; // [3]
+ }
+
+ FI[] c = new FI[] {TestInlineMethodRef::m, TestInlineMethodRef::m}; // [4]
+ FI[][] d = new FI[][] {{TestInlineMethodRef::m, TestInlineMethodRef::m}, {TestInlineMethodRef::m}}; // [5]
+ FI[] e = {TestInlineMethodRef::m, TestInlineMethodRef::m}; // [6]
+ FI[][] f = {{TestInlineMethodRef::m}, {TestInlineMethodRef::m}}; // [7]
+
+ int g = fun2(TestInlineMethodRef::m); // [8]
+ TestInlineMethodRef h = new TestInlineMethodRef(TestInlineMethodRef::m); // [9]
+ private int fun2(FI fi) {return 0;}
+ public TestInlineMethodRef(FI fi) {}
+
+ private void fun3() {
+ F f1 = (fi_p) -> TestInlineMethodRef::m; // [10]
+ F f2 = (fi_p) -> {
+ return TestInlineMethodRef::m; // [11]
+ };
+ boolean flag = true;
+ FI fi4 = flag ? TestInlineMethodRef::m : TestInlineMethodRef::m; // [12]
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/in/TestInlineMethodRef_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/in/TestInlineMethodRef_Cast.java
new file mode 100644
index 0000000..5ecec4d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/in/TestInlineMethodRef_Cast.java
@@ -0,0 +1,50 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRef_Cast {
+ public static final FI fi = TestInlineMethodRef_Cast::m;
+
+ private static int m(int x) {
+ return x++;
+ }
+
+ private FI fun3() {
+ F a = o -> null;
+ return a.bar(fi); // [1]
+ }
+
+ private Object fun5() {
+ Object o = fi; // [2]
+ F fx = (z) -> {
+ z = fi; // [3]
+ return null;
+ };
+
+ Object fi2;
+ fi2 = fi; // [4]
+
+ Object[] b = new Object[] { fi, fi }; // [5]
+ Object[][] c = new Object[][] { { fi }, { fi } }; // [6]
+ Object[] d = { fi, fi }; // [7]
+ Object[][] e = { { fi }, { fi } }; // [8]
+
+ System.out.println(fi); // [9]
+
+ Object fi4 = true ? fi : fi; // [10]
+ System.out.println(true ? fi : fi); // [11]
+
+ int x2 = fi.foo(10); // [12]
+
+ return fi; // [13]
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/out/TestInlineMethodRef_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/out/TestInlineMethodRef_Cast.java
new file mode 100644
index 0000000..0c307f6
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1001/out/TestInlineMethodRef_Cast.java
@@ -0,0 +1,48 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRef_Cast {
+ private static int m(int x) {
+ return x++;
+ }
+
+ private FI fun3() {
+ F a = o -> null;
+ return a.bar((FI) TestInlineMethodRef_Cast::m); // [1]
+ }
+
+ private Object fun5() {
+ Object o = (FI) TestInlineMethodRef_Cast::m; // [2]
+ F fx = (z) -> {
+ z = (FI) TestInlineMethodRef_Cast::m; // [3]
+ return null;
+ };
+
+ Object fi2;
+ fi2 = (FI) TestInlineMethodRef_Cast::m; // [4]
+
+ Object[] b = new Object[] { (FI) TestInlineMethodRef_Cast::m, (FI) TestInlineMethodRef_Cast::m }; // [5]
+ Object[][] c = new Object[][] { { (FI) TestInlineMethodRef_Cast::m }, { (FI) TestInlineMethodRef_Cast::m } }; // [6]
+ Object[] d = { (FI) TestInlineMethodRef_Cast::m, (FI) TestInlineMethodRef_Cast::m }; // [7]
+ Object[][] e = { { (FI) TestInlineMethodRef_Cast::m }, { (FI) TestInlineMethodRef_Cast::m } }; // [8]
+
+ System.out.println((FI) TestInlineMethodRef_Cast::m); // [9]
+
+ Object fi4 = true ? (FI) TestInlineMethodRef_Cast::m : (FI) TestInlineMethodRef_Cast::m; // [10]
+ System.out.println(true ? (FI) TestInlineMethodRef_Cast::m : (FI) TestInlineMethodRef_Cast::m); // [11]
+
+ int x2 = ((FI) TestInlineMethodRef_Cast::m).foo(10); // [12]
+
+ return (FI) TestInlineMethodRef_Cast::m; // [13]
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(Object o);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/in/TestInlineMethodRefArray.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/in/TestInlineMethodRefArray.java
new file mode 100644
index 0000000..8e9f383
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/in/TestInlineMethodRefArray.java
@@ -0,0 +1,20 @@
+// 5, 30 -> 5, 35 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRefArray {
+ public static final FI[] fiArr = { TestInlineMethodRefArray::m };
+
+ private static int m(int x) {
+ return x++;
+ }
+
+ FI[] a = fiArr;
+ FI[][] b = { fiArr };
+ Object[] c = fiArr;
+ Object[][] d = { fiArr };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/out/TestInlineMethodRefArray.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/out/TestInlineMethodRefArray.java
new file mode 100644
index 0000000..fbeae1a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1002/out/TestInlineMethodRefArray.java
@@ -0,0 +1,18 @@
+// 5, 30 -> 5, 35 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineMethodRefArray {
+ private static int m(int x) {
+ return x++;
+ }
+
+ FI[] a = new FI[]{ TestInlineMethodRefArray::m };
+ FI[][] b = { new FI[]{ TestInlineMethodRefArray::m } };
+ Object[] c = new FI[]{ TestInlineMethodRefArray::m };
+ Object[][] d = { new FI[]{ TestInlineMethodRefArray::m } };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/in/TestInlineMethodRef_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/in/TestInlineMethodRef_Ambiguous.java
new file mode 100644
index 0000000..94aad6d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/in/TestInlineMethodRef_Ambiguous.java
@@ -0,0 +1,51 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClass extends SuperClass {
+ public static final FI fi = TestClass::m;
+ private static int m(int x) {
+ return x++;
+ }
+
+ {
+ bar(0, fi); // [1]
+ super.bar(0, fi); // [2]
+ }
+
+ TestClass() {
+ this(0, fi); // [3]
+ }
+
+ TestClass(int i, FI a) {
+ super(i, fi); // [4]
+ }
+
+ TestClass(int i, FX b) { }
+
+ {
+ new TestClass(0, fi); // [5]
+ }
+
+ void bar(int x, FX fx) {
+ System.out.println();
+ }
+}
+
+class SuperClass {
+ public SuperClass() { }
+ SuperClass(int i, FI fi) { }
+ SuperClass(int x, FX fx) { }
+
+ void bar(int i, FI fi) { }
+ void bar(int x, FX fx) { }
+}
+
+@FunctionalInterface
+interface FI {
+int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/out/TestInlineMethodRef_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/out/TestInlineMethodRef_Ambiguous.java
new file mode 100644
index 0000000..8defc90
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test1003/out/TestInlineMethodRef_Ambiguous.java
@@ -0,0 +1,50 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClass extends SuperClass {
+ private static int m(int x) {
+ return x++;
+ }
+
+ {
+ bar(0, (FI) TestClass::m); // [1]
+ super.bar(0, (FI) TestClass::m); // [2]
+ }
+
+ TestClass() {
+ this(0, (FI) TestClass::m); // [3]
+ }
+
+ TestClass(int i, FI a) {
+ super(i, (FI) TestClass::m); // [4]
+ }
+
+ TestClass(int i, FX b) { }
+
+ {
+ new TestClass(0, (FI) TestClass::m); // [5]
+ }
+
+ void bar(int x, FX fx) {
+ System.out.println();
+ }
+}
+
+class SuperClass {
+ public SuperClass() { }
+ SuperClass(int i, FI fi) { }
+ SuperClass(int x, FX fx) { }
+
+ void bar(int i, FI fi) { }
+ void bar(int x, FX fx) { }
+}
+
+@FunctionalInterface
+interface FI {
+int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/in/TestInlineLambdaArray.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/in/TestInlineLambdaArray.java
new file mode 100644
index 0000000..b7ef711
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/in/TestInlineLambdaArray.java
@@ -0,0 +1,15 @@
+// 5, 30 -> 5, 35 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambdaArray {
+ public static final FI[] fiArr = { x -> x++ };
+ FI[] a = fiArr;
+ FI[][] b = { fiArr };
+ Object[] c = fiArr;
+ Object[][] d = { fiArr };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/out/TestInlineLambdaArray.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/out/TestInlineLambdaArray.java
new file mode 100644
index 0000000..3b2d34a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test2/out/TestInlineLambdaArray.java
@@ -0,0 +1,14 @@
+// 5, 30 -> 5, 35 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestInlineLambdaArray {
+ FI[] a = new FI[]{ x -> x++ };
+ FI[][] b = { new FI[]{ x -> x++ } };
+ Object[] c = new FI[]{ x -> x++ };
+ Object[][] d = { new FI[]{ x -> x++ } };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/in/TestInlineLambda_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/in/TestInlineLambda_Ambiguous.java
new file mode 100644
index 0000000..7fdb425
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/in/TestInlineLambda_Ambiguous.java
@@ -0,0 +1,54 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClass extends SuperClass {
+ public static final FI fi = x -> x++;
+
+ {
+ bar(0, fi); // [1]
+ super.bar(0, fi); // [2]
+ }
+
+ TestClass() {
+ this(0, fi); // [3]
+ }
+
+ TestClass(int i, FI a) {
+ super(i, fi); // [4]
+ }
+
+ TestClass(int i, FX b) { }
+
+ {
+ new TestClass(0, fi); // [5]
+ }
+
+ void bar(int x, FX fx) {
+ System.out.println();
+ }
+}
+
+class SuperClass {
+ public SuperClass() { }
+ SuperClass(int i, FI fi) { }
+ SuperClass(int x, FX fx) { }
+
+ void bar(int i, FI fi) { }
+ void bar(int x, FX fx) { }
+}
+
+enum E {
+ EE(0, TestClass.fi); // [6]
+ E(int i, FI fi) { }
+ E(int s, FX fl) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+ int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/out/TestInlineLambda_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/out/TestInlineLambda_Ambiguous.java
new file mode 100644
index 0000000..3bf6e58
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test3/out/TestInlineLambda_Ambiguous.java
@@ -0,0 +1,52 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClass extends SuperClass {
+ {
+ bar(0, (FI) x -> x++); // [1]
+ super.bar(0, (FI) x -> x++); // [2]
+ }
+
+ TestClass() {
+ this(0, (FI) x -> x++); // [3]
+ }
+
+ TestClass(int i, FI a) {
+ super(i, (FI) x -> x++); // [4]
+ }
+
+ TestClass(int i, FX b) { }
+
+ {
+ new TestClass(0, (FI) x -> x++); // [5]
+ }
+
+ void bar(int x, FX fx) {
+ System.out.println();
+ }
+}
+
+class SuperClass {
+ public SuperClass() { }
+ SuperClass(int i, FI fi) { }
+ SuperClass(int x, FX fx) { }
+
+ void bar(int i, FI fi) { }
+ void bar(int x, FX fx) { }
+}
+
+enum E {
+ EE(0, (FI) x -> x++); // [6]
+ E(int i, FI fi) { }
+ E(int s, FX fl) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+ int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/in/TestInlineLambda_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/in/TestInlineLambda_Ambiguous.java
new file mode 100644
index 0000000..7a7fd6d
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/in/TestInlineLambda_Ambiguous.java
@@ -0,0 +1,36 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClassN extends SuperClassN implements SuperInterfaceN {
+ public static final FI fi = x -> x++;
+
+ {
+ bar1(0, fi); // [1]
+ bar2(0, fi); // [2]
+ bar3(0, fi, 1); // [3]
+ }
+
+ void bar1(int x, FI fi) { }
+ void bar2(int x, FI fi) { }
+
+ void bar3(int i, FI fi, int j) { }
+ void bar3(int i, String s, int j) { }
+}
+
+class SuperClassN {
+ private void bar1(int i, FX fx) { }
+}
+
+interface SuperInterfaceN {
+ static void bar2(int i, FX fx) { };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+ int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/out/TestInlineLambda_Ambiguous.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/out/TestInlineLambda_Ambiguous.java
new file mode 100644
index 0000000..4bccbcb
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test4/out/TestInlineLambda_Ambiguous.java
@@ -0,0 +1,34 @@
+// 5, 28 -> 5, 30 replaceAll = true, removeDeclaration = true
+package p;
+
+class TestClassN extends SuperClassN implements SuperInterfaceN {
+ {
+ bar1(0, x -> x++); // [1]
+ bar2(0, x -> x++); // [2]
+ bar3(0, x -> x++, 1); // [3]
+ }
+
+ void bar1(int x, FI fi) { }
+ void bar2(int x, FI fi) { }
+
+ void bar3(int i, FI fi, int j) { }
+ void bar3(int i, String s, int j) { }
+}
+
+class SuperClassN {
+ private void bar1(int i, FX fx) { }
+}
+
+interface SuperInterfaceN {
+ static void bar2(int i, FX fx) { };
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface FX {
+ int foo(String s);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/in/TestInlineLambda_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/in/TestInlineLambda_Cast.java
new file mode 100644
index 0000000..f02be50
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/in/TestInlineLambda_Cast.java
@@ -0,0 +1,22 @@
+// 15, 30 -> 15, 36 replaceAll = true, removeDeclaration = true
+package p;
+
+interface ISup {
+ int foo(double x);
+ int foo(float x);
+}
+
+@FunctionalInterface
+interface FSub {
+ int foo(int x);
+}
+
+class TestInlineLambda1 {
+ public static final FSub fi_sub = x -> x++;
+
+ {
+ fun1((ISup) fi_sub);
+ }
+
+ private void fun1(ISup sup) { }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/out/TestInlineLambda_Cast.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/out/TestInlineLambda_Cast.java
new file mode 100644
index 0000000..ee0b4a4
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineConstant/canInline18/test5/out/TestInlineLambda_Cast.java
@@ -0,0 +1,20 @@
+// 15, 30 -> 15, 36 replaceAll = true, removeDeclaration = true
+package p;
+
+interface ISup {
+ int foo(double x);
+ int foo(float x);
+}
+
+@FunctionalInterface
+interface FSub {
+ int foo(int x);
+}
+
+class TestInlineLambda1 {
+ {
+ fun1((ISup) (FSub) x -> x++);
+ }
+
+ private void fun1(ISup sup) { }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_in.java
new file mode 100644
index 0000000..6f909b9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_in.java
@@ -0,0 +1,40 @@
+package p;
+
+class TestInlineLambda0 {
+
+ private FI fun1() {
+ final FI fi = x -> x++;
+
+ FI fi1 = fi; // [1]
+ FI fi2;
+ fi2 = fi; // [2]
+
+ FI[] a = new FI[] {fi, fi}; // [3]
+ FI[][] b = new FI[][] {{fi, fi}, {fi}}; // [4]
+ FI[] c = {fi, fi}; // [5]
+ FI[][] d = {{fi}, {fi}}; // [6]
+
+ int x1 = fun2(fi); // [7]
+ TestInlineLambda0 c1 = new TestInlineLambda0(fi); // [8]
+ F f1 = (fi_p) -> fi; // [9]
+ F f2 = (fi_p) -> {
+ return fi; // [10]
+ };
+ f1.bar(fi); // [11]
+ FI fi4 = true ? fi : fi; // [12]
+ return fi; // [13]
+ }
+
+ private int fun2(FI fi) {return 0;}
+ public TestInlineLambda0(FI fi) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(FI fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_out.java
new file mode 100644
index 0000000..b8e7931
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test0_out.java
@@ -0,0 +1,38 @@
+package p;
+
+class TestInlineLambda0 {
+
+ private FI fun1() {
+ FI fi1 = x -> x++; // [1]
+ FI fi2;
+ fi2 = x -> x++; // [2]
+
+ FI[] a = new FI[] {x -> x++, x -> x++}; // [3]
+ FI[][] b = new FI[][] {{x -> x++, x -> x++}, {x -> x++}}; // [4]
+ FI[] c = {x -> x++, x -> x++}; // [5]
+ FI[][] d = {{x -> x++}, {x -> x++}}; // [6]
+
+ int x1 = fun2(x -> x++); // [7]
+ TestInlineLambda0 c1 = new TestInlineLambda0(x -> x++); // [8]
+ F f1 = (fi_p) -> x -> x++; // [9]
+ F f2 = (fi_p) -> {
+ return x -> x++; // [10]
+ };
+ f1.bar(x -> x++); // [11]
+ FI fi4 = true ? x -> x++ : x -> x++; // [12]
+ return x -> x++; // [13]
+ }
+
+ private int fun2(FI fi) {return 0;}
+ public TestInlineLambda0(FI fi) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(FI fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_in.java
new file mode 100644
index 0000000..eaabf2a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_in.java
@@ -0,0 +1,44 @@
+package p;
+
+class TestInlineMethodReference0 {
+
+ private FI fun1() {
+ final FI fi = this::m;
+
+ FI fi1 = fi; // [1]
+ FI fi2;
+ fi2 = fi; // [2]
+
+ FI[] a = new FI[] {fi, fi}; // [3]
+ FI[][] b = new FI[][] {{fi, fi}, {fi}}; // [4]
+ FI[] c = {fi, fi}; // [5]
+ FI[][] d = {{fi}, {fi}}; // [6]
+
+ int x1 = fun2(fi); // [7]
+ TestInlineMethodReference0 c1 = new TestInlineMethodReference0(fi); // [8]
+ F f1 = (fi_p) -> fi; // [9]
+ F f2 = (fi_p) -> {
+ return fi; // [10]
+ };
+ f1.bar(fi); // [11]
+ FI fi4 = true ? fi : fi; // [12]
+ return fi; // [13]
+ }
+
+ private int fun2(FI fi) {return 0;}
+ public TestInlineMethodReference0(FI fi) { }
+
+ int m(int x) {
+ return x++;
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(FI fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_out.java
new file mode 100644
index 0000000..aee68cd
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1000_out.java
@@ -0,0 +1,42 @@
+package p;
+
+class TestInlineMethodReference0 {
+
+ private FI fun1() {
+ FI fi1 = this::m; // [1]
+ FI fi2;
+ fi2 = this::m; // [2]
+
+ FI[] a = new FI[] {this::m, this::m}; // [3]
+ FI[][] b = new FI[][] {{this::m, this::m}, {this::m}}; // [4]
+ FI[] c = {this::m, this::m}; // [5]
+ FI[][] d = {{this::m}, {this::m}}; // [6]
+
+ int x1 = fun2(this::m); // [7]
+ TestInlineMethodReference0 c1 = new TestInlineMethodReference0(this::m); // [8]
+ F f1 = (fi_p) -> this::m; // [9]
+ F f2 = (fi_p) -> {
+ return this::m; // [10]
+ };
+ f1.bar(this::m); // [11]
+ FI fi4 = true ? this::m : this::m; // [12]
+ return this::m; // [13]
+ }
+
+ private int fun2(FI fi) {return 0;}
+ public TestInlineMethodReference0(FI fi) { }
+
+ int m(int x) {
+ return x++;
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ FI bar(FI fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_in.java
new file mode 100644
index 0000000..c97a034
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_in.java
@@ -0,0 +1,44 @@
+package p;
+
+class TestInlineMethodReference1 {
+
+ private Object fun1() {
+ final FI fi = this::m;
+
+ Object fi1 = fi; // [1]
+ Object fi2;
+ fi2 = fi; // [2]
+
+ Object[] a = new Object[] {fi, fi}; // [3]
+ Object[][] b = new Object[][] {{fi, fi}, {fi}}; // [4]
+ Object[] c = {fi, fi}; // [5]
+ Object[][] d = {{fi}, {fi}}; // [6]
+
+ int x1 = fun2(fi); // [7]
+ TestInlineMethodReference1 c1 = new TestInlineMethodReference1(fi); // [8]
+ F f1 = (fi_p) -> fi; // [9]
+ F f2 = (fi_p) -> {
+ return fi; // [10]
+ };
+ f1.bar(fi); // [11]
+ Object fi4 = true ? fi : fi; // [12]
+ return fi; // [13]
+ }
+
+ private int fun2(Object fi) {return 0;}
+ public TestInlineMethodReference1(Object fi) { }
+
+ int m(int x) {
+ return x++;
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ Object bar(Object fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_out.java
new file mode 100644
index 0000000..288d3c4
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1001_out.java
@@ -0,0 +1,42 @@
+package p;
+
+class TestInlineMethodReference1 {
+
+ private Object fun1() {
+ Object fi1 = (FI) this::m; // [1]
+ Object fi2;
+ fi2 = (FI) this::m; // [2]
+
+ Object[] a = new Object[] {(FI) this::m, (FI) this::m}; // [3]
+ Object[][] b = new Object[][] {{(FI) this::m, (FI) this::m}, {(FI) this::m}}; // [4]
+ Object[] c = {(FI) this::m, (FI) this::m}; // [5]
+ Object[][] d = {{(FI) this::m}, {(FI) this::m}}; // [6]
+
+ int x1 = fun2((FI) this::m); // [7]
+ TestInlineMethodReference1 c1 = new TestInlineMethodReference1((FI) this::m); // [8]
+ F f1 = (fi_p) -> ((FI) this::m); // [9]
+ F f2 = (fi_p) -> {
+ return (FI) this::m; // [10]
+ };
+ f1.bar((FI) this::m); // [11]
+ Object fi4 = true ? (FI) this::m : (FI) this::m; // [12]
+ return (FI) this::m; // [13]
+ }
+
+ private int fun2(Object fi) {return 0;}
+ public TestInlineMethodReference1(Object fi) { }
+
+ int m(int x) {
+ return x++;
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ Object bar(Object fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_in.java
new file mode 100644
index 0000000..f0af076
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_in.java
@@ -0,0 +1,40 @@
+package p;
+
+class TestInlineLambda1 {
+
+ private Object fun1() {
+ final FI fi = x -> x++;
+
+ Object fi1 = fi; // [1]
+ Object fi2;
+ fi2 = fi; // [2]
+
+ Object[] a = new Object[] {fi, fi}; // [3]
+ Object[][] b = new Object[][] {{fi, fi}, {fi}}; // [4]
+ Object[] c = {fi, fi}; // [5]
+ Object[][] d = {{fi}, {fi}}; // [6]
+
+ int x1 = fun2(fi); // [7]
+ TestInlineLambda1 c1 = new TestInlineLambda1(fi); // [8]
+ F f1 = (fi_p) -> fi; // [9]
+ F f2 = (fi_p) -> {
+ return fi; // [10]
+ };
+ f1.bar(fi); // [11]
+ Object fi4 = true ? fi : fi; // [12]
+ return fi; // [13]
+ }
+
+ private int fun2(Object fi) {return 0;}
+ public TestInlineLambda1(Object fi) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ Object bar(Object fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_out.java
new file mode 100644
index 0000000..f95c62b
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test1_out.java
@@ -0,0 +1,38 @@
+package p;
+
+class TestInlineLambda1 {
+
+ private Object fun1() {
+ Object fi1 = (FI) x -> x++; // [1]
+ Object fi2;
+ fi2 = (FI) x -> x++; // [2]
+
+ Object[] a = new Object[] {(FI) x -> x++, (FI) x -> x++}; // [3]
+ Object[][] b = new Object[][] {{(FI) x -> x++, (FI) x -> x++}, {(FI) x -> x++}}; // [4]
+ Object[] c = {(FI) x -> x++, (FI) x -> x++}; // [5]
+ Object[][] d = {{(FI) x -> x++}, {(FI) x -> x++}}; // [6]
+
+ int x1 = fun2((FI) x -> x++); // [7]
+ TestInlineLambda1 c1 = new TestInlineLambda1((FI) x -> x++); // [8]
+ F f1 = (fi_p) -> ((FI) x -> x++); // [9]
+ F f2 = (fi_p) -> {
+ return (FI) x -> x++; // [10]
+ };
+ f1.bar((FI) x -> x++); // [11]
+ Object fi4 = true ? (FI) x -> x++ : (FI) x -> x++; // [12]
+ return (FI) x -> x++; // [13]
+ }
+
+ private int fun2(Object fi) {return 0;}
+ public TestInlineLambda1(Object fi) { }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
+
+@FunctionalInterface
+interface F {
+ Object bar(Object fi);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_in.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_in.java
new file mode 100644
index 0000000..37af135
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_in.java
@@ -0,0 +1,16 @@
+package p;
+
+class TestInlineLambda2 {
+ private void fun1() {
+ final FI[] fiArr = {x -> x++};
+ FI[] a = fiArr;
+ FI[][] b = {fiArr};
+ Object[] c = fiArr;
+ Object[][] d = {fiArr};
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_out.java b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_out.java
new file mode 100644
index 0000000..8a0cbac
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/InlineTemp/canInline18/A_test2_out.java
@@ -0,0 +1,15 @@
+package p;
+
+class TestInlineLambda2 {
+ private void fun1() {
+ FI[] a = new FI[]{x -> x++};
+ FI[][] b = {new FI[]{x -> x++}};
+ Object[] c = new FI[]{x -> x++};
+ Object[][] d = {new FI[]{x -> x++}};
+ }
+}
+
+@FunctionalInterface
+interface FI {
+ int foo(int x);
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
index ce939fa..0889434 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
@@ -22,6 +22,8 @@
TestSuite suite= new TestSuite(clazz.getName());
suite.addTest(RenameTests18.suite());
+ suite.addTest(InlineTempTests18.suite());
+ suite.addTest(InlineConstantTests18.suite());
//--code
suite.addTest(ExtractMethodTests.suite());
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java
new file mode 100644
index 0000000..c845b6e
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.refactoring;
+
+import junit.framework.Test;
+
+public class InlineConstantTests18 extends InlineConstantTests {
+ private static final Class clazz= InlineConstantTests18.class;
+
+ public InlineConstantTests18(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String successPath() {
+ return toSucceed ? "/canInline18/" : "/cannotInline18/";
+ }
+
+ public static Test suite() {
+ return new Java18Setup(new NoSuperTestsSuite(clazz));
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new Java18Setup(someTest);
+ }
+
+ //--- Test lambda expressions
+
+ public void test0() throws Exception {
+ helper1("p.TestInlineLambda", 5, 28, 5, 30, true, true);
+ }
+
+ public void test1() throws Exception {
+ helper1("p.TestInlineLambda_Cast", 5, 28, 5, 30, true, true);
+ }
+
+ public void test2() throws Exception {
+ helper1("p.TestInlineLambdaArray", 5, 30, 5, 35, true, true);
+ }
+
+ public void test3() throws Exception {
+ helper1("p.TestInlineLambda_Ambiguous", 5, 28, 5, 30, true, true);
+ }
+
+ public void test4() throws Exception {
+ helper1("p.TestInlineLambda_Ambiguous", 5, 28, 5, 30, true, true);
+ }
+
+ public void test5() throws Exception {
+ helper1("p.TestInlineLambda_Cast", 15, 30, 15, 36, true, true);
+ }
+
+ //--- Test method references
+
+ public void test1000() throws Exception {
+ helper1("p.TestInlineMethodRef", 5, 28, 5, 30, true, true);
+ }
+
+ public void test1001() throws Exception {
+ helper1("p.TestInlineMethodRef_Cast", 5, 28, 5, 30, true, true);
+ }
+
+ public void test1002() throws Exception {
+ helper1("p.TestInlineMethodRefArray", 5, 30, 5, 35, true, true);
+ }
+
+ public void test1003() throws Exception {
+ helper1("p.TestInlineMethodRef_Ambiguous", 5, 28, 5, 30, true, true);
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
new file mode 100644
index 0000000..768b869
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.refactoring;
+
+import junit.framework.Test;
+
+public class InlineTempTests18 extends InlineTempTests {
+
+ private static final Class clazz= InlineTempTests18.class;
+
+ public InlineTempTests18(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new Java18Setup(new NoSuperTestsSuite(clazz));
+ }
+
+ public static Test setUpTest(Test someTest) {
+ return new Java18Setup(someTest);
+ }
+
+ @Override
+ protected String getTestFileName(boolean canInline, boolean input) {
+ String fileName= TEST_PATH_PREFIX + getRefactoringPath();
+ fileName+= (canInline ? "canInline18/" : "cannotInline18/");
+ return fileName + getSimpleTestFileName(canInline, input);
+ }
+
+ //--- tests for lambda expressions
+
+ public void test0() throws Exception {
+ helper1(6, 18, 6, 20);
+ }
+
+ public void test1() throws Exception {
+ helper1(6, 18, 6, 20);
+ }
+
+ public void test2() throws Exception {
+ helper1(5, 20, 5, 25);
+ }
+
+ //--- tests for method references
+
+ public void test1000() throws Exception {
+ helper1(6, 18, 6, 20);
+ }
+
+ public void test1001() throws Exception {
+ helper1(6, 18, 6, 20);
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
index 93a35d8..e86e33e 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
@@ -75,6 +75,7 @@
import org.eclipse.jdt.core.dom.Message;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.MethodReference;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NameQualifiedType;
@@ -600,7 +601,17 @@
} else if (initializerType.isRawType() && referenceType.isParameterizedType()) {
return referenceType; // don't lose the unchecked conversion
-
+
+ } else if (initializer instanceof LambdaExpression || initializer instanceof MethodReference) {
+ if (isTargetAmbiguous(reference)) {
+ return referenceType;
+ } else {
+ ITypeBinding targetType= getTargetType(reference);
+ if (targetType == null || targetType != referenceType) {
+ return referenceType;
+ }
+ }
+
} else if (! TypeRules.canAssign(initializerType, referenceType)) {
if (!Bindings.containsTypeVariables(referenceType))
return referenceType;