Skip to content

@unroll should work on final classes without needing a final on each method #22833

Closed
@lihaoyi

Description

@lihaoyi

Compiler version

3.7.0-RC1

Minimized code

final class Foo{
  def bar(@scala.annotation.unroll x: Int = 0) = x + 1
}

Output

[44] [error] -- [E207] Declaration Error: /Users/lihaoyi/test/src/test.scala:2:35 -----------
[44] [error] 2 |  def bar(@scala.annotation.unroll x: Int = 0) = x + 1
[44] [error]   |                                   ^
[44] [error]   |                   Cannot unroll parameters of method bar: it is not final
[44] [error] one error found

Expectation

@unroll should be able to see that the enclosing Foo is a final class, and thus allow us to elide final modifiers on the def bar. It already recognizes enclosing objects as final, so recognizing enclosing final class and final case classes is a straightforward extension

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions