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

Method decompilation failed with: No common supertype for ternary expression #455

Open
nitram84 opened this issue Feb 16, 2025 · 0 comments
Labels
Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting Type: Bug Something isn't working

Comments

@nitram84
Copy link

Vineflower version

develop/1.11.0, 317e74b

Describe the bug

This class can't be decompiled (compiled with openjdk11) with vineflower develop/1.11.0

import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;

public class TernaryExpressionTest<V> {

  public void doSomething(final CompletableFuture<V> future) {
    future.whenComplete((value, e) -> {
      execute((a, v) -> {
        if (v == null) {
          return value;
        }
        return v;
      });
    });
  }

  private V execute(final BiFunction<? super V, ? super V, ? extends V> value) {
    return null;
  }
}

Decompilation result:

import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;

public class TernaryExpressionTest<V> {
   public void doSomething(CompletableFuture<V> future) {
      future.whenComplete((value, e) -> this.execute((a, v) -> // $VF: Couldn't be decompiled));
   }

   private V execute(BiFunction<? super V, ? super V, ? extends V> value) {
      return null;
   }
}

If this issue can't be reproduced, I'll attach the compiled test class. This test class can be used for unit tests.

Additional information

Error message:

WARN:              Method lambda$doSomething$0 (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class TernaryExpressionTest couldn't be written.
java.lang.IllegalStateException: No common supertype for ternary expression
	at org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent.getExprType(FunctionExprent.java:223)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent.getInferredExprType(FunctionExprent.java:299)
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.getCastedExprent(ExprProcessor.java:962)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent.toJava(ExitExprent.java:86)
	at org.jetbrains.java.decompiler.main.ClassWriter.classLambdaToJava(ClassWriter.java:288)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.NewExprent.toJava(NewExprent.java:404)
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.getCastedExprent(ExprProcessor.java:1014)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.appendParamList(InvocationExprent.java:1153)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.toJava(InvocationExprent.java:904)
	at org.jetbrains.java.decompiler.main.ClassWriter.classLambdaToJava(ClassWriter.java:288)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.NewExprent.toJava(NewExprent.java:404)
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.getCastedExprent(ExprProcessor.java:1014)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.appendParamList(InvocationExprent.java:1153)
	at org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent.toJava(InvocationExprent.java:904)
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.listToJava(ExprProcessor.java:891)
	at org.jetbrains.java.decompiler.modules.decompiler.stats.BasicBlockStatement.toJava(BasicBlockStatement.java:91)
	at org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement.toJava(RootStatement.java:36)
	at org.jetbrains.java.decompiler.main.ClassWriter.writeMethod(ClassWriter.java:1306)
	at org.jetbrains.java.decompiler.main.ClassWriter.writeClass(ClassWriter.java:485)
	at org.jetbrains.java.decompiler.main.ClassesProcessor.writeClass(ClassesProcessor.java:500)
	at org.jetbrains.java.decompiler.main.Fernflower.getClassContent(Fernflower.java:196)
	at org.jetbrains.java.decompiler.struct.ContextUnit.lambda$3(ContextUnit.java:195)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1403)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
@jaskarth jaskarth added Type: Bug Something isn't working Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants