Closed
Description
Compiler version
3.1.2-RC2
Minimized code
class Foo():
def normal: Unit = println("normal")
extension (f: Foo)
def ext: Unit = println("ext")
object Bar:
def makeFoo[A]: Foo = Foo()
def makeFoo[A](s: String): Foo = Foo()
def tests: Unit =
Bar.makeFoo[Int].ext // error
(Bar.makeFoo[Int]).ext // error
val foo = Bar.makeFoo[Int]
foo.ext // ok
Bar.makeFoo[Int].normal // ok
Output
[error] -- [E134] Type Error: <snip>
[error] 35 | Bar.makeFoo[Int].ext()
[error] | ^^^^^^^^^^^
[error] |None of the overloaded alternatives of method makeFoo in object Bar with types
[error] | [A](s: String): com.example.Foo
[error] | [A] => com.example.Foo
[error] |match type arguments [Int] and expected type ?{ ext: ? }
[error] -- [E134] Type Error: <snip>
[error] 38 | (Bar.makeFoo[Int]).ext()
[error] | ^^^^^^^^^^^
[error] |None of the overloaded alternatives of method makeFoo in object Bar with types
[error] | [A](s: String): com.example.Foo
[error] | [A] => com.example.Foo
[error] |match type arguments [Int] and expected type ?{ ext: ? }
Expectation
Compile with no error.
Note
Confirmed that codes below compile successfully.
class Foo():
def normal: Unit = println("normal")
extension (f: Foo)
def ext(): Unit = println("ext")
object WithParen:
def makeFoo[A](): Foo = Foo()
def makeFoo[A](s: String): Foo = Foo()
object NoTypeParam:
def makeFoo: Foo = Foo()
def makeFoo(s: String): Foo = Foo()
object NoOverload:
def makeFoo[A]: Foo = Foo()
def ok: Unit =
WithParen.makeFoo[Int]().ext
NoTypeParam.makeFoo.ext
NoOverload.makeFoo[Int].ext