Skip to content

Polymorphic functions variance not working as expected #6918

Closed
@guyde2011

Description

@guyde2011

minimized code

val aiPoly: [T] => Any => Int = [T] => (a: Any) => 5
val iiPoly: [T] => Int => Int = aiPoly // <-- this part fails

Does not compile, producing the error:
Found: PolyFunction{apply: [T](x$1: Any): Int}(aiPoly)
Required: PolyFunction{apply: [T](x$1: Int): Int}

expectation

Expected the polymorhpic case to behave the same way as normal functions do:

val ai: Any => Int = (a: Any) => 5
val ii: Int => Int = ai // <-- compiles and works with no errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions