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

Control flow can not generate fake conditional when the for each iterable is of type J$Ternary #58

Open
JLLeitschuh opened this issue Sep 9, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@JLLeitschuh
Copy link
Collaborator

Problem

Describe the issue you are experiencing.

Expected behavior

Describe what you expected to see.

Example diff

                                 + "{ this(" + (dim > 0 ? "Math.min(firstValue.length, secondValue.length)" : "") + "); put(firstValue, secondValue); }\n";
                   }
               } else if (resizable && firstType == null && secondType == null) {
-                    for (String javaName : valueType.javaNames != null ? valueType.javaNames : new String[]{valueType.javaName}) {
+                    /*~~(java.lang.ClassCastException: class org.openrewrite.java.tree.J$Ternary cannot be cast to class org.openrewrite.java.tree.J$MethodInvocation (org.openrewrite.java.tree.J$Ternary and org.openrewrite.java.tree.J$MethodInvocation are in unnamed module of loader 'app')
+  org.openrewrite.java.controlflow.ControlFlow$ControlFlowAnalysis.createFakeConditionalMethod(ControlFlow.java:623)
+  org.openrewrite.java.controlflow.ControlFlow$ControlFlowAnalysis.visitForEachLoop(ControlFlow.java:603)
+  org.openrewrite.java.controlflow.ControlFlow$ControlFlowAnalysis.visitForEachLoop(ControlFlow.java:90)
+  org.openrewrite.java.tree.J$ForEachLoop.acceptJava(J.java:1862)
+  org.openrewrite.java.tree.J.accept(J.java:60)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:145)
+  org.openrewrite.java.controlflow.ControlFlow$ControlFlowAnalysis.visitRecursive(ControlFlow.java:171)
+  ...)~~>*/for (String javaName : valueType.javaNames != null ? valueType.javaNames : new String[]{valueType.javaName}) {
                       if (dim < 2 && !javaName.equals("int") && !javaName.equals("long")) {
                           decl.text += "    public " + containerType.javaName + "(" + javaName + " value) { this(1); put(0, value); }\n";
                       }

Recipes in example diff:

  • org.openrewrite.java.security.PartialPathTraversalVulnerability

References:

  • Recipe ID: undefined
  • Recipe Name: "Partial path traversal vulnerability"
  • Repository: wumo/gradle-javacpp-plugin/master
  • Created at Thu Sep 08 2022 22:52:42 GMT-0400 (Eastern Daylight Time)
@JLLeitschuh JLLeitschuh added the bug Something isn't working label Sep 9, 2022
@JLLeitschuh JLLeitschuh self-assigned this Sep 9, 2022
@pway99 pway99 moved this to Backlog in OpenRewrite Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant