-
Notifications
You must be signed in to change notification settings - Fork 21
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
LinearSeq#head and LinearSeq#tail aren't abstract #11697
Comments
This part can be fast-tracked, without issues of binary compatibility. |
volunteer to tackle this for 2.13.2? |
Is this related to the fact that the optimizer can't inline such code: implicit final class RichList[A](private val list: List[A]) extends AnyVal {
def sumBy[B: Numeric](f: A => B): B = list.foldLeft(Numeric[B].zero) { case (acc, a) => Numeric[B].plus(acc, f(a)) }
} If I compile with the optimizer enabled and the [error] Failed to check if scala/collection/LinearSeqOps::foldLeft(Ljava/lang/Object;Lscala/Function2;)Ljava/lang/Object; can be safely inlined to LanguageExtensions$RichList$ without causing an IllegalAccessError. Checking instruction INVOKEINTERFACE scala/collection/LinearSeq.isEmpty ()Z (itf) failed:
[error] The method isEmpty()Z could not be found in the class scala/collection/LinearSeq or any of its parents.
[error] def sumBy[B: Numeric](f: A => B): B = list.foldLeft(Numeric[B].zero) { case (acc, a) => Numeric[B].plus(acc, f(a)) }
[error] ^
[error] LanguageExtensions.scala:114:93: scala/collection/LinearSeqOps::foldLeft(Ljava/lang/Object;Lscala/Function2;)Ljava/lang/Object; could not be inlined: ??? 🤔 |
@guizmaii it won't inline methods that can be overridden. Here, I think it's looking for candidates to inline and notices that there is an abstract It's just looking at bytecode, so it doesn't have enough information about |
Not sure whether to leave this open — the linked PR initially aimed to change the code, but ended up changing the documentation only. |
I created an issue on |
The
LinearSeq#isEmpty
,LinearSeq#head
, andLinearSeq#tail
methods should be abstract, so that it is obvious (and verified at compile time) that these methods must be implemented in order to have a workingLinearSeq
. Currently, they are not, andnew LinearSeq[SomeType] {}
is permitted at compile time but causes a stack overflow at run time.Also, the
LinearSeq
documentation no longer says that these methods must be implemented. In 2.12 and earlier, this was in the documentation forLinearSeqOptimized
, but it doesn't seem to have been brought over.The text was updated successfully, but these errors were encountered: