Skip to content

Hygiene issue with overloads in AnyVal classes #17288

Open
@mpilquist

Description

@mpilquist

Compiler version

3.2.2

Minimized code

//> using scala "3.2.2"

class FooOps[A](self: A) extends AnyVal {
  def foo = ???
  @annotation.targetName("foo2")
  def foo[B] = ???
}

Or the simpler:

//> using scala "3.2.2"

class IntOps(self: Int) extends AnyVal {
  def foo = ???
  @annotation.targetName("foo2")
  def foo[A] = ???
}

Output

Error: Not enough type arguments for FooOps.foo$extension[B, A]
expected: [B, A]
actual:   [A]

and

Error: method foo$extension in object IntOps does not take parameters

Renaming the overload to something else avoids the bug. Removing AnyVal also avoids the bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions