effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Binding of type parameters in methods

Open phischu opened this issue 2 months ago • 0 comments

Currently the following program is accepted:

interface Choose {
  def choose[A](x: A, y: A): A
}

def c = new Choose {
  def choose(x, y) = x
}

We want it to be rejected, because there is no explicit binding of the type parameter in the method definition.

Instead, the user has to write the following, which is already accepted:

interface Choose {
  def choose[A](x: A, y: A): A
}

def c = new Choose {
  def choose[B](x, y) = x
}

For consistency, we always require users to explicitly bind type parameters. Moreover, the A from the interface appears in error messages in the method definition, which might be confusing.

phischu avatar Oct 02 '25 07:10 phischu