Skip to content

Documentation for context bound desugaring disagrees with implementation #15141

Closed
@griggt

Description

@griggt

Compiler version

3.1.2

Minimized code

trait C1[T]; trait C2[T]; trait C3[T]
trait V; trait R

trait Test:
  def f[T: C1 : C2, U: C3](x: T)(using y: U, z: V): R

Output

$ scalac -Xprint:typer -source:future context-bound-params.scala
[[syntax trees at end of                     typer]] // context-bound-params.scala
package <empty> {
  trait C1[T >: Nothing <: Any]() extends Object {
    T
  }
  trait C2[T >: Nothing <: Any]() extends Object {
    T
  }
  trait C3[T >: Nothing <: Any]() extends Object {
    T
  }
  trait V() extends Object {}
  trait R() extends Object {}
  trait Test() extends Object {
    def f[T >: Nothing <: Any, U >: Nothing <: Any](x: T)(using 
      evidence$1: C1[T]
    , evidence$2: C2[T], evidence$3: C3[U], y: U, z: V): R
  }
}

Expectation

The documentation at https://docs.scala-lang.org/scala3/reference/contextual/context-bounds.html states:

For instance,

def f[T: C1 : C2, U: C3](x: T)(using y: U, z: V): R

would expand to

def f[T, U](x: T)(using y: U, z: V)(using C1[T], C2[T], C3[U]): R

Note that this differs from the implementation both in the number of using clauses and the ordering of context parameters.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions