diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala | 10 | ||||
-rw-r--r-- | src/reflect/scala/reflect/api/Symbols.scala | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index a9714acc55..d00e0e6bf6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -2070,6 +2070,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL import scala.collection.mutable.ArrayBuffer type FormulaBuilder = ArrayBuffer[Clause] def formulaBuilder = ArrayBuffer[Clause]() + def formulaBuilderSized(init: Int) = new ArrayBuffer[Clause](init) def addFormula(buff: FormulaBuilder, f: Formula): Unit = buff ++= f def toFormula(buff: FormulaBuilder): Formula = buff @@ -2223,13 +2224,18 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL } private def withLit(res: Model, l: Lit): Model = if (res eq NoModel) NoModel else res + (l.sym -> l.pos) - private def dropUnit(f: Formula, unitLit: Lit) = { + private def dropUnit(f: Formula, unitLit: Lit): Formula = { val negated = -unitLit // drop entire clauses that are trivially true // (i.e., disjunctions that contain the literal we're making true in the returned model), // and simplify clauses by dropping the negation of the literal we're making true // (since False \/ X == X) - f.filterNot(_.contains(unitLit)).map(_ - negated) + val dropped = formulaBuilderSized(f.size) + for { + clause <- f + if !(clause contains unitLit) + } dropped += (clause - negated) + dropped } def findModelFor(f: Formula): Model = { diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index 36f8626389..b53c700701 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -351,8 +351,7 @@ trait Symbols { self: Universe => def asFreeType: FreeTypeSymbol = throw new ScalaReflectionException(s"$this is not a free type") /** @group Constructors */ - def - newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol + def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol /** @group Constructors */ def newModuleAndClassSymbol(name: Name, pos: Position = NoPosition, flags: FlagSet = NoFlags): (ModuleSymbol, ClassSymbol) /** @group Constructors */ |