Skip to content

Fix #8598: Refinements cannot have default arguments #8614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3771,6 +3771,8 @@ object Parsers {
val problem = tree match
case tree: MemberDef if !(tree.mods.flags & ModifierFlags).isEmpty =>
i"refinement cannot be ${(tree.mods.flags & ModifierFlags).flagStrings().mkString("`", "`, `", "`")}"
case tree: DefDef if tree.vparamss.exists(_.exists(!_.rhs.isEmpty)) =>
i"refinement cannot have default arguments"
case tree: ValOrDefDef =>
if tree.rhs.isEmpty then ""
else "refinement in cannot have a right-hand side"
Expand Down
1 change: 1 addition & 0 deletions tests/neg/default-arg-in-refinement.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def foo[T <: AnyRef { def bar(a: Int = 0): Unit }](t: T): Unit = t.bar // error // error