Skip to content

Added error messages - Parsers.scala:712 #1842

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
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: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ object Parsers {

in.token match {
case ARROW => functionRest(t :: Nil)
case FORSOME => syntaxError("existential types no longer supported; use a wildcard type or dependent type instead"); t
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported()); t
case _ => t
}
}
Expand Down
26 changes: 24 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ package diagnostic

import dotc.core._
import Contexts.Context, Decorators._, Symbols._, Names._, NameOps._, Types._
import util.{SourceFile, NoSource}
import util.{SourcePosition, NoSourcePosition}
import util.SourcePosition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line shouldn't need to be added IIRC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imports that were removed were unused, that's why I removed them. util.SourcePosition still needs to be included as it is in use in the MessageContainers.

I can put the imports back in if that's what you want

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it's fine boyscout principle right? 😃. The one below however didn't need to change right?

Copy link
Contributor Author

@raindeerr raindeerr Dec 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my idea in cleaning up the used imports! 😄

No the one below shouldn't have changed, I've fixed that. That might have been the IDE trying to tidy up for me!

import config.Settings.Setting
import interfaces.Diagnostic.{ERROR, WARNING, INFO}
import printing.Highlighting._
Expand Down Expand Up @@ -901,4 +900,27 @@ object messages {
val msg = hl"trying to define package with same name as `$existing`"
val explanation = ""
}

case class ExistentialTypesNoLongerSupported()(implicit ctx: Context) extends Message(34) {
val kind = "Syntax"
val msg =
hl"""|Existential types are no longer supported -
|use a wildcard or dependent type instead"""
val explanation =
hl"""|The use of existential types is no longer supported.
|
|You should use a wildcard or dependent type instead.
|
|For example:
|
|Instead of using ${"forSome"} to specify a type variable
|
|${"List[T forSome { type T }]"}
|
|Try using a wildcard type variable
|
|${"List[_]"}
|"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout this explanation, there's no need for there to be a padding of whitespace after the |-signs. None of the other messages should be doing this.

}

}