File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
106
106
case _ => Nil
107
107
}
108
108
109
+ /** Is tree a constructor call this(...) or new C(...)? */
110
+ def isConstrCall (tree : Tree ): Boolean = methPart(tree) match {
111
+ case Select (_, nme.CONSTRUCTOR ) => true
112
+ case _ => false
113
+ }
114
+
109
115
/** Is tree a self constructor call this(...)? I.e. a call to a constructor of the
110
116
* same object?
111
117
*/
Original file line number Diff line number Diff line change @@ -2282,7 +2282,10 @@ class Typer extends Namer
2282
2282
pt.markAsDropped()
2283
2283
tree
2284
2284
case _ =>
2285
- if (isApplyProto(pt) || isMethod(tree) || isSyntheticApply(tree)) tryImplicit(fallBack)
2285
+ if (isConstrCall(tree))
2286
+ fallBack
2287
+ if (isApplyProto(pt) || isMethod(tree) || isSyntheticApply(tree))
2288
+ tryImplicit(fallBack)
2286
2289
else tryEither(tryApply(_)) { (app, appState) =>
2287
2290
tryImplicit {
2288
2291
if (tree.tpe.member(nme.apply).exists) {
Original file line number Diff line number Diff line change
1
+ class I1 (i2 : Int ) {
2
+ def apply (i3 : Int ) = 1 // error: constructor I1 in class I1 does not take more parameters
3
+ new I1 (1 )(2 ) {}
4
+ }
5
+
6
+ class I0 (i1 : Int ) {
7
+ class I0 [I2 ] {
8
+ def apply (i3 : Int ) = 1
9
+ new I0 [Int ]()(2 ) {} // error: constructor I0 in class I0 does not take more parameters
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments