Skip to content

Consider inlining manually hoisted lambdas in the compiler #11357

Open
@retronym

Description

@retronym

https://github.com/scala/scala/blob/3b0cf29b794fc9c9c5409c0443802a815afbbf04/src/reflect/scala/reflect/internal/Types.scala#L4605-L4622

The lambda encoding hoists these automatically:

scala> def foo = (_: Any).toString
foo: Any => String

scala> foo eq foo
res0: Boolean = true

scala> def bar = (_: Any).toString
bar: Any => String

scala> bar eq bar
res1: Boolean = true

scala> bar eq foo
res2: Boolean = false

Inlining these will likely result in more readable code. There will be a small cost (creation of the anonfun methods at each place that defines a "copy" of the same lambda), although we could and should eliminate that with #102

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions