From 315440a70c2534bdd860e31e3e1672d69bcce577 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Sat, 11 Jan 2025 00:35:06 +0100 Subject: [PATCH] fix: splicing of default getters should not special case constructors with implicits --- .../dotty/tools/dotc/typer/Applications.scala | 16 +--------------- tests/pos/i22061.scala | 5 +++++ 2 files changed, 6 insertions(+), 15 deletions(-) create mode 100644 tests/pos/i22061.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index c2864093ff70..119c02eba297 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -365,21 +365,7 @@ object Applications { /** Splice new method reference `meth` into existing application `app` */ private def spliceMeth(meth: Tree, app: Tree)(using Context): Tree = app match { - case Apply(fn, args) => - // Constructors always have one leading non-implicit parameter list. - // Empty list is inserted for constructors where the first parameter list is implicit. - // - // Therefore, we need to ignore the first empty argument list. - // This is needed for the test tests/neg/i12344.scala - // - // see NamerOps.normalizeIfConstructor - // - if args == Nil - && !fn.isInstanceOf[Apply] - && app.tpe.isImplicitMethod - && fn.symbol.isConstructor - then meth - else spliceMeth(meth, fn).appliedToArgs(args) + case Apply(fn, args) => spliceMeth(meth, fn).appliedToArgs(args) case TypeApply(fn, targs) => // Note: It is important that the type arguments `targs` are passed in new trees // instead of being spliced in literally. Otherwise, a type argument to a default diff --git a/tests/pos/i22061.scala b/tests/pos/i22061.scala new file mode 100644 index 000000000000..0e44967ac97b --- /dev/null +++ b/tests/pos/i22061.scala @@ -0,0 +1,5 @@ +abstract class A()(implicit val x: Int = 3) +trait B extends A + +abstract class C()(using y: Int = 9) +class D extends C() \ No newline at end of file