summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-07-24 15:24:06 +1000
committerJason Zaugg <jzaugg@gmail.com>2013-07-24 15:29:42 +1000
commit91214dad841ee04e01d064da276e3fe46edf9e31 (patch)
tree10c433cdab7f5f99a99505117bebd40e440fdec2
parent56b7c0f8fa6c1037905867aec88520476dbd3baa (diff)
downloadscala-91214dad841ee04e01d064da276e3fe46edf9e31.tar.gz
scala-91214dad841ee04e01d064da276e3fe46edf9e31.tar.bz2
scala-91214dad841ee04e01d064da276e3fe46edf9e31.zip
SI-7689 Fix typing regression with default arguments
Regressed in e28c3edda4. That commit encoded upper/lower bounds of Any/Nothing as EmptyTree, which were triggering the .isEmpty check in Namers#TypeTreeSubstitutor and resulting in the default getter having TypeTree() as the return type. This resulted in a "missing parmameter type" error. This commit tightens up that condition to only consider empty TypeTrees (those wrapping null or NoType.)
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala3
-rw-r--r--test/files/pos/t7689.scala7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 1282cfb416..e8a1e8e85a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -35,7 +35,8 @@ trait Namers extends MethodSynthesis {
}
def apply(tree: Tree) = {
val r = transform(tree)
- if (r.exists(_.isEmpty)) TypeTree()
+ if (r exists { case tt: TypeTree => tt.isEmpty case _ => false })
+ TypeTree()
else r
}
}
diff --git a/test/files/pos/t7689.scala b/test/files/pos/t7689.scala
new file mode 100644
index 0000000000..022e7ab7a0
--- /dev/null
+++ b/test/files/pos/t7689.scala
@@ -0,0 +1,7 @@
+object A {
+ // The default getter must have an explicit return type (List[_] => Int)
+ // This wasn't happening since e28c3edda4. That commit encoded upper/lower
+ // bounds of Any/Nothing as EmptyTree, which were triggering an .isEmpty
+ // check in Namers#TypeTreeSubstitutor
+ def x(f: List[_] => Int = _ => 3) = 9
+}