File tree 3 files changed +20
-22
lines changed
compiler/src/dotty/tools/dotc/ast 3 files changed +20
-22
lines changed Original file line number Diff line number Diff line change @@ -769,28 +769,26 @@ object Trees {
769
769
def genericEmptyTree [T >: Untyped ]: Thicket [T ] = theEmptyTree.asInstanceOf [Thicket [T ]]
770
770
771
771
def flatten [T >: Untyped ](trees : List [Tree [T ]]): List [Tree [T ]] = {
772
- var buf : ListBuffer [Tree [T ]] = null
773
- var xs = trees
774
- while (! xs.isEmpty) {
775
- xs.head match {
776
- case Thicket (elems) =>
777
- if (buf == null ) {
778
- buf = new ListBuffer
779
- var ys = trees
780
- while (ys ne xs) {
781
- buf += ys.head
782
- ys = ys.tail
772
+ def recur (buf : ListBuffer [Tree [T ]], remaining : List [Tree [T ]]): ListBuffer [Tree [T ]] =
773
+ remaining match {
774
+ case Thicket (elems) :: remaining1 =>
775
+ var buf1 = buf
776
+ if (buf1 == null ) {
777
+ buf1 = new ListBuffer [Tree [T ]]
778
+ var scanned = trees
779
+ while (scanned `ne` remaining) {
780
+ buf1 += scanned.head
781
+ scanned = scanned.tail
783
782
}
784
783
}
785
- for (elem <- elems) {
786
- assert(! elem.isInstanceOf [Thicket [_]])
787
- buf += elem
788
- }
789
- case tree =>
784
+ recur(recur(buf1, elems), remaining1)
785
+ case tree :: remaining1 =>
790
786
if (buf != null ) buf += tree
787
+ recur(buf, remaining1)
788
+ case nil =>
789
+ buf
791
790
}
792
- xs = xs.tail
793
- }
791
+ val buf = recur(null , trees)
794
792
if (buf != null ) buf.toList else trees
795
793
}
796
794
Original file line number Diff line number Diff line change 1
1
package x0 {
2
- case class x0
2
+ case class x0 // error // error
3
3
}
4
4
package x0
5
- class x0
5
+ class x0 // error // error
Original file line number Diff line number Diff line change 1
- trait x0 []
1
+ trait x0 [] // error
2
2
trait x1 [x1 <: x0]
3
- extends x1[
3
+ extends x1[ // error
You can’t perform that action at this time.
0 commit comments