Skip to content

SAM treatment in typechecker doesn't differentiate between "literal function type" and function types #158

Closed
@retronym

Description

@retronym

I would not expect an ambiguity in this case.

scala> object O {
     |   def foo(f: String => String) = 1
     |   def foo(f: java.util.function.Function[String, String]) = 2
     | }
defined object O

scala> def f[A]: A => A = null
f: [A]=> A => A

scala> O.foo(f)
<console>:14: error: overloaded method value foo with alternatives:
  (f: java.util.function.Function[String,String])Int <and>
  (f: String => String)Int
 cannot be applied to (Nothing => Nothing)
       O.foo(f)
         ^

given that the does not typecheck:

scala> object O {
     |   def foo(f: java.util.function.Function[String, String]) = 2
     | }
defined object O

scala> def f[A]: A => A = null
f: [A]=> A => A

scala> O.foo(f)
<console>:14: error: type mismatch;
 found   : String => String
 required: java.util.function.Function[String,String]
       O.foo(f)
             ^

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions