File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ object Test {
1313
1414 @ varargs def nov (a : Int ) = 0 // error: A method without repeated parameters cannot be annotated with @varargs
1515 @ varargs def v (a : Int , b : String * ) = a + b.length // ok
16+ def v (a : Int , b : String ) = a // ok
1617
1718 @ varargs def v2 (a : Int , b : String * ) = 0 // error
1819 def v2 (a : Int , b : Array [String ]) = 0
Original file line number Diff line number Diff line change 1+ public class Vararg {
2+ void v (int ... i ) {}
3+ }
Original file line number Diff line number Diff line change 1+ public abstract class VarargAbstract {
2+ public abstract void v1 (String ... s );
3+ public abstract void v2 (String ... s );
4+ }
Original file line number Diff line number Diff line change 1+ import scala .annotation .varargs
2+
3+ class VarargImpl extends VarargAbstract {
4+ def v1 (s : String * ) = ()
5+
6+ override def v2 (s : String * ) = ()
7+ }
8+
9+ class VarargSub extends Vararg {
10+ override def v (i : Int * ) = ()
11+ }
12+
13+ object Test {
14+ def main (args : Array [String ]): Unit =
15+ val a : VarargAbstract = VarargImpl ()
16+ a.v1(" a" , " b" , " c" )
17+ a.v2(" a" , " b" , " c" )
18+
19+ val i : VarargImpl = VarargImpl ()
20+ i.v1(" a" , " b" , " c" )
21+ i.v2(" a" , " b" , " c" )
22+
23+ val b : Vararg = VarargSub ()
24+ b.v(1 , 2 , 3 )
25+
26+ val c : VarargSub = VarargSub ()
27+ c.v(1 , 2 , 3 )
28+ }
You can’t perform that action at this time.
0 commit comments