diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-19 21:58:45 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-24 22:49:51 -0800 |
commit | 62560b16765bdfe74212446e8ccb50dbeb06d457 (patch) | |
tree | 0e07878e253f70ef78a189b80e1f404950fe0bd2 | |
parent | 2ead4d6aa3de402f269252190aaa9075a990e098 (diff) | |
download | scala-62560b16765bdfe74212446e8ccb50dbeb06d457.tar.gz scala-62560b16765bdfe74212446e8ccb50dbeb06d457.tar.bz2 scala-62560b16765bdfe74212446e8ccb50dbeb06d457.zip |
SI-6455 under -Xfuture, don't rewrite .withFilter to .filter
This has been deprecated for two major releases now,
but `filter`'s still preferred over `withFilter` in the wild.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t6455.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6455.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6455.scala | 6 | ||||
-rw-r--r-- | test/files/scalacheck/quasiquotes/TypecheckedProps.scala | 2 |
5 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 8721450dc9..b64e3a351e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4714,7 +4714,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper UnstableTreeError(qualTyped) ) val tree1 = name match { - case nme.withFilter => tryWithFilterAndFilter(tree, qualStableOrError) + case nme.withFilter if !settings.future => tryWithFilterAndFilter(tree, qualStableOrError) case _ => typedSelect(tree, qualStableOrError, name) } def sym = tree1.symbol diff --git a/test/files/neg/t6455.check b/test/files/neg/t6455.check new file mode 100644 index 0000000000..8f2aad0b9e --- /dev/null +++ b/test/files/neg/t6455.check @@ -0,0 +1,4 @@ +t6455.scala:5: error: value withFilter is not a member of object O + O.withFilter(f => true) + ^ +one error found diff --git a/test/files/neg/t6455.flags b/test/files/neg/t6455.flags new file mode 100644 index 0000000000..112fc720a0 --- /dev/null +++ b/test/files/neg/t6455.flags @@ -0,0 +1 @@ +-Xfuture
\ No newline at end of file diff --git a/test/files/neg/t6455.scala b/test/files/neg/t6455.scala new file mode 100644 index 0000000000..ebbb37f1cd --- /dev/null +++ b/test/files/neg/t6455.scala @@ -0,0 +1,6 @@ +object O { def filter(p: Int => Boolean): O.type = this } + +class Test { + // should not compile because we no longer rewrite withFilter => filter under -Xfuture + O.withFilter(f => true) +}
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index 8b1cb6cc49..0aca41ac66 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -44,7 +44,7 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") { val enums = fq"foo <- new Foo" :: fq"if foo != null" :: Nil val body = q"foo" val q"$_; for(..$enums1) yield $body1" = typecheck(q""" - class Foo { def map(f: Any => Any) = this; def filter(cond: Any => Boolean) = this } + class Foo { def map(f: Any => Any) = this; def withFilter(cond: Any => Boolean) = this } for(..$enums) yield $body """) assert(enums1 ≈ enums) |