Make CharSequence.length a function instead of property

And String.length as well.

This is done for JVM interoperability: java.lang.CharSequence is an open class
and has a function 'length()' which should be implemented in subclasses
somehow.

A minor unexpected effect of this is that String.length() is now a compile-time
constant (it wasn't such as a property because properties are not supported in
compile-time constant evaluation)

 #KT-3571 Fixed
This commit is contained in:
Alexander Udalov
2014-11-26 18:50:04 +03:00
parent 6b8da062a4
commit a7b88e9485
159 changed files with 265 additions and 313 deletions
@@ -1,21 +1,21 @@
== test ==
fun test(s: String?) {
s?.length
fun test(s: IntProgression?) {
s?.start
}
---------------------
L0:
1 <START>
v(s: String?)
magic[FAKE_INITIALIZER](s: String?) -> <v0>
v(s: IntProgression?)
magic[FAKE_INITIALIZER](s: IntProgression?) -> <v0>
w(s|<v0>)
2 mark({ s?.length })
mark(s?.length)
2 mark({ s?.start })
mark(s?.start)
r(s) -> <v1>
r(length|<v1>) -> <v2>
r(start|<v1>) -> <v2>
L1:
1 <END> NEXT:[<SINK>]
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -1,3 +1,3 @@
fun test(s: String?) {
s?.length
}
fun test(s: IntProgression?) {
s?.start
}
@@ -1,11 +1,11 @@
== test ==
fun test(s: String?) {
s?.length
fun test(s: IntProgression?) {
s?.start
}
---------------------
<v0>: {<: String?} NEW: magic[FAKE_INITIALIZER](s: String?) -> <v0>
s <v1>: {<: CharSequence?} NEW: r(s) -> <v1>
length <v2>: * NEW: r(length|<v1>) -> <v2>
s?.length <v2>: * COPY
{ s?.length } <v2>: * COPY
<v0>: {<: IntProgression?} NEW: magic[FAKE_INITIALIZER](s: IntProgression?) -> <v0>
s <v1>: {<: Progression<Int>?} NEW: r(s) -> <v1>
start <v2>: * NEW: r(start|<v1>) -> <v2>
s?.start <v2>: * COPY
{ s?.start } <v2>: * COPY
=====================