Skip to content

Commit 009c57d

Browse files
committed
Removed code from the typechecker.
Removing code from this neighborhood is more difficult than elsewhere, making it all the more important that it be done.
1 parent e5b0508 commit 009c57d

12 files changed

+60
-251
lines changed

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ trait Contexts { self: Analyzer =>
219219
current
220220
}
221221

222-
def logError(err: AbsTypeError) = buffer += err
223-
224222
def withImplicitsEnabled[T](op: => T): T = {
225223
val saved = implicitsEnabled
226224
implicitsEnabled = true
@@ -312,15 +310,6 @@ trait Contexts { self: Analyzer =>
312310
c
313311
}
314312

315-
// TODO: remove? Doesn't seem to be used
316-
def make(unit: CompilationUnit): Context = {
317-
val c = make(unit, EmptyTree, owner, scope, imports)
318-
c.setReportErrors()
319-
c.implicitsEnabled = true
320-
c.macrosEnabled = true
321-
c
322-
}
323-
324313
def makeNewImport(sym: Symbol): Context =
325314
makeNewImport(gen.mkWildcardImport(sym))
326315

@@ -489,17 +478,6 @@ trait Contexts { self: Analyzer =>
489478
sub.isNonBottomSubClass(base) ||
490479
sub.isModuleClass && sub.linkedClassOfClass.isNonBottomSubClass(base)
491480

492-
/** Return closest enclosing context that defines a superclass of `clazz`, or a
493-
* companion module of a superclass of `clazz`, or NoContext if none exists */
494-
def enclosingSuperClassContext(clazz: Symbol): Context = {
495-
var c = this.enclClass
496-
while (c != NoContext &&
497-
!clazz.isNonBottomSubClass(c.owner) &&
498-
!(c.owner.isModuleClass && clazz.isNonBottomSubClass(c.owner.companionClass)))
499-
c = c.outer.enclClass
500-
c
501-
}
502-
503481
/** Return the closest enclosing context that defines a subclass of `clazz`
504482
* or a companion object thereof, or `NoContext` if no such context exists.
505483
*/

src/compiler/scala/tools/nsc/typechecker/DestructureTypes.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ trait DestructureTypes {
6464
},
6565
tree.productPrefix
6666
)
67-
def wrapSymbol(label: String, sym: Symbol): Node = {
68-
if (sym eq NoSymbol) wrapEmpty
69-
else atom(label, sym)
70-
}
71-
def wrapInfo(sym: Symbol) = sym.info match {
72-
case TypeBounds(lo, hi) => typeBounds(lo, hi)
73-
case PolyType(tparams, restpe) => polyFunction(tparams, restpe)
74-
case _ => wrapEmpty
75-
}
7667
def wrapSymbolInfo(sym: Symbol): Node = {
7768
if ((sym eq NoSymbol) || openSymbols(sym)) wrapEmpty
7869
else {
@@ -95,7 +86,6 @@ trait DestructureTypes {
9586
def constant(label: String, const: Constant): Node = atom(label, const)
9687

9788
def scope(decls: Scope): Node = node("decls", scopeMemberList(decls.toList))
98-
def const[T](named: (String, T)): Node = constant(named._1, Constant(named._2))
9989

10090
def resultType(restpe: Type): Node = this("resultType", restpe)
10191
def typeParams(tps: List[Symbol]): Node = node("typeParams", symbolList(tps))

src/compiler/scala/tools/nsc/typechecker/Duplicators.scala

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ abstract class Duplicators extends Analyzer {
1919
import global._
2020
import definitions.{ AnyRefClass, AnyValClass }
2121

22-
def retyped(context: Context, tree: Tree): Tree = {
23-
resetClassOwners
24-
(newBodyDuplicator(context)).typed(tree)
25-
}
26-
2722
/** Retype the given tree in the given context. Use this method when retyping
2823
* a method in a different class. The typer will replace references to the this of
2924
* the old class with the new class, and map symbols through the given 'env'. The
@@ -42,9 +37,6 @@ abstract class Duplicators extends Analyzer {
4237

4338
protected def newBodyDuplicator(context: Context) = new BodyDuplicator(context)
4439

45-
def retypedMethod(context: Context, tree: Tree, oldThis: Symbol, newThis: Symbol): Tree =
46-
(newBodyDuplicator(context)).retypedMethod(tree.asInstanceOf[DefDef], oldThis, newThis)
47-
4840
/** Return the special typer for duplicate method bodies. */
4941
override def newTyper(context: Context): Typer =
5042
newBodyDuplicator(context)
@@ -186,20 +178,6 @@ abstract class Duplicators extends Analyzer {
186178
stats.foreach(invalidate(_, owner))
187179
}
188180

189-
def retypedMethod(ddef: DefDef, oldThis: Symbol, newThis: Symbol): Tree = {
190-
oldClassOwner = oldThis
191-
newClassOwner = newThis
192-
invalidateAll(ddef.tparams)
193-
mforeach(ddef.vparamss) { vdef =>
194-
invalidate(vdef)
195-
vdef.tpe = null
196-
}
197-
ddef.symbol = NoSymbol
198-
enterSym(context, ddef)
199-
debuglog("remapping this of " + oldClassOwner + " to " + newClassOwner)
200-
typed(ddef)
201-
}
202-
203181
/** Optionally cast this tree into some other type, if required.
204182
* Unless overridden, just returns the tree.
205183
*/

src/compiler/scala/tools/nsc/typechecker/Implicits.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ trait Implicits {
233233
object HasMember {
234234
private val hasMemberCache = perRunCaches.newMap[Name, Type]()
235235
def apply(name: Name): Type = hasMemberCache.getOrElseUpdate(name, memberWildcardType(name, WildcardType))
236-
def unapply(pt: Type): Option[Name] = pt match {
237-
case RefinedType(List(WildcardType), Scope(sym)) if sym.tpe == WildcardType => Some(sym.name)
238-
case _ => None
239-
}
240236
}
241237

242238
/** An extractor for types of the form ? { name: (? >: argtpe <: Any*)restp }
@@ -1493,9 +1489,7 @@ object ImplicitsStats {
14931489
val subtypeImpl = Statistics.newSubCounter(" of which in implicit", subtypeCount)
14941490
val findMemberImpl = Statistics.newSubCounter(" of which in implicit", findMemberCount)
14951491
val subtypeAppInfos = Statistics.newSubCounter(" of which in app impl", subtypeCount)
1496-
val subtypeImprovCount = Statistics.newSubCounter(" of which in improves", subtypeCount)
14971492
val implicitSearchCount = Statistics.newCounter ("#implicit searches", "typer")
1498-
val triedImplicits = Statistics.newSubCounter(" #tried", implicitSearchCount)
14991493
val plausiblyCompatibleImplicits
15001494
= Statistics.newSubCounter(" #plausibly compatible", implicitSearchCount)
15011495
val matchingImplicits = Statistics.newSubCounter(" #matching", implicitSearchCount)

src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,61 +29,23 @@ trait MethodSynthesis {
2929
if (sym.isLazy) ValDef(sym, body)
3030
else DefDef(sym, body)
3131

32-
def applyTypeInternal(tags: List[TT[_]]): Type = {
33-
val symbols = tags map compilerSymbolFromTag
34-
val container :: args = symbols
35-
val tparams = container.typeConstructor.typeParams
36-
37-
// Conservative at present - if manifests were more usable this could do a lot more.
38-
// [Eugene to Paul] all right, they are now. what do you have in mind?
39-
require(symbols forall (_ ne NoSymbol), "Must find all tags: " + symbols)
40-
require(container.owner.isPackageClass, "Container must be a top-level class in a package: " + container)
41-
require(tparams.size == args.size, "Arguments must match type constructor arity: " + tparams + ", " + args)
42-
43-
appliedType(container, args map (_.tpe): _*)
44-
}
45-
46-
def companionType[T](implicit ct: CT[T]) =
47-
rootMirror.getRequiredModule(ct.runtimeClass.getName).tpe
48-
49-
// Use these like `applyType[List, Int]` or `applyType[Map, Int, String]`
50-
def applyType[CC](implicit t1: TT[CC]): Type =
51-
applyTypeInternal(List(t1))
52-
53-
def applyType[CC[X1], X1](implicit t1: TT[CC[_]], t2: TT[X1]): Type =
54-
applyTypeInternal(List(t1, t2))
55-
56-
def applyType[CC[X1, X2], X1, X2](implicit t1: TT[CC[_,_]], t2: TT[X1], t3: TT[X2]): Type =
57-
applyTypeInternal(List(t1, t2, t3))
58-
59-
def applyType[CC[X1, X2, X3], X1, X2, X3](implicit t1: TT[CC[_,_,_]], t2: TT[X1], t3: TT[X2], t4: TT[X3]): Type =
60-
applyTypeInternal(List(t1, t2, t3, t4))
61-
62-
def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = {
63-
val fnSymbol = compilerSymbolFromTag(t)
64-
val formals = compilerTypeFromTag(t).typeArguments
65-
assert(fnSymbol isSubClass FunctionClass(formals.size - 1), (owner, t))
66-
val params = owner newSyntheticValueParams formals
67-
MethodType(params, formals.last)
68-
}
69-
70-
/** The annotations amongst those found on the original symbol which
71-
* should be propagated to this kind of accessor.
72-
*/
73-
def deriveAnnotations(initial: List[AnnotationInfo], category: Symbol, keepClean: Boolean): List[AnnotationInfo] = {
74-
initial filter { ann =>
75-
// There are no meta-annotation arguments attached to `ann`
76-
if (ann.metaAnnotations.isEmpty) {
77-
// A meta-annotation matching `annotKind` exists on `ann`'s definition.
78-
(ann.defaultTargets contains category) ||
79-
// `ann`'s definition has no meta-annotations, and `keepClean` is true.
80-
(ann.defaultTargets.isEmpty && keepClean)
81-
}
82-
// There are meta-annotation arguments, and one of them matches `annotKind`
83-
else ann.metaAnnotations exists (_ matches category)
32+
/** The annotations amongst those found on the original symbol which
33+
* should be propagated to this kind of accessor.
34+
*/
35+
def deriveAnnotations(initial: List[AnnotationInfo], category: Symbol, keepClean: Boolean): List[AnnotationInfo] = {
36+
initial filter { ann =>
37+
// There are no meta-annotation arguments attached to `ann`
38+
if (ann.metaAnnotations.isEmpty) {
39+
// A meta-annotation matching `annotKind` exists on `ann`'s definition.
40+
(ann.defaultTargets contains category) ||
41+
// `ann`'s definition has no meta-annotations, and `keepClean` is true.
42+
(ann.defaultTargets.isEmpty && keepClean)
8443
}
44+
// There are meta-annotation arguments, and one of them matches `annotKind`
45+
else ann.metaAnnotations exists (_ matches category)
8546
}
86-
}
47+
}
48+
}
8749
import synthesisUtil._
8850

8951
class ClassMethodSynthesis(val clazz: Symbol, localTyper: Typer) {
@@ -118,22 +80,9 @@ trait MethodSynthesis {
11880
finishMethod(clazz.info.decls enter m, f)
11981
}
12082

121-
private def cloneInternal(original: Symbol, f: Symbol => Tree): Tree =
122-
cloneInternal(original, f, original.name)
123-
12483
def clazzMember(name: Name) = clazz.info nonPrivateMember name
12584
def typeInClazz(sym: Symbol) = clazz.thisType memberType sym
12685

127-
/** Function argument takes the newly created method symbol of
128-
* the same type as `name` in clazz, and returns the tree to be
129-
* added to the template.
130-
*/
131-
def overrideMethod(name: Name)(f: Symbol => Tree): Tree =
132-
overrideMethod(clazzMember(name))(f)
133-
134-
def overrideMethod(original: Symbol)(f: Symbol => Tree): Tree =
135-
cloneInternal(original, sym => f(sym setFlag OVERRIDE))
136-
13786
def deriveMethod(original: Symbol, nameFn: Name => Name)(f: Symbol => Tree): Tree =
13887
cloneInternal(original, f, nameFn(original.name))
13988

@@ -311,7 +260,6 @@ trait MethodSynthesis {
311260
// Final methods to make the rest easier to reason about.
312261
final def mods = tree.mods
313262
final def basisSym = tree.symbol
314-
final def derivedFlags: Long = basisSym.flags & flagsMask | flagsExtra
315263
}
316264

317265
trait DerivedFromClassDef extends DerivedFromMemberDef {

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,12 +1388,6 @@ trait Namers extends MethodSynthesis {
13881388
tpe
13891389
}
13901390

1391-
def ensureParent(clazz: Symbol, parent: Symbol) = {
1392-
val info0 = clazz.info
1393-
val info1 = includeParent(info0, parent)
1394-
if (info0 ne info1) clazz setInfo info1
1395-
}
1396-
13971391
class LogTransitions[S](onEnter: S => String, onExit: S => String) {
13981392
val enabled = settings.debug.value
13991393
@inline final def apply[T](entity: S)(body: => T): T = {

src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ trait NamesDefaults { self: Analyzer =>
4141
blockTyper: Typer
4242
) { }
4343

44-
val noApplyInfo = NamedApplyInfo(None, Nil, Nil, null)
45-
4644
def nameOf(arg: Tree) = arg match {
4745
case AssignOrNamedArg(Ident(name), rhs) => Some(name)
4846
case _ => None

0 commit comments

Comments
 (0)