ClassCastException when calling a trait method with call-by-name argument if implemented as single abstract method #11237
Labels
byname
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
has PR
sam
Milestone
The following code:
crashes at runtime with ClassCastException
Seems like the bytecode generated contains erroneous call to function representing call-by-name argument (instruction at 2) and then casting of it's result to Function0 (instruction at 7):
Also note that if name of call-by-name argument in trait and SAM implementation are the same as in:
then it works as expected and compiler generates correct bytecode for this function:
Tried with Scala versions 2.12.7 and 2.13.0-M5.
Also seems like this issue is related to #10362 since same exception is being thrown at runtime and similar bytecode is being generated in both cases.
The text was updated successfully, but these errors were encountered: