Skip to content

Commit

Permalink
solves dotc assertion error on (non-sensical?) parameter type. scala#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioDSR authored and olsdavis committed Apr 4, 2022
1 parent 5ccc54b commit 3597543
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ object Parsers {
def convertToParam(tree: Tree, mods: Modifiers, expected: String = "formal parameter"): ValDef = tree match {
case id @ Ident(name) =>
makeParameter(name.asTermName, TypeTree(), mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
case Typed(_, tpt: TypeBoundsTree) =>
syntaxError(s"not a legal $expected", tree.span)
makeParameter(nme.ERROR, tree, mods)
case Typed(id @ Ident(name), tpt) =>
makeParameter(name.asTermName, tpt, mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
case Typed(Splice(Ident(name)), tpt) =>
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i13769.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Error: tests/neg/i13769.scala:2:18 ----------------------------------------------------------------------------------
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
| ^^^^^^^^^^^
| not a legal formal parameter
-- [E006] Not Found Error: tests/neg/i13769.scala:2:39 -----------------------------------------------------------------
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
| ^
| Not found: x

longer explanation available when compiling with `-explain`
2 changes: 2 additions & 0 deletions tests/neg/i13769.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val tup = (1, "s")
val te = tup.map((x: _ <: Int) => List(x)) // error // error

0 comments on commit 3597543

Please sign in to comment.