You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/03/23 19:19:54 UTC

[GitHub] matthiasblaesing closed pull request #407: [NETBEANS-345] Fix "Move Inner to Outer Level" produces ""

matthiasblaesing closed pull request #407: [NETBEANS-345] Fix "Move Inner to Outer Level" produces "<captured wildcard>"
URL: https://github.com/apache/incubator-netbeans/pull/407
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableTreeTranslator.java b/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableTreeTranslator.java
index 0a1c88f02..c446d9a69 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableTreeTranslator.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/transform/ImmutableTreeTranslator.java
@@ -24,6 +24,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
 import com.sun.tools.javac.util.Context;
 import java.util.ArrayList;
@@ -778,6 +779,10 @@ protected final LambdaExpressionTree rewriteChildren(LambdaExpressionTree tree)
             parameters != tree.getParameters())
         {
             LambdaExpressionTree n = make.LambdaExpression(parameters, body);
+            // issue #239256, NETBEANS-345
+            // Subsequent to the construction of tree, the vartype of the head
+            // param might have been filled in, so we need to copy tree's paramKind.
+            ((JCLambda)n).paramKind = ((JCLambda)tree).paramKind;
             model.setType(n, model.getType(tree));
 	    copyCommentTo(tree,n);
             copyPosTo(tree,n);
diff --git a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerToOutterTest.java b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerToOutterTest.java
index 2f9f9112d..bb7593f3a 100644
--- a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerToOutterTest.java
+++ b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerToOutterTest.java
@@ -620,6 +620,43 @@ public void test119419() throws Exception {
                       new File("t/B.java", "/* * Refactoring License */ package t; /** * * @author junit */ enum B { A(0); private B(int i) { System.err.println(i); } } "));
     }
 
+    // If types are omitted on lambda parameters (IMPLICIT paramKind), then the
+    // generated lambda source code should also omit parameter types.
+    public void testNETBEANS345() throws Exception {
+        writeFilesAndWaitForScan(src,
+                                 new File("t/A.java", "package t;\n" +
+                                                      "\n" +
+                                                      "import java.util.List;\n" +
+                                                      "import java.util.concurrent.RunnableFuture;\n" +
+                                                      "\n" +
+                                                      "public class A {\n" +
+                                                      "    public static class B {\n" +
+                                                      "        public B(List<? extends Runnable> runnables) {\n" +
+                                                      "            assert runnables.stream().noneMatch((r) -> r instanceof RunnableFuture);\n" +
+                                                      "        }\n" +
+                                                      "    }\n" +
+                                                      "}"));
+        performInnerToOuterTest(null);
+        verifyContent(src,
+                      new File("t/A.java", "package t;\n" +
+                                           "\n" +
+                                           "import java.util.List;\n" +
+                                           "import java.util.concurrent.RunnableFuture;\n" +
+                                           "\n" +
+                                           "public class A {\n" +
+                                           "}"),
+                      new File("t/B.java", "/* * Refactoring License */ package t;\n" +
+                                           "\n" +
+                                           "import java.util.List;\n" +
+                                           "import java.util.concurrent.RunnableFuture;\n" +
+                                           "\n" +
+                                           "/** * * @author junit */ public class B {\n" +
+                                           "    public B(List<? extends Runnable> runnables) {\n" +
+                                           "        assert runnables.stream().noneMatch((r) -> r instanceof RunnableFuture);\n" +
+                                           "    }\n" +
+                                           "} "));
+    }
+
     private void performInnerToOuterTest(String generateOuter, Problem... expectedProblems) throws Exception {
         final InnerToOuterRefactoring[] r = new InnerToOuterRefactoring[1];
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists