Skip to content

Commit ee4f4a1

Browse files
raindeerrfelixmulder
authored andcommitted
Add error messages - Parsers.scala:712 (#1842)
* Add error messages - Parsers.scala:712 * Tidy up imports and formatting
1 parent f3bf225 commit ee4f4a1

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ object Parsers {
730730

731731
in.token match {
732732
case ARROW => functionRest(t :: Nil)
733-
case FORSOME => syntaxError("existential types no longer supported; use a wildcard type or dependent type instead"); t
733+
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported()); t
734734
case _ => t
735735
}
736736
}

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ package diagnostic
55

66
import dotc.core._
77
import Contexts.Context, Decorators._, Symbols._, Names._, NameOps._, Types._
8-
import util.{SourceFile, NoSource}
9-
import util.{SourcePosition, NoSourcePosition}
8+
import util.SourcePosition
109
import config.Settings.Setting
1110
import interfaces.Diagnostic.{ERROR, WARNING, INFO}
1211
import printing.Highlighting._
@@ -901,4 +900,27 @@ object messages {
901900
val msg = hl"trying to define package with same name as `$existing`"
902901
val explanation = ""
903902
}
903+
904+
case class ExistentialTypesNoLongerSupported()(implicit ctx: Context) extends Message(34) {
905+
val kind = "Syntax"
906+
val msg =
907+
hl"""|Existential types are no longer supported -
908+
|use a wildcard or dependent type instead"""
909+
val explanation =
910+
hl"""|The use of existential types is no longer supported.
911+
|
912+
|You should use a wildcard or dependent type instead.
913+
|
914+
|For example:
915+
|
916+
|Instead of using ${"forSome"} to specify a type variable
917+
|
918+
|${"List[T forSome { type T }]"}
919+
|
920+
|Try using a wildcard type variable
921+
|
922+
|${"List[_]"}
923+
|"""
924+
}
925+
904926
}

0 commit comments

Comments
 (0)