Skip to content

Commit 09e8b17

Browse files
committed
Use a SAM type as PositionPickler parameter
Avoids lack of boxing due to unspecialized function type
1 parent a246ed0 commit 09e8b17

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Contexts._, Symbols._, Annotations._, Decorators._
1616
import collection.mutable
1717
import util.Spans._
1818

19-
class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) {
19+
class PositionPickler(pickler: TastyPickler, addrOfTree: PositionPickler.TreeToAddr) {
2020
val buf: TastyBuffer = new TastyBuffer(5000)
2121
pickler.newSection("Positions", buf)
2222
import ast.tpd._
@@ -121,3 +121,8 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) {
121121
traverse(root, NoSource)
122122
}
123123
}
124+
object PositionPickler:
125+
// Note: This could be just TreeToAddr => Addr if functions are specialized to value classes.
126+
// We use a SAM type to avoid boxing of Addr
127+
@FunctionalInterface trait TreeToAddr:
128+
def apply(x: untpd.Tree): Addr

0 commit comments

Comments
 (0)