Skip to content

Warn or optimize when inline given inlines anonymous class creation #16723

Closed
@szymon-rd

Description

@szymon-rd

Compiler version

3.2.1

Minimized example

trait Converter[A, B] {
    def convert: A => B
}

inline given Converter[Int, String] = new Converter {
    def convert = _.toString()
}

def foo(using bar: Converter[Int, String]) = 
    "foo"

@main
def main = 
    foo
    foo
    foo
    foo

Output

Creates 4 anon classes in the compilation output. Can lead to an explosion of amount of classes, killing the jit code cache (as seen in the lichess case)

Expectation

Should warn the User about the generation of anon classes per usage of Converter inline given, or find a way to avoid inlining anonymous class generation.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions