Fix issue getting the size property from Collection bounded type

parameters, when lowering for-loops over Collection.indices.
This commit is contained in:
Mark Punzalan
2019-11-06 13:51:51 -08:00
committed by max-kammerer
parent 30679ebfaf
commit 21178a4f1a
13 changed files with 131 additions and 3 deletions
@@ -1,4 +1,4 @@
fun <T: CharSequence> test(sequence: T) {
fun <T : CharSequence> test(sequence: T) {
var s = ""
for (c in sequence) {
s += c
@@ -8,3 +8,5 @@ fun <T: CharSequence> test(sequence: T) {
// 0 iterator
// 0 hasNext
// 0 nextChar
// 1 INVOKEINTERFACE java/lang/CharSequence\.charAt \(I\)C
// 1 INVOKEINTERFACE java/lang/CharSequence\.length \(\)I
@@ -1,4 +1,4 @@
fun <T: CharSequence> test(s: T): Int {
fun <T : CharSequence> test(s: T): Int {
var result = 0
for (i in s.indices) {
result = result * 10 + (i + 1)
@@ -14,6 +14,7 @@ fun <T: CharSequence> test(s: T): Int {
// 0 getEnd
// 0 getFirst
// 0 getLast
// 1 INVOKEINTERFACE java/lang/CharSequence\.length \(\)I
// JVM_TEMPLATES
// 0 IF_ICMPGT
@@ -0,0 +1,25 @@
fun <T : Collection<*>> test(c: T) {
var sum = 0
for (i in c.indices) {
sum += i
}
}
// 0 iterator
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 1 INVOKEINTERFACE java/util/Collection\.size \(\)I
// JVM non-IR uses while.
// JVM IR uses if + do-while.
// JVM_TEMPLATES
// 1 IF_ICMPGE
// 1 IF
// JVM_IR_TEMPLATES
// 1 IF_ICMPGT
// 1 IF_ICMPLE
// 2 IF