summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-26 11:31:40 -0700
committerPaul Phillips <paulp@improving.org>2012-09-26 11:31:40 -0700
commitb716261a7b29bcf613cb4e3b47ca2fb5a97380bb (patch)
tree898dd03c5108f114094f13cd50525857c158cb24
parentcf08f25d598a1d44ed4440b1cc1097a5869aefdd (diff)
downloadscala-b716261a7b29bcf613cb4e3b47ca2fb5a97380bb.tar.gz
scala-b716261a7b29bcf613cb4e3b47ca2fb5a97380bb.tar.bz2
scala-b716261a7b29bcf613cb4e3b47ca2fb5a97380bb.zip
Avoid relying on auto-tupling.
When you call Some(a, b, c) The compiler does eventually figure out that you meant Some((a, b, c)) However the compiler finds this inordinately taxing, and because this auto-tupling is dangerous, -Xlint warns about it. In the interests of being able to hear -Xlint's important points, we write Some((a, b, c)) to give it less to warn about.
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Infrastructure.scala4
-rw-r--r--src/compiler/scala/reflect/reify/utils/Extractors.scala12
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala8
-rw-r--r--src/library/scala/collection/SeqExtractors.scala2
5 files changed, 14 insertions, 14 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
index a8cc61e0f9..7157dbeaa2 100644
--- a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
@@ -23,13 +23,13 @@ trait Infrastructure {
type Run = universe.Run
object Run extends RunExtractor {
- def unapply(run: Run): Option[(CompilationUnit, List[CompilationUnit])] = Some(run.currentUnit, run.units.toList)
+ def unapply(run: Run): Option[(CompilationUnit, List[CompilationUnit])] = Some((run.currentUnit, run.units.toList))
}
type CompilationUnit = universe.CompilationUnit
object CompilationUnit extends CompilationUnitExtractor {
- def unapply(compilationUnit: CompilationUnit): Option[(java.io.File, Array[Char], Tree)] = Some(compilationUnit.source.file.file, compilationUnit.source.content, compilationUnit.body)
+ def unapply(compilationUnit: CompilationUnit): Option[(java.io.File, Array[Char], Tree)] = Some((compilationUnit.source.file.file, compilationUnit.source.content, compilationUnit.body))
}
val currentMacro: Symbol = expandee.symbol
diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala
index bf211ceec4..91cccaee99 100644
--- a/src/compiler/scala/reflect/reify/utils/Extractors.scala
+++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala
@@ -114,7 +114,7 @@ trait Extractors {
case Select(Select(_, tagFlavor), _) => tagFlavor
case Select(_, tagFlavor) => tagFlavor
}
- Some(universe, mirror, SymbolTable(symbolTable1 ++ symbolTable2), rtree, ttpe.tpe, rtpe, tagFlavor == nme.TypeTag)
+ Some((universe, mirror, SymbolTable(symbolTable1 ++ symbolTable2), rtree, ttpe.tpe, rtpe, tagFlavor == nme.TypeTag))
case _ =>
None
}
@@ -139,7 +139,7 @@ trait Extractors {
case Select(Select(_, tagFlavor), _) => tagFlavor
case Select(_, tagFlavor) => tagFlavor
}
- Some(universe, mirror, SymbolTable(symtab), ttpe.tpe, rtpe, tagFlavor == nme.TypeTag)
+ Some((universe, mirror, SymbolTable(symtab), ttpe.tpe, rtpe, tagFlavor == nme.TypeTag))
case _ =>
None
}
@@ -160,9 +160,9 @@ trait Extractors {
object FreeDef {
def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
case FreeTermDef(uref, name, binding, flags, origin) =>
- Some(uref, name, binding, flags, origin)
+ Some((uref, name, binding, flags, origin))
case FreeTypeDef(uref, name, binding, flags, origin) =>
- Some(uref, name, binding, flags, origin)
+ Some((uref, name, binding, flags, origin))
case _ =>
None
}
@@ -207,7 +207,7 @@ trait Extractors {
def unapply(tree: Tree): Option[(Tree, TermName)] = tree match {
case Apply(Select(Select(uref @ Ident(_), build), ident), List(Ident(name: TermName)))
if build == nme.build && ident == nme.Ident && name.startsWith(nme.REIFY_FREE_PREFIX) =>
- Some(uref, name)
+ Some((uref, name))
case _ =>
None
}
@@ -226,7 +226,7 @@ trait Extractors {
Literal(Constant(isClass: Boolean)))))
if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newNestedSymbol == nme.newNestedSymbol &&
uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
- Some(uref1, name, flags, isClass)
+ Some((uref1, name, flags, isClass))
case _ =>
None
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index f9a35ba9a0..bcc37e8b37 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -354,7 +354,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
macroTraceVerbose("tparams are: ")(tparams)
macroTraceVerbose("vparamss are: ")(vparamss)
macroTraceVerbose("retTpe is: ")(retTpe)
- macroTraceVerbose("macroImplSig is: ")(paramss, implRetTpe)
+ macroTraceVerbose("macroImplSig is: ")((paramss, implRetTpe))
}
/** Verifies that the body of a macro def typechecks to a reference to a static public non-overloaded method,
diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
index d0b715d502..c413448b57 100644
--- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
@@ -1589,7 +1589,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
object EqualityCond {
private val uniques = new scala.collection.mutable.HashMap[(Tree, Tree), EqualityCond]
def apply(testedPath: Tree, rhs: Tree): EqualityCond = uniques getOrElseUpdate((testedPath, rhs), new EqualityCond(testedPath, rhs))
- def unapply(c: EqualityCond) = Some(c.testedPath, c.rhs)
+ def unapply(c: EqualityCond) = Some((c.testedPath, c.rhs))
}
class EqualityCond(val testedPath: Tree, val rhs: Tree) extends Cond {
override def toString = testedPath +" == "+ rhs +"#"+ id
@@ -1607,7 +1607,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
object TypeCond {
private val uniques = new scala.collection.mutable.HashMap[(Tree, Type), TypeCond]
def apply(testedPath: Tree, pt: Type): TypeCond = uniques getOrElseUpdate((testedPath, pt), new TypeCond(testedPath, pt))
- def unapply(c: TypeCond) = Some(c.testedPath, c.pt)
+ def unapply(c: TypeCond) = Some((c.testedPath, c.pt))
}
class TypeCond(val testedPath: Tree, val pt: Type) extends Cond {
override def toString = testedPath +" : "+ pt +"#"+ id
@@ -1645,7 +1645,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
def unapply(xtm: ExtractorTreeMaker): Option[(Tree, Symbol)] = xtm match {
case ExtractorTreeMaker(extractor, None, nextBinder) if irrefutableExtractorType(extractor.tpe) =>
- Some(extractor, nextBinder)
+ Some((extractor, nextBinder))
case _ =>
None
}
@@ -2676,7 +2676,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL
case UnitClass =>
Some(List(UnitClass.tpe))
case BooleanClass =>
- Some(List(ConstantType(Constant(true)), ConstantType(Constant(false))))
+ Some((List(ConstantType(Constant(true)), ConstantType(Constant(false)))))
// TODO case _ if tp.isTupleType => // recurse into component types
case modSym: ModuleClassSymbol =>
Some(List(tp))
diff --git a/src/library/scala/collection/SeqExtractors.scala b/src/library/scala/collection/SeqExtractors.scala
index de9ff93521..20ea7f54b7 100644
--- a/src/library/scala/collection/SeqExtractors.scala
+++ b/src/library/scala/collection/SeqExtractors.scala
@@ -11,7 +11,7 @@ object +: {
/** An extractor used to init/last deconstruct sequences. */
object :+ {
/** Splits a sequence into init :+ tail.
- * @return Some(init, tail) if sequence is non-empty. None otherwise.
+ * @return Some((init, tail)) if sequence is non-empty. None otherwise.
*/
def unapply[T,Coll <: SeqLike[T, Coll]](
t: Coll with SeqLike[T, Coll]): Option[(Coll, T)] =