diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 10 | ||||
-rw-r--r-- | test/files/neg/t9041.check | 4 | ||||
-rw-r--r-- | test/files/neg/t9041.scala | 17 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 6e5f61db1a..e4255e5333 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -825,6 +825,16 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } orElse { _ => val resetTree = resetAttrs(original) + resetTree match { + case treeInfo.Applied(fun, targs, args) => + if (fun.symbol != null && fun.symbol.isError) + // SI-9041 Without this, we leak error symbols past the typer! + // because the fallback typechecking notices the error-symbol, + // refuses to re-attempt typechecking, and presumes that someone + // else was responsible for issuing the related type error! + fun.setSymbol(NoSymbol) + case _ => + } debuglog(s"fallback on implicits: ${tree}/$resetTree") val tree1 = typed(resetTree, mode) // Q: `typed` already calls `pluginsTyped` and `adapt`. the only difference here is that diff --git a/test/files/neg/t9041.check b/test/files/neg/t9041.check new file mode 100644 index 0000000000..669e9434e0 --- /dev/null +++ b/test/files/neg/t9041.check @@ -0,0 +1,4 @@ +t9041.scala:11: error: could not find implicit value for parameter cellSetter: CellSetter[scala.math.BigDecimal] + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + ^ +one error found diff --git a/test/files/neg/t9041.scala b/test/files/neg/t9041.scala new file mode 100644 index 0000000000..2bdef0d3ae --- /dev/null +++ b/test/files/neg/t9041.scala @@ -0,0 +1,17 @@ +// False negative test, requires overloading in Cell. + +trait Cell { def setCellValue(i: Int) = () ; def setCellValue(d: Double) = () } + +trait Nope { + def f = { + trait CellSetter[A] { + def setCell(cell: Cell, data: A): Unit + } + implicit val bigDecimalCellSetter = new CellSetter[math.BigDecimal]() { + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + } + implicit class RichCell(cell: Cell) { + def setCellValue[A](data: A)(implicit cellSetter: CellSetter[A]) = cellSetter.setCell(cell, data) + } + } +} |