E087: Duplicate Private Protected Qualifier

This error is emitted when both private and protected modifiers with scope qualifiers (like [ClassName]) are used on the same definition.

It is not allowed to combine private and protected modifiers even if they are qualified to different scopes. A member can only have one visibility modifier.


Example

class Example:
  private[Example] protected[Example] def method: Int = 42

Error

-- [E087] Syntax Error: example.scala:2:28 -------------------------------------
2 |  private[Example] protected[Example] def method: Int = 42
  |                            ^
  |                            Duplicate private/protected modifier
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | It is not allowed to combine `private` and `protected` modifiers even if they are qualified to different scopes
   -----------------------------------------------------------------------------

Solution

// Use only one access modifier
class Example:
  protected[Example] def method: Int = 42