summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-07-16 15:02:24 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-07-16 15:30:48 +1000
commit585cf5a2397210eb37cb01bf5a29771beef21412 (patch)
treecefa9afc3a03bd8058e63d62399fd2af8316e4c1 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentd99785b7c3b99bbb053eb3337262c88548ab50d2 (diff)
downloadscala-585cf5a2397210eb37cb01bf5a29771beef21412.tar.gz
scala-585cf5a2397210eb37cb01bf5a29771beef21412.tar.bz2
scala-585cf5a2397210eb37cb01bf5a29771beef21412.zip
SI-9401 Avoid SOE with array + missing classtag
The implicit classtags required by the Array constructor are not expressed in the type signature of its constructor, and instead are summoned by a special case in the typechecker. This special case entails replacing the `new Array` tree with `implicitly[T].newArray(size)`, handled in `ArrayInstantiation`. This tree is recursively typechecked. However, if the implicit materialization/search fails, an error is issued to the current reporter and the original tree is marked with an error type. As above, this is recursively typechecked. In the normal course of affairs, the recursive typecheck of the erroneous tree would be a noop (the tree already has a type!). However, if we are both in silent mode (in which errors are buffered) and in retyping mode (in which the typer clears the type and symbols of trees), we were getting into an cycle. In the enclosed test, retyping mode was trying to recover from: Resetting.this.gencastarray_=(new Array[T](0).<ERROR>) By inserting a suitable a view: implicitly[Resetting => { def gencastarray_=(AT)}]( Resetting.this ).gencastarray_=(new Array[T](0)) Where AT is the type found by retypechecking the argument. It is during the argument retypechecking that we fell into cycle. Crazily enough, in 2.11.0, the ensuing `StackOverflowError` was being caught and treated as a failure. We would then back out of the retyping mode, and issue the error from the the very first attempt at the implicit search. This fragile state of affairs was disrupted by a refactoring to the error reporting system in 725c5c9, after which the SOE crashed the compiler. This commit avoids recursively typechecking error typed trees.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b5129af9ec..fd1a6f293f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4577,7 +4577,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
typed1(atPos(tree.pos)(Block(stats, Apply(expr, args) setPos tree.pos.makeTransparent)), mode, pt)
case Apply(fun, args) =>
normalTypedApply(tree, fun, args) match {
- case ArrayInstantiation(tree1) => typed(tree1, mode, pt)
+ case ArrayInstantiation(tree1) => if (tree1.isErrorTyped) tree1 else typed(tree1, mode, pt)
case Apply(Select(fun, nme.apply), _) if treeInfo.isSuperConstrCall(fun) => TooManyArgumentListsForConstructor(tree) //SI-5696
case tree1 => tree1
}