-
Notifications
You must be signed in to change notification settings - Fork 21
Multiple type applications on overloaded method crashes scalac #10628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The stack trace is telling:
Nice find! |
This also crashes the compiler in cases that should compile.
|
This caused some considerable head scratching today, I wrote
💥 whereas I meant to write
(where Not sure how Diego came up with their example, but above is at least one piece of anecdotal evidence it can come up in practice. |
closed PR a volunteer could try to finish: scala/scala#10832 |
Auntie Polly will thank you. |
Why is the first alternative treated specially? I don't get the purpose of this code. // Alternatives which conform to bounds
def checkWithinBounds(sym: Symbol): Unit = sym.alternatives match {
case Nil => if (!argtypes.exists(_.isErroneous)) fail()
case alt :: Nil => finish(alt, pre memberType alt)
case alts @ hd :: _ =>
log(s"Attaching AntiPolyType-carrying overloaded type to $sym")
// Multiple alternatives which are within bounds; spin up an
// overloaded type which carries an "AntiPolyType" as a prefix.
val tparams = new AsSeenFromMap(pre, hd.owner) mapOver hd.typeParams
val bounds = tparams map (_.tpeHK) // see e.g., #1236
val tpe = PolyType(tparams, OverloadedType(AntiPolyType(pre, bounds), alts))
finish(sym setInfo tpe, tpe)
} |
I observe that changing the test
shows the My loose understanding was that it simply assists in providing an expected type for args while typing. (We know the alternatives take
|
Uh oh!
There was an error while loading. Please reload this page.
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 methoda
, in both cases with a simple type parameterF
, with different arguments.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:
F
.a
(no overloading)a
to a single list of several parametersA.a[Int, String](42)
.The text was updated successfully, but these errors were encountered: