File tree 4 files changed +73
-0
lines changed
src/compiler/scala/tools/nsc/typechecker 4 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,11 @@ trait ContextErrors {
224
224
def SuperConstrArgsThisReferenceError (tree : Tree ) =
225
225
NormalTypeError (tree, " super constructor arguments cannot reference unconstructed `this`" )
226
226
227
+ def TooManyArgumentListsForConstructor (tree : Tree ) = {
228
+ issueNormalTypeError(tree, " too many argument lists for constructor invocation" )
229
+ setError(tree)
230
+ }
231
+
227
232
// typedValDef
228
233
def VolatileValueError (vdef : Tree ) =
229
234
issueNormalTypeError(vdef, " values cannot be volatile" )
Original file line number Diff line number Diff line change @@ -4950,6 +4950,8 @@ trait Typers extends Modes with Adaptations with Tags {
4950
4950
else new ApplyToImplicitArgs (Select (tag, nme.newArray), args)
4951
4951
}
4952
4952
typed(newArrayApp, mode, pt)
4953
+ case Apply (Select (fun, nme.apply), _) if treeInfo.isSuperConstrCall(fun) => // SI-5696
4954
+ TooManyArgumentListsForConstructor (tree)
4953
4955
case tree1 =>
4954
4956
tree1
4955
4957
}
Original file line number Diff line number Diff line change
1
+ t5696.scala:6: error: too many argument lists for constructor invocation
2
+ new G(1)(2) {}
3
+ ^
4
+ t5696.scala:14: error: too many argument lists for constructor invocation
5
+ new G()(2) {}
6
+ ^
7
+ t5696.scala:22: error: too many argument lists for constructor invocation
8
+ new G[Int]()(2) {}
9
+ ^
10
+ t5696.scala:30: error: too many argument lists for constructor invocation
11
+ new G[Int]()(2)(3) {}
12
+ ^
13
+ t5696.scala:38: error: too many argument lists for constructor invocation
14
+ new G[Int]()()(2) {}
15
+ ^
16
+ t5696.scala:46: error: too many argument lists for constructor invocation
17
+ object x extends G(1)(2) {}
18
+ ^
19
+ 6 errors found
Original file line number Diff line number Diff line change
1
+ class TestApply1 {
2
+ class G (y : Int ) {
3
+ def apply (x : Int ) = 1
4
+ }
5
+
6
+ new G (1 )(2 ) {}
7
+ }
8
+
9
+ class TestApply2 {
10
+ class G {
11
+ def apply (x : Int ) = 1
12
+ }
13
+
14
+ new G ()(2 ) {}
15
+ }
16
+
17
+ class TestApply3 {
18
+ class G [X ] {
19
+ def apply (x : Int ) = 1
20
+ }
21
+
22
+ new G [Int ]()(2 ) {}
23
+ }
24
+
25
+ class TestApply4 {
26
+ class G [X ] {
27
+ def apply (x : Int )(y : Int ) = 1
28
+ }
29
+
30
+ new G [Int ]()(2 )(3 ) {}
31
+ }
32
+
33
+ class TestApply5 {
34
+ class G [X ]()() {
35
+ def apply (x : Int ) = 1
36
+ }
37
+
38
+ new G [Int ]()()(2 ) {}
39
+ }
40
+
41
+ class TestApply6 {
42
+ class G (y : Int ) {
43
+ def apply (x : Int ) = 1
44
+ }
45
+
46
+ object x extends G (1 )(2 ) {}
47
+ }
You can’t perform that action at this time.
0 commit comments