-
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
Can't call scala.StringBuilder#length_= in 2.13.0-M5 #11158
Comments
what's the underlying cause? |
minimal reproduce example: CharSeqJava.javapackage example;
public interface CharSeqJava {
int length();
} Main.scalapackage example
trait CharSeqScala {
def length: Int
}
class A extends CharSeqJava {
override def length: Int = 1
def length_=(value: Int): Unit = {}
}
class B extends CharSeqScala {
def length: Int = 1
def length_=(value: Int): Unit = {}
}
class C {
def length: Int = 1
def length_=(value: Int): Unit = {}
}
class D extends CharSeqJava with CharSeqScala {
def length: Int = 1
def length_=(value: Int): Unit = {}
}
class E extends CharSeqScala with CharSeqJava {
def length: Int = 1
def length_=(value: Int): Unit = {}
}
object Main {
val a = new A
val b = new B
val c = new C
val d = new D
val e = new E
// compile error
a.length = 1
// success
b.length = 1
// success
c.length = 1
// success
d.length = 1
// compile error
e.length = 1
} |
Should we swap mixin order? 🤔
final class StringBuilder(val underlying: java.lang.StringBuilder) extends AbstractSeq[Char]
+ with java.lang.CharSequence
with Builder[Char, String]
with IndexedSeq[Char]
- with IndexedSeqOps[Char, IndexedSeq, StringBuilder]
+ with IndexedSeqOps[Char, IndexedSeq, StringBuilder] {
- with java.lang.CharSequence { |
|
This goes back to scala/scala@b739c4a -- since we're "overriding" a Java method with an empty argument list, we add one to the |
@adriaanm tentatively moved to RC1 milestone, you can make the call though |
I won't have time for a proper fix. It's kind of tricky :-/ |
not sure what PR fixed it, but it's been working since 2.13.2 |
which instead of fixing getter detection, fixes setter detection for assignment rewrite. Regression test at scala/scala#10357 Worth adding that there are a few contexts now in which Lukas has said recently (since 2.13) it's time to revert adding a param list to an override of Java ( |
https://github.com/scala/scala/blob/v2.13.0-M5/src/library/scala/collection/mutable/StringBuilder.scala#L68
🤔
The text was updated successfully, but these errors were encountered: