diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-11 23:37:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-11 23:37:15 +0000 |
commit | bbeecf2b7811971371a1312a376f66a95d4db2ba (patch) | |
tree | d096f2a4b928793c9a6d44fc823a040fd6e6203f /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 1e166a7a826bb086d9bcb77ae973fa343277f84f (diff) | |
download | scala-bbeecf2b7811971371a1312a376f66a95d4db2ba.tar.gz scala-bbeecf2b7811971371a1312a376f66a95d4db2ba.tar.bz2 scala-bbeecf2b7811971371a1312a376f66a95d4db2ba.zip |
The non-intrusive bits of my hopefully pending ...
The non-intrusive bits of my hopefully pending "use the static type of
the scrutinee to rule out some type/extractor patterns" patch. Includes
a cleanup of the (still inadequate) type-parameter-ignoring match test
which had been interfering with martin's digestion.
Also: implicit search is disabled when typing a pattern, because the
matcher never invokes implicits to satisfy a pattern. At worst maybe
we'll get a performance bump. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 879dadcbed..aeb3762afc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4206,20 +4206,13 @@ trait Typers { self: Analyzer => /** Types a pattern with prototype <code>pt</code> */ def typedPattern(tree: Tree, pt: Type): Tree = { - // The commented out code stems from investigation into whether - // "abc" match { case Seq('a', 'b', 'c') => true } - // can be ruled out statically. At present this is a runtime - // error both because there is an implicit from String to Seq - // (even though such implicits are not used by the matcher) and - // because the typer is fine with concluding that "abc" might - // be of type "String with Seq[T]" and thus eligible for a call - // to unapplySeq. - // - // val savedImplicitsEnabled = context.implicitsEnabled - // context.implicitsEnabled = false - // try - typed(tree, PATTERNmode, pt) - // finally context.implicitsEnabled = savedImplicitsEnabled + // We disable implicits because otherwise some constructs will + // type check which should not. The pattern matcher does not + // perform implicit conversions in an attempt to consummate a match. + val savedImplicitsEnabled = context.implicitsEnabled + context.implicitsEnabled = false + try typed(tree, PATTERNmode, pt) + finally context.implicitsEnabled = savedImplicitsEnabled } /** Types a (fully parameterized) type tree */ |