Back to Scala3

E106: Package Name Already Defined

docs/_docs/reference/error-codes/E106.md

3.8.41.1 KB
Original Source

E106: Package Name Already Defined

This error is emitted when a top-level definition (such as an object or class) has the same name as an existing package symbol.

The compiler message indicates:

  • The name is already used by a package
  • The definition cannot coexist with a package of the same name

This error typically occurs in incremental compilation scenarios where:

  • A classfile exists defining a symbol with a certain name
  • Source code attempts to define a package with the same name
  • The conflict between the classfile and the package definition triggers this error

Reproducing this error with simple source code is difficult as it requires specific classpath and compilation order conditions.

To resolve this error, either:

  • Rename the top-level definition to avoid the conflict
  • Delete the conflicting classfile
  • Reorganize your package structure
<!-- SOURCE-ONLY: Remove the notice below once this page has been manually updated. --> <aside class="warning"> This reference page was created with LLM assistance - the description of the error code may not be accurate or cover all possible scenarios. </aside>