Skip to content

Commit f8d7a8e

Browse files
committed
Fix #2470: Do not desugar companion for AnyVal object
1 parent 8a9aedc commit f8d7a8e

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
@@ -461,8 +461,12 @@ object desugar {
461461
}
462462
else if (defaultGetters.nonEmpty)
463463
companionDefs(anyRef, defaultGetters)
464-
else if (isValueClass)
465-
companionDefs(anyRef, Nil)
464+
else if (isValueClass) {
465+
constr0.vparamss match {
466+
case List(_ :: Nil) => companionDefs(anyRef, Nil)
467+
case _ => Nil // error will be emitted in typer
468+
}
469+
}
466470
else Nil
467471

468472
// 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)