diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-13 23:09:39 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-13 23:19:57 -0800 |
commit | 2b731911e97a281e324060099631e2374b2144ec (patch) | |
tree | b8cba303e6855f879f6cce0704c208ec162fd140 | |
parent | eb8556ca663de9bf77514eab6e63f0a2f7599413 (diff) | |
download | scala-2b731911e97a281e324060099631e2374b2144ec.tar.gz scala-2b731911e97a281e324060099631e2374b2144ec.tar.bz2 scala-2b731911e97a281e324060099631e2374b2144ec.zip |
Fix for SI-5452.
Why is calling the error function not enough to register the error, why
does "setError(tree)" have to be called as well? That was the cause of
this particular stackoverflow. In ContextErrors I see lots of methods
which call setError and lots more which do not, and frankly it's all
pretty terrifying.
There is zero documentation attached to setError. Maybe there's an
explanation somewhere I'm not seeing.
Review by @hubertp.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 4 | ||||
-rw-r--r-- | test/files/neg/t5452.check | 6 | ||||
-rw-r--r-- | test/files/neg/t5452.scala | 29 |
3 files changed, 38 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 6ee09d064f..466b5125a8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -714,9 +714,11 @@ trait ContextErrors { setError(tree) } - def NoBestMethodAlternativeError(tree: Tree, argtpes: List[Type], pt: Type) = + def NoBestMethodAlternativeError(tree: Tree, argtpes: List[Type], pt: Type) = { issueNormalTypeError(tree, applyErrorMsg(tree, " cannot be applied to ", argtpes, pt)) + setError(tree) + } def AmbiguousMethodAlternativeError(tree: Tree, pre: Type, best: Symbol, firstCompeting: Symbol, argtpes: List[Type], pt: Type) = { diff --git a/test/files/neg/t5452.check b/test/files/neg/t5452.check new file mode 100644 index 0000000000..baf544499b --- /dev/null +++ b/test/files/neg/t5452.check @@ -0,0 +1,6 @@ +t5452.scala:28: error: overloaded method value apply with alternatives: + + cannot be applied to (Queryable[CoffeesTable]) + Queryable[CoffeesTable]( q.treeFilter(null) ) + ^ +one error found diff --git a/test/files/neg/t5452.scala b/test/files/neg/t5452.scala new file mode 100644 index 0000000000..1032db7a4b --- /dev/null +++ b/test/files/neg/t5452.scala @@ -0,0 +1,29 @@ +// /scala/trac/5452/a.scala +// Mon Feb 13 22:52:36 PST 2012 + +// import scala.reflect.mirror._ + +trait Tree + +object Bip { + def ??? = sys.error("") +} +import Bip._ + +case class Queryable[T]() { + def treeFilter( t:Tree ) : Queryable[T] = ??? +} + +object Queryable { + def apply[T:Manifest] = ??? + def apply[T:Manifest]( t:Tree ) = ??? +} + +trait CoffeesTable{ + def sales : Int +} + +object Test extends App{ + val q = new Queryable[CoffeesTable] + Queryable[CoffeesTable]( q.treeFilter(null) ) +} |