diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-31 13:09:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 13:09:17 +0100 |
commit | 9f3005c1b742b6d05e94a93ad9ac31b02f951008 (patch) | |
tree | bcadbabcda83733fe11c42f7addd7f8ba234b4a8 /src | |
parent | 167a885edb76eecc1d8582489b1fbb085a3ba799 (diff) | |
parent | ba7f0112ea5174ba2a70c2b6d9f1744508183c78 (diff) | |
download | dotty-9f3005c1b742b6d05e94a93ad9ac31b02f951008.tar.gz dotty-9f3005c1b742b6d05e94a93ad9ac31b02f951008.tar.bz2 dotty-9f3005c1b742b6d05e94a93ad9ac31b02f951008.zip |
Merge pull request #1630 from m-sp/master
Add error message Parsers.scala:1620 missing type keyword
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/parsing/Parsers.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala index 6871916dd..754db3d3b 100644 --- a/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1623,7 +1623,7 @@ object Parsers { val mod = atPos(in.skipToken()) { Mod.Type() } (mods | Param | ParamAccessor).withAddedMod(mod) } else { - if (mods.hasFlags) syntaxError("`type' expected") + if (mods.hasFlags) syntaxError(TypeParamsTypeExpected(mods, ident())) mods | Param | PrivateLocal } } diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 2913f4f4c..67d53fd22 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -677,5 +677,18 @@ object messages { | |$fixedVarInAlternative""".stripMargin } + } + + case class TypeParamsTypeExpected(mods: Modifiers, identifier: TermName)(implicit ctx: Context) extends Message(24) { + val kind = "Syntax" + + val msg = hl"""Expected ${"type"} keyword for type parameter $identifier""" + + val explanation = hl"""|This happens when you add modifiers like ${"private"} or ${"protected"} + |to your type parameter definition without adding the ${"type"} keyword. + | + |Add ${"type"} to your code, e.g.: + |${s"trait A[${mods.flags} type $identifier]"} + |""".stripMargin } } |