E147: Redundant Modifier
This warning occurs when a modifier is applied to a definition where it has no effect because the definition is already implicitly given that property.
Common cases include:
- Using
finalon a given definition (givens are already final) - Using
finalon an object member in a final class - Using modifiers that are implied by the definition context
Example
object Example {
final given g: Object()
}
Error
-- [E147] Syntax Warning: example.scala:2:2 ------------------------------------
2 | final given g: Object()
| ^^^^^
| Modifier final is redundant for this definition
Solution
object Example {
// Remove the redundant `final` modifier - givens are implicitly final
given g: Object()
}
In this article