docs/_docs/reference/error-codes/E156.md
This error occurs when a modifier is used on a definition where it is not applicable. Different kinds of definitions (classes, objects, methods, etc.) support different sets of modifiers.
Common invalid combinations include:
opaque on a method definition (only valid for type aliases)abstract on an object definitionsealed on an object definitionobject Test {
opaque def example: Int = 42
}
-- [E156] Syntax Error: example.scala:2:13 -------------------------------------
2 | opaque def example: Int = 42
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Modifier opaque is not allowed for this definition
object Test {
// opaque is only valid for type aliases
opaque type PositiveInt = Int
// Regular method definition
def example: Int = 42
}
// abstract is not allowed on object - use trait or abstract class instead
abstract class Base {
def example: Int
}