Skip to content

Commit

Permalink
Merge pull request #13830 from SergioDSR/i13769
Browse files Browse the repository at this point in the history
solves dotc assertion error on (non-sensical?) parameter type. #13769
  • Loading branch information
smarter authored Oct 27, 2021
2 parents 5eef0c6 + 0f5029d commit 0eb7e61
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 0eb7e61

Please sign in to comment.