summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-05-06 12:00:12 +0200
committerJason Zaugg <jzaugg@gmail.com>2012-05-06 12:00:12 +0200
commitf5df207f95087c38b2936429cf793d63f0b68c24 (patch)
tree2ab6327f993d14feac3c8356ed4f8176a42f9666
parent7cac6334d4437ff54c4979799574045501f64135 (diff)
downloadscala-f5df207f95087c38b2936429cf793d63f0b68c24.tar.gz
scala-f5df207f95087c38b2936429cf793d63f0b68c24.tar.bz2
scala-f5df207f95087c38b2936429cf793d63f0b68c24.zip
Don't hop to the first enclosing, non-silent context when typing refinements.
Closes SI-5305. This reverts a few lines of e5cfe47a19, which was a remedy for SI-3614 and SI-3856*. I added a test case for the former, the latter was already tested. Both tests pass after this change, and they do so with the old and new pattern matcher. But does this change still "avoid trees with null types in presentation compiler"? What was the intent of the context hopping in the first place? * Based on this comment: https://issues.scala-lang.org/browse/SI-3614?focusedCommentId=50477&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-50477, which elaborates further than the commit comment of e5cfe47a19.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
-rw-r--r--test/files/neg/t3614.check4
-rw-r--r--test/files/neg/t3614.scala3
-rw-r--r--test/files/pos/t3856.scala1
-rw-r--r--test/files/pos/t5305.scala13
5 files changed, 22 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 5902e480a3..9555280ecd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2498,10 +2498,7 @@ trait Typers extends Modes with Adaptations with Taggings {
namer.enterSyms(stats)
// need to delay rest of typedRefinement to avoid cyclic reference errors
unit.toCheck += { () =>
- // go to next outer context which is not silent, see #3614
- var c = context
- while (c.bufferErrors) c = c.outer
- val stats1 = newTyper(c).typedStats(stats, NoSymbol)
+ val stats1 = typedStats(stats, NoSymbol)
for (stat <- stats1 if stat.isDef) {
val member = stat.symbol
if (!(context.owner.ancestors forall
diff --git a/test/files/neg/t3614.check b/test/files/neg/t3614.check
new file mode 100644
index 0000000000..5fdb5cbf1f
--- /dev/null
+++ b/test/files/neg/t3614.check
@@ -0,0 +1,4 @@
+t3614.scala:2: error: class type required but AnyRef{def a: <?>} found
+ def v = new ({ def a=0 })
+ ^
+one error found \ No newline at end of file
diff --git a/test/files/neg/t3614.scala b/test/files/neg/t3614.scala
new file mode 100644
index 0000000000..5b02cdf2b2
--- /dev/null
+++ b/test/files/neg/t3614.scala
@@ -0,0 +1,3 @@
+object t3614 {
+ def v = new ({ def a=0 })
+} \ No newline at end of file
diff --git a/test/files/pos/t3856.scala b/test/files/pos/t3856.scala
index fd253a56a8..5ea4b84e2c 100644
--- a/test/files/pos/t3856.scala
+++ b/test/files/pos/t3856.scala
@@ -2,6 +2,7 @@ case class C[T](x: T)
case class CS(xs: C[_]*)
+// t3856
object Test {
val x = CS(C(5), C("abc")) match { case CS(C(5), xs @ _*) => xs }
println(x)
diff --git a/test/files/pos/t5305.scala b/test/files/pos/t5305.scala
new file mode 100644
index 0000000000..4c32cd7c6d
--- /dev/null
+++ b/test/files/pos/t5305.scala
@@ -0,0 +1,13 @@
+object t5305 {
+ def in(a: Any) = {}
+
+ object O {
+ type F = Int
+ val v = ""
+ }
+
+ in {
+ import O.{F, v}
+ type x = {type l = (F, v.type)} // not found: type F
+ }
+}