Skip to content

Commit 2e6c00b

Browse files
committed
Fix non-implicit constructor arg list handling with -Yimplicit-as-given
1 parent 9a5bd70 commit 2e6c00b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ object desugar {
635635
ValDef(vparam.name, vparam.tpt, vparam.rhs)
636636
.withSpan(vparam.span)
637637
.withAttachmentsFrom(vparam)
638-
.withMods(mods & (GivenOrImplicit | Erased | hasDefault | Tracked) | Param)
638+
.withMods(mods & (GivenOrImplicit | Erased | hasDefault | Tracked | FromImplicit) | Param)
639639
}
640640

641641
/** Desugar type def (not param): Under x.moduliity this can expand

compiler/src/dotty/tools/dotc/core/NamerOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object NamerOps:
6363
if !isConstructor then paramss
6464
else paramss match
6565
case TypeSymbols(tparams) :: paramss1 => tparams :: normalizeIfConstructor(paramss1, isConstructor)
66-
case TermSymbols(vparam :: _) :: _ if vparam.is(Implicit) => Nil :: paramss
66+
case TermSymbols(vparam :: _) :: _ if vparam.is(Implicit) || vparam.is(FromImplicit) => Nil :: paramss
6767
case _ =>
6868
if paramss.forall {
6969
case TermSymbols(vparams) => vparams.nonEmpty && vparams.head.is(Given)

tests/pos/i22482.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ def bar()(implicit a: Int) : Unit = ???
66
def main() =
77
foo(0)
88
bar()(0)
9+
10+
class Foo(implicit hashA: Int):
11+
// added empty param list, works only for implicits
12+
def this(o: Int, h: Int) = this()(h)

0 commit comments

Comments
 (0)