Skip to content

Update error msg for Parsers.scala:1738 and 1739 #1629

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
Oct 31, 2016
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
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1742,8 +1742,8 @@ object Parsers {
if (owner == nme.CONSTRUCTOR && (result.isEmpty || (result.head take 1 exists (_.mods is Implicit)))) {
in.token match {
case LBRACKET => syntaxError("no type parameters allowed here")
case EOF => incompleteInputError("auxiliary constructor needs non-implicit parameter list")
case _ => syntaxError("auxiliary constructor needs non-implicit parameter list", start)
case EOF => incompleteInputError(AuxConstructorNeedsNonImplicitParameter())
case _ => syntaxError(AuxConstructorNeedsNonImplicitParameter(), start)
}
}
result
Expand Down
17 changes: 17 additions & 0 deletions src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -715,4 +715,21 @@ object messages {
|""".stripMargin
}
}

case class AuxConstructorNeedsNonImplicitParameter()(implicit ctx:Context) extends Message(26) {
val kind = "Syntax"
val msg = "auxiliary constructor needs non-implicit parameter list"
val explanation =
hl"""Only the primary constructor is allowed an ${"implicit"} parameter list;
|auxiliary constructors need a non-implicit parameter list. When a primary
|constructor has an implicit argslist, auxiliary constructors that call the
|primary constructor must specify the implicit value.
|
|To resolve this issue check for:
| - forgotten parenthesis on ${"this"} (${"def this() = // ..."})
| - auxiliary constructors specify the implicit value
|""".stripMargin
}


}