Skip to content

Commit

Permalink
Elide companion defs to a object extending AnyVal
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Aug 24, 2023
1 parent 3783220 commit 673d9bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ object desugar {
}
else if (companionMembers.nonEmpty || companionDerived.nonEmpty || isEnum)
companionDefs(anyRef, companionMembers)
else if (isValueClass)
else if isValueClass && !isObject then
companionDefs(anyRef, Nil)
else Nil

Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i18274.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E078] Syntax Error: tests/neg/i18274.scala:1:7 ---------------------------------------------------------------------
1 |object Foo extends AnyVal // error
| ^
| Value class needs one val parameter
1 change: 1 addition & 0 deletions tests/neg/i18274.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
object Foo extends AnyVal // error

0 comments on commit 673d9bc

Please sign in to comment.