From ee4f4a109b3ec3190886c75bb6d140087c33287d Mon Sep 17 00:00:00 2001 From: Adam Trousdale Date: Wed, 21 Dec 2016 20:12:56 +0000 Subject: Add error messages - Parsers.scala:712 (#1842) * Add error messages - Parsers.scala:712 * Tidy up imports and formatting --- .../src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- .../tools/dotc/reporting/diagnostic/messages.scala | 26 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'compiler') diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 76f82d8af..57dd1ea20 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -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 } } diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 9dda233bf..b55b7e868 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -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 import config.Settings.Setting import interfaces.Diagnostic.{ERROR, WARNING, INFO} import printing.Highlighting._ @@ -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[_]"} + |""" + } + } -- cgit v1.2.3