Skip to content

Commit 1518801

Browse files
Merge pull request #2475 from dotty-staging/fix-#2470
Fix #2470: Do not desugar companion for AnyVal object
2 parents abad0ad + f8d7a8e commit 1518801

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,12 @@ object desugar {
462462
}
463463
else if (defaultGetters.nonEmpty)
464464
companionDefs(anyRef, defaultGetters)
465-
else if (isValueClass)
466-
companionDefs(anyRef, Nil)
465+
else if (isValueClass) {
466+
constr0.vparamss match {
467+
case List(_ :: Nil) => companionDefs(anyRef, Nil)
468+
case _ => Nil // error will be emitted in typer
469+
}
470+
}
467471
else Nil
468472

469473
// For an implicit class C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, .., pMN: TMN), the method

tests/neg/i2470.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
object Foo extends AnyVal // error: value class needs to have exactly one val parameter

0 commit comments

Comments
 (0)