Skip to content

Commit 59e3977

Browse files
committed
Small changes to test
1 parent f019062 commit 59e3977

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/pos/commons.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ trait Text {
77
def apply(idx: Int): Char
88
def concat(txt: Text): Text
99
def toStr: String
10+
def flatten = `common`.fromString(toStr)
1011
}
1112
object Text {
1213
trait Common { self =>
13-
type Instance <: Text { val `common`: self.type }
1414
def fromString(str: String): Text
1515
def fromStrings(strs: String*): Text =
1616
("" :: strs.toList).map(fromString).reduceLeft(_.concat(_))
@@ -19,13 +19,14 @@ object Text {
1919

2020
class FlatText(str: String) extends Text {
2121
val common: FlatText.type = FlatText
22+
import `common`._
23+
2224
def length = str.length
2325
def apply(n: Int) = str.charAt(n)
2426
def concat(txt: Text) = new FlatText(str ++ txt.toStr)
2527
def toStr = str
2628
}
2729
object FlatText extends Text.Common {
28-
type Instance = FlatText
2930
def fromString(str: String) = new FlatText(str)
3031
}
3132

@@ -45,7 +46,7 @@ enum ConcText extends Text {
4546
case Conc(t1, t2) => if (n < t1.length) t1(n) else t2(n - t1.length)
4647
}
4748

48-
def concat(txt: Text) = Conc(this, txt)
49+
def concat(txt: Text): Text = Conc(this, txt)
4950

5051
def toStr: String = this match {
5152
case Str(s) => s
@@ -54,7 +55,6 @@ enum ConcText extends Text {
5455
}
5556

5657
object ConcText extends Text.Common {
57-
type Instance = ConcText
5858
def fromString(str: String) = Str(str)
5959
}
6060

0 commit comments

Comments
 (0)