bug icon indicating copy to clipboard operation
bug copied to clipboard

Optimizer: Tuple copy and copy$default are not inlined

Open lrytz opened this issue 6 years ago • 1 comments

This could probably be improved

class C {
   final def f = {
      val tup = (1, 2)
      tup.copy(_1 = 3)
   }
}
$> scalac Test.scala -opt:l:inline '-opt-inline-from:**' -opt-warnings:_
Test.scala:4: warning: there was a problem determining if method copy$default$2 can be inlined:
No inline information for method scala/Tuple2$mcII$sp::copy$default$2()Ljava/lang/Object; could be found.
      tup.copy(_1 = 3)
          ^
one warning found
$> cfr-decompiler C.class
public class C {
    public final Tuple2<Object, Object> f() {
        Tuple2$mcII$sp tup = new Tuple2$mcII$sp(1, 2);
        return tup.copy$mIIc$sp(3, BoxesRunTime.unboxToInt(((Tuple2)tup).copy$default$2()));
    }
}

lrytz avatar Aug 08 '19 09:08 lrytz

default is inlined at 2.13.12

som-snytt avatar Jan 20 '24 23:01 som-snytt