File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,20 @@ object Applications {
261261 /** Splice new method reference `meth` into existing application `app` */
262262 private def spliceMeth (meth : Tree , app : Tree )(using Context ): Tree = app match {
263263 case Apply (fn, args) =>
264- spliceMeth(meth, fn).appliedToArgs(args)
264+ // Constructors always have one leading non-implicit parameter list.
265+ // Empty list is inserted for constructors where the first parameter list is implicit.
266+ //
267+ // Therefore, we need to ignore the first empty argument list.
268+ // This is needed for the test tests/neg/i12344.scala
269+ //
270+ // see NamerOps.normalizeIfConstructor
271+ //
272+ if args == Nil
273+ && ! fn.isInstanceOf [Apply ]
274+ && app.tpe.isImplicitMethod
275+ && fn.symbol.isConstructor
276+ then meth
277+ else spliceMeth(meth, fn).appliedToArgs(args)
265278 case TypeApply (fn, targs) =>
266279 // Note: It is important that the type arguments `targs` are passed in new trees
267280 // instead of being spliced in literally. Otherwise, a type argument to a default
Original file line number Diff line number Diff line change 1+ import scala .quoted .*
2+
3+ class C (using q : Quotes )(i : Int = 1 , f : q.reflect.Flags = q.reflect.Flags .EmptyFlags )
4+
5+ def test1a (using q : Quotes ) = new C () // error
6+ def test2a (using q : Quotes ) = new C (1 ) // error
7+ def test3a (using q : Quotes ) = new C (1 , q.reflect.Flags .Lazy ) // error
8+ def test4a (using q : Quotes ) = new C (f = q.reflect.Flags .Lazy ) // error
9+
10+ def test1b (using q : Quotes ) = C () // error
11+ def test2b (using q : Quotes ) = C (1 ) // error
12+ def test3b (using q : Quotes ) = C (1 , q.reflect.Flags .Lazy ) // error
13+ def test4b (using q : Quotes ) = C (f = q.reflect.Flags .Lazy ) // error
14+
15+ def test1c (using q : Quotes ) = new C (using q)()
16+ def test2c (using q : Quotes ) = new C (using q)(1 )
17+ def test3c (using q : Quotes ) = new C (using q)(1 , q.reflect.Flags .Lazy )
18+ def test4c (using q : Quotes ) = new C (using q)(f = q.reflect.Flags .Lazy )
19+
20+ def test1d (using q : Quotes ) = C (using q)()
21+ def test2d (using q : Quotes ) = C (using q)(1 )
22+ def test3d (using q : Quotes ) = C (using q)(1 , q.reflect.Flags .Lazy )
23+ def test4d (using q : Quotes ) = C (using q)(f = q.reflect.Flags .Lazy )
24+
25+ def test1e (using q : Quotes ) = new C ()()
26+ def test2e (using q : Quotes ) = C ()()
You can’t perform that action at this time.
0 commit comments