Skip to content

Commit 843f976

Browse files
committed
Two fixes in desugar
(1) set position of companion object def (2) companions of case classes taking multiple parameter lists do not inherit from a function type (reason: we can't straightforwardly converyt a curried method with multiple parameter lists to a function value).
1 parent 81745e2 commit 843f976

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ object desugar {
324324
moduleDef(
325325
ModuleDef(
326326
Modifiers(Synthetic), name.toTermName,
327-
Template(emptyConstructor, parentTpt :: Nil, EmptyValDef, defs))).toList
327+
Template(emptyConstructor, parentTpt :: Nil, EmptyValDef, defs)))
328+
.withPos(cdef.pos).toList
328329

329330
// The companion object defifinitions, if a companion is needed, Nil otherwise.
330331
// companion definitions include:
@@ -338,7 +339,8 @@ object desugar {
338339
val companions =
339340
if (mods is Case) {
340341
val parent =
341-
if (constrTparams.nonEmpty) anyRef // todo: also use anyRef if constructor has a dependent method type (or rule that out)!
342+
if (constrTparams.nonEmpty || constrVparamss.length > 1) anyRef
343+
// todo: also use anyRef if constructor has a dependent method type (or rule that out)!
342344
else (constrVparamss :\ classTypeRef) ((vparams, restpe) => Function(vparams map (_.tpt), restpe))
343345
val applyMeths =
344346
if (mods is Abstract) Nil

0 commit comments

Comments
 (0)