Skip to content

Regression (since Scala 2) in handling of by-name parameters when typing arguments to polymorphic method #14236

Open
@mbore

Description

@mbore

Compiler version

3.0.1;
3.1.0

Minimized code

def f(i: => Int): String = i.toString()

object Test {
  def test[RES](factory: () => RES): RES = ???
  def test[A, RES](factory: (A) => RES): RES = ???
}

Test.test(f _)

Output

[error] -- [E134] Type Error: [...]/TestMain.scala:23:5 
[error] 23 |Test.test(f _)
[error]    |^^^^^^^^^
[error]    |None of the overloaded alternatives of method test in object Test with types
[error]    | [A, RES](factory: A => RES): RES
[error]    | [RES](factory: () => RES): RES
[error]    |match arguments ((=> Int) => String)

Expectation

In Scala 2.13.6 it compiles, so I expect it to compile in 3.0.1 as well

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