Skip to content

Overloading resolution for functions fails with Unit adaptation #11016

Open
@lrytz

Description

@lrytz

This fails in 2.12 and 2.13

scala> trait SAM { def flup(c: Int): Unit }
scala> object T { def f(x: Int => Unit) = 0; def f(s: SAM) = 1 }

scala> T.f(x => x)
         ^
       error: overloaded method value f with alternatives:
         (s: SAM)Int <and>
         (x: Int => Unit)Int
        cannot be applied to (Int => Int)

scala> T.f(x => {x; ()}) // workaround
res1: Int = 0

Mabye this can be improved. Found by compiling Spark for 2.12 (https://issues.apache.org/jira/browse/SPARK-14220?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&focusedCommentId=16540495#comment-16540495)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions