Skip to content

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

@nitram84

Description

@nitram84

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: MediumMedium prioritySubsystem: VariablesAnything concerning variables, types, assignments, and castingType: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions