Skip to content

Multiple type applications on overloaded method crashes scalac #10628

Open
@diesalbla

Description

@diesalbla

There is a corner case that occurs in the intersection of type application and method overloading.

The following program shows an object A with an overloaded method a, in both cases with a simple type parameter F, with different arguments.

object A {
    def a[F](x: Int) = 0
    def a[F](x: String) = 0
}
A.a[Int][String](0)

In the final line, when the method is applied with two lists of type arguments, the compiler crashes with a java.lang.ClassCastException.

Note that, as explained in #6729, this is not a syntax problem. There can be applications with several lists of type parameters, such as when the result of one is an object with an def apply[F] method.

Similar programs that do not crash the compiler are the following ones:

  • If you remove the type parameters F.
  • If you only have one method a (no overloading)
  • If you apply the method a to a single list of several parameters A.a[Int, String](42) .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions