|
| 1 | +import collection.mutable.ArrayBuffer |
1 | 2 | object Test {
|
2 | 3 |
|
3 | 4 | def main(args: Array[String]) = {
|
@@ -50,20 +51,37 @@ object Test {
|
50 | 51 |
|
51 | 52 | }
|
52 | 53 |
|
53 |
| - inline val b = 33 |
54 |
| - def f(): Int = b + 1 |
55 |
| - val a1 = Array(b, 33, 'a') |
56 |
| - val b1: Array[Int] = a1 // error: no widening |
57 |
| - val a2 = Array(b, 33, 'a', f()) |
58 |
| - val b2: Array[Int] = a2 // error: no widening |
59 |
| - val a3 = Array(1.0f, 'a', 0) |
60 |
| - val b3: Array[Float] = a3 // error: no widening |
61 |
| - val a4 = Array(1.0f, 1L) |
62 |
| - val b4: Array[Double] = a4 // error: no widening |
63 |
| - val a5 = Array(1.0f, 1L, f()) |
64 |
| - val b5: Array[AnyVal] = a5 |
65 |
| - val a6 = Array(1.0f, 1234567890) |
66 |
| - val b6: Array[AnyVal] = a6 |
| 54 | + def arraytest = |
| 55 | + inline val b = 33 |
| 56 | + def f(): Int = b + 1 |
| 57 | + val a1 = Array(b, 33, 'a') |
| 58 | + val b1: Array[Int] = a1 // OK, Array constructor selection uses weak conformance |
| 59 | + val a2 = Array(b, 33, 'a', f()) |
| 60 | + val b2: Array[Int] = a2 // OK, Array constructor selection uses weak conformance |
| 61 | + val a3 = Array(1.0f, 'a', 0) |
| 62 | + val b3: Array[Float] = a3 // OK, Array constructor selection uses weak conformance |
| 63 | + val a4 = Array(1.0f, 1L) |
| 64 | + val b4: Array[Double] = a4 // error: Array[Float] is picked |
| 65 | + val a5 = Array(1.0f, 1L, f()) |
| 66 | + val b5: Array[AnyVal] = a5 // error: Array[Float] is picked |
| 67 | + val a6 = Array(1.0f, 1234567890) |
| 68 | + val b6: Array[AnyVal] = a6 // error: Array[Float] is picked |
| 69 | + |
| 70 | + def arrayBufferTest = |
| 71 | + inline val b = 33 |
| 72 | + def f(): Int = b + 1 |
| 73 | + val a1 = ArrayBuffer(b, 33, 'a') |
| 74 | + val b1: ArrayBuffer[Int] = a1 // error: no widening |
| 75 | + val a2 = ArrayBuffer(b, 33, 'a', f()) |
| 76 | + val b2: ArrayBuffer[Int] = a2 // error: no widening |
| 77 | + val a3 = ArrayBuffer(1.0f, 'a', 0) |
| 78 | + val b3: ArrayBuffer[Float] = a3 // error: no widening |
| 79 | + val a4 = ArrayBuffer(1.0f, 1L) |
| 80 | + val b4: ArrayBuffer[Double] = a4 // error: no widening |
| 81 | + val a5 = ArrayBuffer(1.0f, 1L, f()) |
| 82 | + val b5: ArrayBuffer[AnyVal] = a5 |
| 83 | + val a6 = ArrayBuffer(1.0f, 1234567890) |
| 84 | + val b6: ArrayBuffer[AnyVal] = a6 |
67 | 85 |
|
68 | 86 | def totalDuration(results: List[Long], cond: Boolean): Long =
|
69 | 87 | results.map(r => if (cond) r else 0).sum
|
|
0 commit comments