docs/_docs/reference/error-codes/E196.md
This error was introduced and made inactive in the same release (Scala 3.5.0) and was never emitted by a released version of the Scala 3 compiler.
This error was triggered when attempting to use a context bound companion as a standalone value, rather than in a selection.
//> using options -experimental -language:experimental.modularity -source:future
class C[Self]
class D[Self]
trait Test:
def foo[A: {C, D}] = A
type A: C
val x = A
val y: A.type = ???
-- [E196] Type Error: example.scala:7:23 --------------------------------------
7 | def foo[A: {C, D}] = A
| ^
| context bound companion value A cannot be used as a value
Context bound companions are synthetic symbols created by the compiler to represent witnesses generated for context bounds of type parameters. For example, in:
class Monoid:
type Self
def unit: Self
type A: Monoid
There is just a type A declared but not a value A. Nevertheless, one can write the selection A.unit, which works because the compiler created a context bound companion value with the (term-)name A.
The error E196 was introduced in commit becdf887a5 (April 2024) as part of implementing context bound companions. However, the restriction was relaxed before the 3.5.0 release, and the error was made inactive.
Since Scala 3.5.0, context bound companions can be used more freely, making this specific error obsolete.
<!-- 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>