Skip to content

Commit 914d6a3

Browse files
committed
Fix rebase breakage
Also: reinstantiate an accidentally deleted test
1 parent 29825bb commit 914d6a3

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ object SymDenotations {
417417
case name: SimpleName => qualify(name)
418418
case name @ AnyQualifiedName(_, _) => qualify(name.mangled.toSimpleName)
419419
}
420-
if (name.isType) fn.toTypeName else fn.toTermName
420+
if (name.isTypeName) fn.toTypeName else fn.toTermName
421421
}
422422

423423
/** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */

tests/run/unittest_collection.scala

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
object Test {
2+
3+
import scala.collection.mutable.{ArrayBuffer, Buffer, BufferProxy, ListBuffer}
4+
5+
def main(args: Array[String]): Unit = {
6+
test(collection.mutable.ArrayBuffer[String]())
7+
test(collection.mutable.ListBuffer[String]())
8+
class BBuf(z:ListBuffer[String]) extends BufferProxy[String] { // @odersky - bug here in scala 2.12 trait encoding seems like...
9+
def self = z
10+
}
11+
test(new BBuf(collection.mutable.ListBuffer[String]()))
12+
}
13+
14+
def test(x: Buffer[String]): Unit = {
15+
// testing method +=
16+
x += "one"
17+
assert(x(0) == "one", "retrieving 'one'")
18+
assert(x.length == 1, "length A")
19+
x += "two"
20+
assert(x(1) == "two", "retrieving 'two'")
21+
assert(x.length == 2, "length B")
22+
23+
// testing method -= (removing last element)
24+
x -= "two"
25+
26+
assert(x.length == 1, "length C")
27+
28+
try { x(1); sys.error("no exception for removed element") }
29+
catch { case i:IndexOutOfBoundsException => }
30+
31+
try { x.remove(1); sys.error("no exception for removed element") }
32+
catch { case i:IndexOutOfBoundsException => }
33+
34+
x += "two2"
35+
assert(x.length == 2, "length D")
36+
37+
// removing first element
38+
x.remove(0)
39+
assert(x.length == 1, "length E")
40+
41+
// toList
42+
assert(x.toList == List("two2"), "toList")
43+
44+
// clear
45+
x.clear()
46+
assert(x.length == 0, "length 0")
47+
assert(x.isEmpty, "isEmpty")
48+
49+
// copyToBuffer
50+
x += "a"
51+
x += "b"
52+
val dest = new ArrayBuffer[String]
53+
x.copyToBuffer(dest)
54+
assert(List("a", "b") == dest.toList, "dest")
55+
assert(List("a", "b") == x.toList, "source")
56+
}
57+
58+
}

0 commit comments

Comments
 (0)