@@ -3,17 +3,17 @@ package scala.runtime
3
3
import scala .collection .immutable .ArraySeq
4
4
import scala .reflect .ClassTag
5
5
6
- sealed abstract class ArraySeqBuilder [T ]:
6
+ sealed abstract class VarArgsBuilder [T ]:
7
7
def add (elem : T ): this .type
8
8
def addSeq (elems : Seq [T ]): this .type
9
9
def addArray (elems : Array [T ]): this .type
10
- def result : ArraySeq [T ]
10
+ def result () : Seq [T ]
11
11
12
- object ArraySeqBuilder :
12
+ object VarArgsBuilder :
13
13
14
- def generic [T ](n : Int ) = new ArraySeqBuilder [T ]:
14
+ def generic [T ](n : Int ): VarArgsBuilder [ T ] = new VarArgsBuilder [T ]:
15
15
private val xs = new Array [AnyRef ](n)
16
- def result = ArraySeq .ofRef(xs).asInstanceOf [ArraySeq [T ]]
16
+ def result () = ArraySeq .ofRef(xs).asInstanceOf [ArraySeq [T ]]
17
17
private var i = 0
18
18
def add (elem : T ): this .type =
19
19
xs(i) = elem.asInstanceOf [AnyRef ]
@@ -30,9 +30,9 @@ object ArraySeqBuilder:
30
30
i += 1
31
31
this
32
32
33
- def ofRef [T <: AnyRef ](n : Int )( using ClassTag [T ]) = new ArraySeqBuilder [T ]:
34
- private val xs = new Array [T ](n)
35
- def result = ArraySeq .ofRef(xs)
33
+ def ofRef [T <: AnyRef ](n : Int ): VarArgsBuilder [T ] = new VarArgsBuilder [T ]:
34
+ private val xs = new Array [AnyRef ](n)
35
+ def result () = ArraySeq .ofRef(xs). asInstanceOf [ ArraySeq [ T ]]
36
36
private var i = 0
37
37
def add (elem : T ): this .type =
38
38
xs(i) = elem
@@ -49,9 +49,9 @@ object ArraySeqBuilder:
49
49
i += 1
50
50
this
51
51
52
- def ofByte (n : Int ) = new ArraySeqBuilder [Byte ]:
52
+ def ofByte (n : Int ): VarArgsBuilder [ Byte ] = new VarArgsBuilder [Byte ]:
53
53
private val xs = new Array [Byte ](n)
54
- def result = ArraySeq .ofByte(xs)
54
+ def result () = ArraySeq .ofByte(xs)
55
55
private var i = 0
56
56
def add (elem : Byte ): this .type =
57
57
xs(i) = elem
@@ -68,9 +68,9 @@ object ArraySeqBuilder:
68
68
i += 1
69
69
this
70
70
71
- def ofShort (n : Int ) = new ArraySeqBuilder [Short ]:
71
+ def ofShort (n : Int ): VarArgsBuilder [ Short ] = new VarArgsBuilder [Short ]:
72
72
private val xs = new Array [Short ](n)
73
- def result = ArraySeq .ofShort(xs)
73
+ def result () = ArraySeq .ofShort(xs)
74
74
private var i = 0
75
75
def add (elem : Short ): this .type =
76
76
xs(i) = elem
@@ -87,9 +87,9 @@ object ArraySeqBuilder:
87
87
i += 1
88
88
this
89
89
90
- def ofChar (n : Int ) = new ArraySeqBuilder [Char ]:
90
+ def ofChar (n : Int ): VarArgsBuilder [ Char ] = new VarArgsBuilder [Char ]:
91
91
private val xs = new Array [Char ](n)
92
- def result = ArraySeq .ofChar(xs)
92
+ def result () = ArraySeq .ofChar(xs)
93
93
private var i = 0
94
94
def add (elem : Char ): this .type =
95
95
xs(i) = elem
@@ -106,9 +106,9 @@ object ArraySeqBuilder:
106
106
i += 1
107
107
this
108
108
109
- def ofInt (n : Int ) = new ArraySeqBuilder [Int ]:
109
+ def ofInt (n : Int ): VarArgsBuilder [ Int ] = new VarArgsBuilder [Int ]:
110
110
private val xs = new Array [Int ](n)
111
- def result = ArraySeq .ofInt(xs)
111
+ def result () = ArraySeq .ofInt(xs)
112
112
private var i = 0
113
113
def add (elem : Int ): this .type =
114
114
xs(i) = elem
@@ -125,9 +125,9 @@ object ArraySeqBuilder:
125
125
i += 1
126
126
this
127
127
128
- def ofLong (n : Int ) = new ArraySeqBuilder [Long ]:
128
+ def ofLong (n : Int ): VarArgsBuilder [ Long ] = new VarArgsBuilder [Long ]:
129
129
private val xs = new Array [Long ](n)
130
- def result = ArraySeq .ofLong(xs)
130
+ def result () = ArraySeq .ofLong(xs)
131
131
private var i = 0
132
132
def add (elem : Long ): this .type =
133
133
xs(i) = elem
@@ -144,9 +144,9 @@ object ArraySeqBuilder:
144
144
i += 1
145
145
this
146
146
147
- def ofFloat (n : Int ) = new ArraySeqBuilder [Float ]:
147
+ def ofFloat (n : Int ): VarArgsBuilder [ Float ] = new VarArgsBuilder [Float ]:
148
148
private val xs = new Array [Float ](n)
149
- def result = ArraySeq .ofFloat(xs)
149
+ def result () = ArraySeq .ofFloat(xs)
150
150
private var i = 0
151
151
def add (elem : Float ): this .type =
152
152
xs(i) = elem
@@ -163,9 +163,9 @@ object ArraySeqBuilder:
163
163
i += 1
164
164
this
165
165
166
- def ofDouble (n : Int ) = new ArraySeqBuilder [Double ]:
166
+ def ofDouble (n : Int ): VarArgsBuilder [ Double ] = new VarArgsBuilder [Double ]:
167
167
private val xs = new Array [Double ](n)
168
- def result = ArraySeq .ofDouble(xs)
168
+ def result () = ArraySeq .ofDouble(xs)
169
169
private var i = 0
170
170
def add (elem : Double ): this .type =
171
171
xs(i) = elem
@@ -182,9 +182,9 @@ object ArraySeqBuilder:
182
182
i += 1
183
183
this
184
184
185
- def ofBoolean (n : Int ) = new ArraySeqBuilder [Boolean ]:
185
+ def ofBoolean (n : Int ): VarArgsBuilder [ Boolean ] = new VarArgsBuilder [Boolean ]:
186
186
private val xs = new Array [Boolean ](n)
187
- def result = ArraySeq .ofBoolean(xs)
187
+ def result () = ArraySeq .ofBoolean(xs)
188
188
private var i = 0
189
189
def add (elem : Boolean ): this .type =
190
190
xs(i) = elem
@@ -201,9 +201,9 @@ object ArraySeqBuilder:
201
201
i += 1
202
202
this
203
203
204
- def ofUnit (n : Int ) = new ArraySeqBuilder [Unit ]:
204
+ def ofUnit (n : Int ): VarArgsBuilder [ Unit ] = new VarArgsBuilder [Unit ]:
205
205
private val xs = new Array [Unit ](n)
206
- def result = ArraySeq .ofUnit(xs)
206
+ def result () = ArraySeq .ofUnit(xs)
207
207
private var i = 0
208
208
def add (elem : Unit ): this .type =
209
209
xs(i) = elem
@@ -220,4 +220,4 @@ object ArraySeqBuilder:
220
220
i += 1
221
221
this
222
222
223
- end ArraySeqBuilder
223
+ end VarArgsBuilder
0 commit comments