Skip to content

Commit 02737ec

Browse files
committed
Account for () insertion in class params when generating instances
The () has to be dropped again in an instance method, since otherwise it would not be applicable. This is a temporary fix. It would be more systematic to avoid the generation of implicit () parameters of classes in the first place.
1 parent cf9b3ec commit 02737ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,19 @@ object desugar {
673673
ctx.error(ImplicitClassPrimaryConstructorArity(), cdef.sourcePos)
674674
Nil
675675
}
676-
else
676+
else {
677+
val defParamss = constrVparamss match {
678+
case Nil :: paramss =>
679+
paramss // drop leading () that got inserted by class
680+
// TODO: drop this once we do not silently insert empty class parameters anymore
681+
case paramss => paramss
682+
}
677683
// implicit wrapper is typechecked in same scope as constructor, so
678684
// we can reuse the constructor parameters; no derived params are needed.
679-
DefDef(className.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr)
685+
DefDef(className.toTermName, constrTparams, defParamss, classTypeRef, creatorExpr)
680686
.withMods(companionMods | Synthetic | Implicit)
681687
.withSpan(cdef.span) :: Nil
688+
}
682689

683690
val self1 = {
684691
val selfType = if (self.tpt.isEmpty) classTypeRef else self.tpt

0 commit comments

Comments
 (0)