diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-06 04:32:39 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-06 04:32:39 +0000 |
commit | 311b7de861bd2f4137e3503483177a1588cfdd12 (patch) | |
tree | 7b784b842cdf4a791a056e045eb4aa208c1e755a /src | |
parent | 14cd653295b5ed3f10b82193a9fb6da0867e31d6 (diff) | |
download | scala-311b7de861bd2f4137e3503483177a1588cfdd12.tar.gz scala-311b7de861bd2f4137e3503483177a1588cfdd12.tar.bz2 scala-311b7de861bd2f4137e3503483177a1588cfdd12.zip |
Finally figured out what was going on with a ce...
Finally figured out what was going on with a certain class of
exhaustiveness checking bugs. Hey moors, you can put away your pins,
puppets, and magic sauces. Closes #3098, no review.
Diffstat (limited to 'src')
3 files changed, 18 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala index c5c57938ca..d75670fd38 100644 --- a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala +++ b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala @@ -172,10 +172,15 @@ trait MatrixAdditions extends ast.TreeDSL { val collected = toCollect map { case (pv, i) => // okay, now reset the flag pv.sym resetFlag MUTABLE - // have to filter out children which cannot match: see ticket #3683 for an example - val kids = pv.tpe.typeSymbol.sealedDescendants filter (_.tpe matchesPattern pv.tpe) - i -> kids + i -> ( + pv.tpe.typeSymbol.sealedDescendants.toList sortBy (_.sealedSortName) + // symbols which are both sealed and abstract need not be covered themselves, because + // all of their children must be and they cannot otherwise be created. + filterNot (x => x.isSealed && x.isAbstractClass && !isValueClass(x)) + // have to filter out children which cannot match: see ticket #3683 for an example + filter (_.tpe matchesPattern pv.tpe) + ) } val folded = diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 281c8af4d5..d1f5cbf4d2 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -1530,19 +1530,14 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable => abort("sourceFile_= inapplicable for " + this) } - /** If this is a sealed class, its known direct subclasses. Otherwise Set.empty */ - def children: List[Symbol] = Nil - - /** Recursively finds all sealed descendants and returns a sorted list. - * Includes this symbol unless it is abstract, but as value classes are - * marked abstract so they can't be instantiated, they are special cased. + /** If this is a sealed class, its known direct subclasses. + * Otherwise, the empty set. */ - def sealedDescendants: List[Symbol] = { - val kids = children flatMap (_.sealedDescendants) - val all = if (isAbstractClass && !isValueClass(this)) kids else this :: kids + def children: Set[Symbol] = Set() - all.distinct sortBy (_.sealedSortName) - } + /** Recursively assemble all children of this symbol. + */ + def sealedDescendants: Set[Symbol] = children.flatMap(_.sealedDescendants) + this // ToString ------------------------------------------------------------------- @@ -2093,7 +2088,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable => if (isModuleClass) companionModule else NoSymbol private var childSet: Set[Symbol] = Set() - override def children: List[Symbol] = childSet.toList sortBy (_.sealedSortName) + override def children = childSet override def addChild(sym: Symbol) { childSet = childSet + sym } incCounter(classSymbolCount) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 862e37ec2b..131c935a8a 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -144,15 +144,15 @@ abstract class Pickler extends SubComponent { putType(sym.typeOfThis); putSymbol(sym.alias) if (!sym.children.isEmpty) { - val (locals, globals) = sym.children.toList.partition(_.isLocalClass) + val (locals, globals) = sym.children partition (_.isLocalClass) val children = if (locals.isEmpty) globals else { val localChildDummy = sym.newClass(sym.pos, tpnme.LOCAL_CHILD) localChildDummy.setInfo(ClassInfoType(List(sym.tpe), EmptyScope, localChildDummy)) - localChildDummy :: globals + globals + localChildDummy } - putChildren(sym, children sortBy (_.sealedSortName)) + putChildren(sym, children.toList sortBy (_.sealedSortName)) } for (annot <- staticAnnotations(sym.annotations.reverse)) putAnnotation(sym, annot) |