E196: Context Bound Companion Not Value

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.

What it did

This error was triggered when attempting to use a context bound companion as a standalone value, rather than in a selection.

Example

//> 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 = ???

Error

-- [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

Explanation

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.