diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 15 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/ReificationSupport.scala | 1 | ||||
-rw-r--r-- | test/files/neg/t6455.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6455.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t7239.scala | 38 |
6 files changed, 5 insertions, 56 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 674e0051b4..72133f31fa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1479,7 +1479,7 @@ abstract class RefChecks extends Transform { private def transformApply(tree: Apply): Tree = tree match { case Apply( - Select(qual, nme.filter | nme.withFilter), + Select(qual, nme.withFilter), List(Function( List(ValDef(_, pname, tpt, _)), Match(_, CaseDef(pat1, _, _) :: _)))) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 41ee89b43b..d412b5ef33 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4837,16 +4837,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } } - // temporarily use `filter` as an alternative for `withFilter` - def tryWithFilterAndFilter(tree: Select, qual: Tree): Tree = { - def warn(sym: Symbol) = context.deprecationWarning(tree.pos, sym, s"`withFilter' method does not yet exist on ${qual.tpe.widen}, using `filter' method instead", "2.11.0") - silent(_ => typedSelect(tree, qual, nme.withFilter)) orElse { _ => - silent(_ => typed1(Select(qual, nme.filter) setPos tree.pos, mode, pt)) match { - case SilentResultValue(res) => warn(res.symbol) ; res - case SilentTypeError(err) => WithFilterError(tree, err) - } - } - } def typedSelectOrSuperCall(tree: Select) = tree match { case Select(qual @ Super(_, _), nme.CONSTRUCTOR) => // the qualifier type of a supercall constructor is its first parent class @@ -4860,10 +4850,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper else UnstableTreeError(qualTyped) ) - val tree1 = name match { - case nme.withFilter if !settings.future => tryWithFilterAndFilter(tree, qualStableOrError) - case _ => typedSelect(tree, qualStableOrError, name) - } + val tree1 = typedSelect(tree, qualStableOrError, name) def sym = tree1.symbol if (tree.isInstanceOf[PostfixSelect]) checkFeature(tree.pos, PostfixOpsFeature, name.decode) diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala index 33ca78b439..026438e421 100644 --- a/src/reflect/scala/reflect/internal/ReificationSupport.scala +++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala @@ -726,6 +726,7 @@ trait ReificationSupport { self: SymbolTable => } // match call to either withFilter or filter + // TODO: now that we no longer rewrite `filter` to `withFilter`, maybe this extractor should only look for `withFilter`? protected object FilterCall { def unapply(tree: Tree): Option[(Tree,Tree)] = tree match { case Apply(Select(obj, nme.withFilter | nme.filter), arg :: Nil) => diff --git a/test/files/neg/t6455.flags b/test/files/neg/t6455.flags deleted file mode 100644 index 112fc720a0..0000000000 --- a/test/files/neg/t6455.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture
\ No newline at end of file diff --git a/test/files/neg/t6455.scala b/test/files/neg/t6455.scala index ebbb37f1cd..22e4c30fdd 100644 --- a/test/files/neg/t6455.scala +++ b/test/files/neg/t6455.scala @@ -1,6 +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 + // should not compile because we no longer rewrite withFilter => filter O.withFilter(f => true) -}
\ No newline at end of file +} diff --git a/test/files/pos/t7239.scala b/test/files/pos/t7239.scala deleted file mode 100644 index 16e9d00f17..0000000000 --- a/test/files/pos/t7239.scala +++ /dev/null @@ -1,38 +0,0 @@ -object Test { - def BrokenMethod(): HasFilter[(Int, String)] = ??? - - trait HasFilter[B] { - def filter(p: B => Boolean) = ??? - } - - trait HasWithFilter { - def withFilter = ??? - } - - object addWithFilter { - trait NoImplicit - implicit def enrich(v: Any) - (implicit F0: NoImplicit): HasWithFilter = ??? - } - - BrokenMethod().withFilter(_ => true) // okay - BrokenMethod().filter(_ => true) // okay - - locally { - import addWithFilter._ - BrokenMethod().withFilter((_: (Int, String)) => true) // okay - } - - locally { - import addWithFilter._ - // adaptToMemberWithArgs sets the type of the tree `x` - // to ErrorType (while in silent mode, so the error is not - // reported. Later, when the fallback from `withFilter` - // to `filter` is attempted, the closure is taken to have - // have the type `<error> => Boolean`, which conforms to - // `(B => Boolean)`. Only later during pickling does the - // defensive check for erroneous types in the tree pick up - // the problem. - BrokenMethod().withFilter(x => true) // erroneous or inaccessible type. - } -} |