Back to Scala3

E119: Symbol Is Not a Value

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

3.8.41.0 KB
Original Source

E119: Symbol Is Not a Value

This error is emitted when a package or Java-defined class is used in a position where a value is expected.

Packages and Java classes (without companion objects) cannot be used as values in Scala.


Example

scala
val x = scala.collection

Error

scala
-- [E119] Type Error: example.scala:1:14 ---------------------------------------
1 |val x = scala.collection
  |        ^^^^^^^^^^^^^^^^
  |        package scala.collection is not a value

Solution

scala
// Use a specific value from the package
val x = scala.collection.immutable.List
scala
// Or import and use a specific type
import scala.collection.mutable.ArrayBuffer
val x = ArrayBuffer[Int]()
<!-- 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>