Skip to content

Inlined methods of type Unit produce unnesesary code #9246

Closed
@edolgy

Description

@edolgy
inline def check(v:Double): Unit = if(v==0) throw new Exception()

inline def divide(v: Double, d: Double): Double = { check(d); v / d }

def run =  divide(10,2)
// Java decompiled method run
public double run() {
  BoxedUnit var10000 = BoxedUnit.UNIT;
  return 5.0D;
}

Expectation

The BoxedUnit type variable is very annoying when trying to optimize inlined code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions