File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -795,6 +795,18 @@ trait Checking {
795
795
}
796
796
traverser.traverse(call)
797
797
}
798
+
799
+ // Check that constructor call is of the form _.<init>(args1)...(argsN).
800
+ // This guards against calls resulting from inserted implicits or applies.
801
+ def checkLegalConstructorCall (tree : Tree , encl : Tree ): Unit = tree match {
802
+ case Apply (fn, _) => checkLegalConstructorCall(fn, tree)
803
+ case Select (_, nme.CONSTRUCTOR ) => // ok
804
+ case _ => ctx.error(" too many arguments in parent constructor" , encl.sourcePos)
805
+ }
806
+ call match {
807
+ case Apply (fn, _) => checkLegalConstructorCall(fn, call)
808
+ case _ =>
809
+ }
798
810
}
799
811
800
812
/** Check that `tpt` does not define a higher-kinded type */
Original file line number Diff line number Diff line change
1
+ class I1 (i2 : Int ) {
2
+ def apply (i3 : Int ) = 1
3
+ new I1 (1 )(2 ) {} // error: too many arguments in parent constructor
4
+ }
5
+
6
+ class I0 (i1 : Int ) {
7
+ class I0 [I2 ] {
8
+ def apply (i3 : Int ) = 1
9
+ new I0 [Int ]()(2 ) {} // error: too many arguments in parent constructor
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments