~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* NSC -- new Scala compiler
2
 
 * Copyright 2005-2011 LAMP/EPFL
 
2
 * Copyright 2005-2013 LAMP/EPFL
3
3
 * Author: Paul Phillips
4
4
 */
5
5
 
20
20
  import CODE._
21
21
  import Debug._
22
22
  import treeInfo._
23
 
  import definitions.{ isValueClass }
 
23
  import definitions.{ isPrimitiveValueClass }
24
24
 
25
25
  /** The Squeezer, responsible for all the squeezing.
26
26
   */
131
131
 
132
132
      import Flags.{ MUTABLE, ABSTRACT, SEALED }
133
133
 
134
 
      private case class Combo(index: Int, sym: Symbol) {
135
 
        val isBaseClass = sym.tpe.baseClasses.toSet
136
 
 
137
 
        // is this combination covered by the given pattern?
138
 
        def isCovered(p: Pattern) = {
139
 
          def coversSym = isBaseClass(decodedEqualsType(p.tpe).typeSymbol)
140
 
 
141
 
          cond(p.tree) {
142
 
            case _: UnApply | _: ArrayValue => true
143
 
            case x                          => p.isDefault || coversSym
144
 
          }
145
 
        }
146
 
      }
 
134
      private case class Combo(index: Int, sym: Symbol) { }
147
135
 
148
136
      /* True if the patterns in 'row' cover the given type symbol combination, and has no guard. */
149
137
      private def rowCoversCombo(row: Row, combos: List[Combo]) =
150
 
        row.guard.isEmpty && (combos forall (c => c isCovered row.pats(c.index)))
 
138
        row.guard.isEmpty && combos.forall(c => row.pats(c.index) covers c.sym)
151
139
 
152
140
      private def requiresExhaustive(sym: Symbol) = {
153
141
         (sym.isMutable) &&                 // indicates that have not yet checked exhaustivity
154
142
        !(sym hasFlag NO_EXHAUSTIVE) &&     // indicates @unchecked
155
143
         (sym.tpe.typeSymbol.isSealed) &&
156
 
        !isValueClass(sym.tpe.typeSymbol)   // make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte
 
144
        !isPrimitiveValueClass(sym.tpe.typeSymbol)   // make sure it's not a primitive, else (5: Byte) match { case 5 => ... } sees no Byte
157
145
      }
158
146
 
159
147
      private lazy val inexhaustives: List[List[Combo]] = {
162
150
        val collected = toCollect map { case (pv, i) =>
163
151
          // okay, now reset the flag
164
152
          pv.sym resetFlag MUTABLE
165
 
          // have to filter out children which cannot match: see ticket #3683 for an example
166
 
          val kids = pv.tpe.typeSymbol.sealedDescendants filter (_.tpe matchesPattern pv.tpe)
167
153
 
168
 
          i -> kids
 
154
          i -> (
 
155
            pv.tpe.typeSymbol.sealedDescendants.toList sortBy (_.sealedSortName)
 
156
            // symbols which are both sealed and abstract need not be covered themselves, because
 
157
            // all of their children must be and they cannot otherwise be created.
 
158
            filterNot (x => x.isSealed && x.isAbstractClass && !isPrimitiveValueClass(x))
 
159
            // have to filter out children which cannot match: see ticket #3683 for an example
 
160
            filter (_.tpe matchesPattern pv.tpe)
 
161
          )
169
162
        }
170
163
 
171
164
        val folded =