Skip to content

Commit 44b8b5c

Browse files
committed
Added error messages - Parsers.scala:712
1 parent e23c278 commit 44b8b5c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
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: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ 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
11-
import interfaces.Diagnostic.{ERROR, WARNING, INFO}
10+
import interfaces.Diagnostic.{ERROR, INFO, WARNING}
1211
import printing.Highlighting._
1312
import printing.Formatting
1413

@@ -901,4 +900,23 @@ 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 = "Existential types are no longer supported - use a wildcard or dependent type instead"
907+
val explanation =
908+
hl"""| The use of existential types is no longer supported and a wildcard or dependent type should be used instead
909+
|
910+
| For example:
911+
|
912+
| Instead of using ${"forSome"} to specify a type variable
913+
|
914+
| ${"List[T forSome { type T }]"}
915+
|
916+
| Try using a wildcard type variable
917+
|
918+
| ${"List[_]"}
919+
|"""
920+
}
921+
904922
}

0 commit comments

Comments
 (0)