-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Named type error messages to new format #3419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
e7b1e44
aa23a8e
674d9fc
dbe80de
615bf48
45db4b8
3b48a3a
439a331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1865,4 +1865,18 @@ object messages { | |
|Excluded from this rule are methods that are defined in Java or that override methods defined in Java.""" | ||
} | ||
} | ||
|
||
case class DuplicateNamedTypeArgument(name: Name)(implicit ctx: Context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to |
||
extends Message(DuplicateNamedTypeArgumentID) { | ||
val kind = "Syntax" | ||
val msg = hl"Type parameter $name was defined multiple times." | ||
val explanation = "" | ||
} | ||
|
||
case class UndefinedNamedTypeArgument(undefinedName: Name, definedNames: List[Name])(implicit ctx: Context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to |
||
extends Message(UndefinedNamedTypeArgumentID) { | ||
val kind = "Syntax" | ||
val msg = hl"Type parameter $undefinedName is undefined. Expected one of ${definedNames.mkString(", ")}." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
val explanation = "" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1088,4 +1088,47 @@ class ErrorMessagesTests extends ErrorMessagesTest { | |
val MissingEmptyArgumentList(method) :: Nil = messages | ||
assertEquals("method greet", method.show) | ||
} | ||
|
||
@Test def duplicateNamedTypeArgument = | ||
checkMessagesAfter("frontend") { | ||
""" | ||
|object Test { | ||
| def f[A, B]() = ??? | ||
| f[A=Any, A=Any]() | ||
| f[B=Any, B=Any]() | ||
|} | ||
| | ||
""".stripMargin | ||
} | ||
.expect { (ictx, messages) => | ||
implicit val ctx: Context = ictx | ||
|
||
assertMessageCount(2, messages) | ||
val DuplicateNamedTypeArgument(n2) :: DuplicateNamedTypeArgument(n1) :: Nil = messages | ||
assertEquals("A", n1.show) | ||
assertEquals("B", n2.show) | ||
} | ||
|
||
@Test def undefinedNamedTypeArgument = | ||
checkMessagesAfter("frontend") { | ||
""" | ||
|object Test { | ||
| def f[A, B]() = ??? | ||
| f[A=Any, C=Any]() | ||
| f[C=Any, B=Any]() | ||
|} | ||
| | ||
""".stripMargin | ||
} | ||
.expect { (ictx, messages) => | ||
implicit val ctx: Context = ictx | ||
|
||
assertMessageCount(2, messages) | ||
val UndefinedNamedTypeArgument(n2, l2) :: UndefinedNamedTypeArgument(n1, l1) :: Nil = messages | ||
assertEquals("C", n1.show) | ||
assertEquals("A"::"B"::Nil, l1.map(_.show)) | ||
assertEquals("C", n2.show) | ||
assertEquals("A"::"B"::Nil, l2.map(_.show)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. val tpParams = List("A", "B")
assertEquals(tpParams, l1.map(_.show))
assertEquals(tpParams, l2.map(_.show)) |
||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
DuplicateNamedTypeParameterID
andUndefinedNamedTypeParameterID