From 44b8b5c06cff8dd6282d8156ee7b5fb4edaf1068 Mon Sep 17 00:00:00 2001 From: Adam Trousdale Date: Wed, 21 Dec 2016 09:49:53 +0000 Subject: [PATCH 1/2] Added error messages - Parsers.scala:712 --- .../dotty/tools/dotc/parsing/Parsers.scala | 2 +- .../dotc/reporting/diagnostic/messages.scala | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 76f82d8af242..57dd1ea20b07 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 9dda233bffe6..07ba118719b8 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -5,10 +5,9 @@ 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 interfaces.Diagnostic.{ERROR, INFO, WARNING} import printing.Highlighting._ import printing.Formatting @@ -901,4 +900,23 @@ 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 = "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 and a wildcard or dependent type should be used instead + | + | For example: + | + | Instead of using ${"forSome"} to specify a type variable + | + | ${"List[T forSome { type T }]"} + | + | Try using a wildcard type variable + | + | ${"List[_]"} + |""" + } + } From e3da9482fc8323337131661611dde76e52121945 Mon Sep 17 00:00:00 2001 From: Adam Trousdale Date: Wed, 21 Dec 2016 19:36:12 +0000 Subject: [PATCH 2/2] Tidied up imports and formatting --- .../dotc/reporting/diagnostic/messages.scala | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 07ba118719b8..b55b7e8683f2 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -7,7 +7,7 @@ import dotc.core._ import Contexts.Context, Decorators._, Symbols._, Names._, NameOps._, Types._ import util.SourcePosition import config.Settings.Setting -import interfaces.Diagnostic.{ERROR, INFO, WARNING} +import interfaces.Diagnostic.{ERROR, WARNING, INFO} import printing.Highlighting._ import printing.Formatting @@ -903,19 +903,23 @@ object messages { case class ExistentialTypesNoLongerSupported()(implicit ctx: Context) extends Message(34) { val kind = "Syntax" - val msg = "Existential types are no longer supported - use a wildcard or dependent type instead" + 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 and a wildcard or dependent type should be used instead + hl"""|The use of existential types is no longer supported. + | + |You should use a wildcard or dependent type instead. | - | For example: + |For example: | - | Instead of using ${"forSome"} to specify a type variable + |Instead of using ${"forSome"} to specify a type variable | - | ${"List[T forSome { type T }]"} + |${"List[T forSome { type T }]"} | - | Try using a wildcard type variable + |Try using a wildcard type variable | - | ${"List[_]"} + |${"List[_]"} |""" }