diff options
author | Paul Phillips <paulp@improving.org> | 2013-09-27 12:28:55 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-10-02 08:59:55 -0700 |
commit | aced32d05c97651534f468bc9a475ea5f6ae75b8 (patch) | |
tree | fda8b628ae8501a8df945aeb7f558f259c857e62 /src/compiler/scala/tools/nsc/typechecker | |
parent | 45183d8d28ff082d9186018b707f9fecb466f14f (diff) | |
download | scala-aced32d05c97651534f468bc9a475ea5f6ae75b8.tar.gz scala-aced32d05c97651534f468bc9a475ea5f6ae75b8.tar.bz2 scala-aced32d05c97651534f468bc9a475ea5f6ae75b8.zip |
Removing unused code.
Most of this was revealed via -Xlint with a flag which assumes
closed world. I can't see how to check the assumes-closed-world
code in without it being an ordeal. I'll leave it in a branch in
case anyone wants to finish the long slog to the merge.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
9 files changed, 4 insertions, 69 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index dc8c26c926..92f95e282b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -442,9 +442,6 @@ trait ContextErrors { def ArrayConstantsTypeMismatchError(tree: Tree, pt: Type) = NormalTypeError(tree, "found array constant, expected argument of type " + pt) - def UnexpectedTreeAnnotation(tree: Tree) = - NormalTypeError(tree, "unexpected tree in annotation: "+ tree) - def AnnotationTypeMismatchError(tree: Tree, expected: Type, found: Type) = NormalTypeError(tree, "expected annotation of type " + expected + ", found " + found) diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index b3675d6a82..4765c301dd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -854,9 +854,6 @@ object MacrosStats { class Fingerprint private[Fingerprint](val value: Int) extends AnyVal { def paramPos = { assert(isTag, this); value } def isTag = value >= 0 - def isOther = this == Other - def isExpr = this == LiftedTyped - def isTree = this == LiftedUntyped override def toString = this match { case Other => "Other" case LiftedTyped => "Expr" diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 12e8b0a3f9..599969598e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1675,13 +1675,6 @@ trait Namers extends MethodSynthesis { } } - @deprecated("Use underlyingSymbol instead", "2.10.0") - def underlying(member: Symbol): Symbol = underlyingSymbol(member) - @deprecated("Use `companionSymbolOf` instead", "2.10.0") - def companionClassOf(module: Symbol, ctx: Context): Symbol = companionSymbolOf(module, ctx) - @deprecated("Use `companionSymbolOf` instead", "2.10.0") - def companionModuleOf(clazz: Symbol, ctx: Context): Symbol = companionSymbolOf(clazz, ctx) - /** The companion class or companion module of `original`. * Calling .companionModule does not work for classes defined inside methods. * diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala index 38a3f18bf8..ee2a207efd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala @@ -159,19 +159,12 @@ trait PatternTypers { } } - def newExtractorShape(tree: Tree): ExtractorShape = tree match { - case Apply(fun, args) => ExtractorShape(fun, args) - case UnApply(fun, args) => ExtractorShape(fun, args) - } def newExtractorShape(fun: Tree, args: List[Tree]): ExtractorShape = ExtractorShape(fun, args) case class CaseClassInfo(clazz: Symbol, classType: Type) { def constructor = clazz.primaryConstructor def constructorType = classType.prefix memberType clazz memberType constructor - def paramTypes = constructorType.paramTypes def accessors = clazz.caseFieldAccessors - def accessorTypes = accessors map (m => (classType memberType m).finalResultType) - // def inverted = MethodType(clazz :: Nil, tupleType(accessorTypes)) } object NoCaseClassInfo extends CaseClassInfo(NoSymbol, NoType) { override def toString = "NoCaseClassInfo" @@ -186,10 +179,7 @@ trait PatternTypers { def paramType = firstParamType(unapplyType) def rawGet = if (isBool) UnitTpe else typeOfMemberNamedGetOrSelf(resultType) def rawTypes = if (isBool) Nil else typesOfSelectorsOrSelf(rawGet) - def rawArity = rawTypes.size def isBool = resultType =:= BooleanTpe // aka "Tuple0" or "Option[Unit]" - def isNothing = rawGet =:= NothingTpe - def isCase = method.isCase } object NoUnapplyMethodInfo extends UnapplyMethodInfo(NoSymbol, NoType) { @@ -213,7 +203,6 @@ trait PatternTypers { def unapplyMethod = exInfo.method def unapplyType = exInfo.unapplyType def unapplyParamType = exInfo.paramType - def caseClass = ccInfo.clazz def enclClass = symbol.enclClass // TODO - merge these. The difference between these two methods is that expectedPatternTypes diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala index bbd51b5564..54c665fe56 100644 --- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala +++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala @@ -62,15 +62,6 @@ trait StdAttachments { } } - /** Checks whether there is any tree resulting from a macro expansion and associated with the current tree. - */ - object ExpandedIntoTree { - def unapply(tree: Tree): Option[Tree] = tree.attachments.get[MacroExpansionAttachment] match { - case Some(MacroExpansionAttachment(_, tree: Tree)) => Some(tree) - case _ => None - } - } - /** When present, suppresses macro expansion for the host. * This is occasionally necessary, e.g. to prohibit eta-expansion of macros. * diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 61295b5abd..f0252251f7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -157,7 +157,7 @@ trait SyntheticMethods extends ast.TreeDSL { Ident(eqmeth.firstParam), List( CaseDef(Typed(Ident(nme.WILDCARD), TypeTree(clazz.tpe)), EmptyTree, TRUE), - CaseDef(WILD.empty, EmptyTree, FALSE) + CaseDef(Ident(nme.WILDCARD), EmptyTree, FALSE) ) ) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index e44c83aa56..1b726c37b9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -162,7 +162,6 @@ abstract class TreeCheckers extends Analyzer { lazy val tpeOfTree = mutable.HashMap[Tree, Type]() private lazy val reportedAlready = mutable.HashSet[(Tree, Symbol)]() - def posstr(t: Tree): String = if (t eq null) "" else posstr(t.pos) def posstr(p: Position): String = ( if (p eq null) "" else { try p.source.path + ":" + p.line @@ -264,9 +263,7 @@ abstract class TreeCheckers extends Analyzer { checkedTyped(tree, mode, pt) ) private def checkedTyped(tree: Tree, mode: Mode, pt: Type): Tree = { - def tpe = try tree.tpe finally tree.clearType() - val recorded = tpeOfTree.getOrElseUpdate(tree, tpe) - val typed = wrap(tree)(super.typed(tree, mode, pt)) + val typed = wrap(tree)(super.typed(tree, mode, pt)) if (tree ne typed) treesDiffer(tree, typed) @@ -365,8 +362,6 @@ abstract class TreeCheckers extends Analyzer { def typeOf(t: Tree): Type = if (t.tpe eq null) NoType else t.tpe def infoOf(t: Tree): Type = symbolOf(t).info def referencesInType(tp: Type) = tp collect { case TypeRef(_, sym, _) => sym } - def referencesInTree(t: Tree) = referencesInType(typeOf(t)) ++ referencesInType(infoOf(t)) - def symbolRefsInTree(t: Tree) = t collect { case t: RefTree => symbolOf(t) } // Accessors are known to steal the type of the underlying field without cloning existential symbols at the new owner. // This happens in Namer#accessorTypeCompleter. We just look the other way here. if (symbolOf(tree).isAccessor) @@ -381,10 +376,6 @@ abstract class TreeCheckers extends Analyzer { sym.isTypeParameter || sym.isLocal ) - val direct = tree match { - case _: RefTree => treeSym - case _ => NoSymbol - } val referencedSymbols = (treeSym :: referencesInType(treeInfo)).distinct filter (sym => isEligible(sym) && !isOk(sym)) def mk[T](what: String, x: T, str: T => String = (x: T) => "" + x): ((Any, String)) = x -> s"%10s %-20s %s".format(what, classString(x), truncate(str(x), 80).trim) @@ -415,13 +406,7 @@ abstract class TreeCheckers extends Analyzer { } referencedSymbols foreach (sym => - if (reportedAlready((tree, sym))) { - def what = tree match { - case tt: TypeTree => s"TypeTree(${tt.tpe})" - case _ => tree.shortClass + "(" + tree.symbol.nameString + ")" - } - } - else { + if (!reportedAlready((tree, sym))) { errorFn("\n" + mkErrorMsg(sym)) reportedAlready += ((tree, sym)) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala index afe6875218..cb1f1f4568 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeStrings.scala @@ -112,11 +112,6 @@ trait StructuredTypeStrings extends DestructureTypes { override def emptyTypeName = "Nil" override def typeName = "List" } - class TypeScope(nodes: List[TypeNode]) extends TypeProduct(nodes) { - override def grouping = BlockGrouping - override def typeName = "Scope" - override def emptyTypeName = "EmptyScope" - } object TypeEmpty extends TypeNode { override def grouping = NoGrouping diff --git a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala index f44fd412fd..550fd4e68d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala @@ -9,14 +9,12 @@ package typechecker import scala.collection.mutable import scala.reflect.internal.util.{ BatchSourceFile, Statistics } import mutable.ListBuffer -import symtab.Flags._ import Mode._ trait TypersTracking { self: Analyzer => import global._ - import definitions._ import typeDebug._ // To enable decent error messages when the typer crashes. @@ -53,7 +51,6 @@ trait TypersTracking { object typingStack { val out = new java.io.PrintWriter(System.err, true) - def println(msg: Any) = out println "" + msg // TODO - account for colors so the color of a multiline string // doesn't infect the connector lines @@ -72,12 +69,7 @@ trait TypersTracking { if (s1.length < 60 || settings.debug.value) s1 else s1.take(57) + "..." } - private val nextId = { var x = 1 ; () => try x finally x += 1 } - private class Frame(val tree: Tree) { - val stamp = System.nanoTime - val id = nextId() - } - private object NoFrame extends Frame(EmptyTree) { } + private class Frame(val tree: Tree) { } private def greenType(tp: Type): String = tpe_s(tp, inGreen) private def greenType(tree: Tree): String = tree match { case null => "[exception]" @@ -108,7 +100,6 @@ trait TypersTracking { showPush(tree, NOmode, WildcardType, context) } def showPush(tree: Tree, mode: Mode, pt: Type, context: Context) { - val alreadyTyped = tree.tpe ne null def tree_s = truncAndOneLine(ptTree(tree)) def pt_s = if (pt.isWildcard || context.inTypeConstructorAllowed) "" else s": pt=$pt" def all_s = List(tree_s, pt_s, mode, fullSiteString(context)) filterNot (_ == "") mkString " " @@ -143,9 +134,6 @@ trait TypersTracking { def nextTyped(tree: Tree, mode: Mode, pt: Type, context: Context)(body: => Tree): Tree = nextTypedInternal(tree, showPush(tree, mode, pt, context))(body) - def nextTyped(tree: Tree, context: Context)(body: => Tree): Tree = - nextTypedInternal(tree, showPush(tree, context))(body) - def nextTypedInternal(tree: Tree, pushFn: => Unit)(body: => Tree): Tree = ( if (noPrintTyping(tree)) body |