Closed
Description
Compiler version
3.1.2-RC1
Problem description
I am having a weird compilation issue that can be resolved by inlining a seemingly unrelated method.
Minimized code
class Foo(val id: Int) {
inline def ==(that: Foo): Boolean = true
}
case class FooWrapper(foo: Foo)
yields
[error] 4 | case class FooWrapper(foo: Foo)
[error] | ^
[error] | method == is declared as `inline`, but was not inlined
[error] |
[error] | Try increasing `-Xmax-inlines` above 32
To make the problem go away, inline the method Bar.f
.
Real-world problem
git clone https://github.com/informarte/yuck.git
cd yuck
git checkout spikes/scala-3-inlining
make unit-tests
works fine. However, rolling back the last commit (which inlines the unrelated method), breaks the compilation:
git checkout HEAD~1
make unit-tests
yields
/mill yuck.dev.test.run yuck.test.UnitTestSuite
[43/80] yuck.dev.compile
[info] compiling 2 Scala sources to /tmp/yuck/out/yuck/dev/compile.dest/classes ...
[info] done compiling
[info] compiling 2 Scala sources to /tmp/yuck/out/yuck/dev/compile.dest/classes ...
[info] done compiling
[67/80] yuck.dev.test.compile
[info] compiling 2 Scala sources to /tmp/yuck/out/yuck/dev/test/compile.dest/classes ...
[error] -- Error: /tmp/yuck/src/test/yuck/flatzinc/test/util/DotExporter.scala:18:23 ---
[error] 18 | private case class VariableVertex(x: AnyVariable) extends Vertex
[error] | ^
[error] | method == is declared as `inline`, but was not inlined
[error] |
[error] | Try increasing `-Xmax-inlines` above 32
[error] -- Error: /tmp/yuck/src/test/yuck/flatzinc/test/util/DotExporter.scala:19:23 ---
[error] 19 | private case class ConstraintVertex(constraint: Constraint) extends Vertex
[error] | ^
[error] | method == is declared as `inline`, but was not inlined
[error] |
[error] | Try increasing `-Xmax-inlines` above 32
[error] two errors found
1 targets failed
yuck.dev.test.compile Compilation failed
In fact, both AnyVariable
and Constraint
come with custom, inline ==
operators - I added those for efficiency and type safety - and they never caused any trouble with Scala 2.13.
As suggested, I increased max-inlines
(up to 40) but it did not help.
Expectation
Assuming that my code is correct, I expect that it should compile without the need to inline an unrelated method.