summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-09-08 13:48:23 +0000
committerMartin Odersky <odersky@gmail.com>2006-09-08 13:48:23 +0000
commitd0798c6b85e63fe4d9b3a2937f4f49f9c54ba9ea (patch)
treefd6ffb3cb56ab251d2047c0c4a36bd40aac25377
parent3d449d9f663913369ae0a0345d85cd755000f029 (diff)
downloadscala-d0798c6b85e63fe4d9b3a2937f4f49f9c54ba9ea.tar.gz
scala-d0798c6b85e63fe4d9b3a2937f4f49f9c54ba9ea.tar.bz2
scala-d0798c6b85e63fe4d9b3a2937f4f49f9c54ba9ea.zip
rebuild checkers (not there yet)
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala78
2 files changed, 41 insertions, 39 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 1787be64ac..e94edfecef 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -188,7 +188,7 @@ trait SyntheticMethods requires Analyzer {
}
}
- ts += tagMethod
+ if (clazz.info.nonPrivateDecl(nme.tag) == NoSymbol) ts += tagMethod
if (clazz.isModuleClass) {
if (!hasImplementation(nme.toString_)) ts += moduleToStringMethod
} else {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 93ff010ce4..64e367bb33 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -804,8 +804,8 @@ trait Typers requires Analyzer {
error(fun.pos, "called constructor must precede calling constructor");
case _ =>
}
- def typedSuperCall(tree: Tree): Tree = {
- val result = typed(tree, EXPRmode | SCCmode, UnitClass.tpe)
+ def typedSuperCall(tree: Tree, pt: Type): Tree = {
+ val result = typed(tree, EXPRmode | SCCmode, pt)
checkPrecedes(result)
result
}
@@ -833,15 +833,16 @@ trait Typers requires Analyzer {
meth.owner.isRefinementClass))
error(ddef.pos, "constructor definition not allowed here "+meth.owner);//debug
val result = ddef.rhs match {
- case Block(stat :: stats, expr) =>
- val stat1 = typedSuperCall(stat)
- newTyper(context.makeConstructorSuffixContext).typed(
- copy.Block(ddef.rhs, stats, expr), UnitClass.tpe) match {
- case block1 @ Block(stats1, expr1) =>
- copy.Block(block1, stat1 :: stats1, expr1)
- }
+ case block @ Block(stat :: stats, expr) =>
+ // the following makes sure not to copy the tree if no subtrees have changed
+ val stat1 = typedSuperCall(stat, WildcardType)
+ val block1 = newTyper(context.makeConstructorSuffixContext)
+ .typedBlock(Block(stats, expr) setPos block.pos, EXPRmode, UnitClass.tpe)
+ val stats1 = if ((stat eq stat1) && (stats eq block1.stats)) block.stats
+ else stat1 :: block1.stats
+ copy.Block(block, stats1, block1.expr) setType block1.tpe
case _ =>
- typedSuperCall(ddef.rhs)
+ typedSuperCall(ddef.rhs, UnitClass.tpe)
}
if (meth.isPrimaryConstructor && !phase.erasedTypes && reporter.errors == 0)
computeParamAliases(meth.owner, vparamss1, result)
@@ -1009,37 +1010,39 @@ trait Typers requires Analyzer {
def typedStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
val inBlock = exprOwner == context.owner
- val result =
- List.mapConserve(stats) { stat =>
- if (context.owner.isRefinementClass && !treeInfo.isDeclaration(stat))
- errorTree(stat, "only declarations allowed here")
- stat match {
- case imp @ Import(_, _) =>
- context = context.makeNewImport(imp)
- stat.symbol.initialize
- EmptyTree
- case _ =>
- val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this
- else newTyper(context.make(stat, exprOwner))
- localTyper.typed(stat)
- }
+ def typedStat(stat: Tree): Tree = {
+ if (context.owner.isRefinementClass && !treeInfo.isDeclaration(stat))
+ errorTree(stat, "only declarations allowed here")
+ stat match {
+ case imp @ Import(_, _) =>
+ context = context.makeNewImport(imp)
+ stat.symbol.initialize
+ EmptyTree
+ case _ =>
+ val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this
+ else newTyper(context.make(stat, exprOwner))
+ localTyper.typed(stat)
}
- val scope = if (inBlock) context.scope else context.owner.info.decls;
- var e = scope.elems;
- while (e != null && e.owner == scope) {
- if (!e.sym.hasFlag(LOCAL)) {
- var e1 = scope.lookupNextEntry(e);
- while (e1 != null && e1.owner == scope) {
- if (!e1.sym.hasFlag(LOCAL) &&
- (e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe)))
- if (!e.sym.isErroneous && !e1.sym.isErroneous)
- error(e.sym.pos, ""+e1.sym+" is defined twice");
- e1 = scope.lookupNextEntry(e1);
+ }
+ def checkNoDoubleDefs(stats: List[Tree]) = {
+ val scope = if (inBlock) context.scope else context.owner.info.decls;
+ var e = scope.elems;
+ while (e != null && e.owner == scope) {
+ if (!e.sym.hasFlag(LOCAL)) {
+ var e1 = scope.lookupNextEntry(e);
+ while (e1 != null && e1.owner == scope) {
+ if (!e1.sym.hasFlag(LOCAL) &&
+ (e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe)))
+ if (!e.sym.isErroneous && !e1.sym.isErroneous)
+ error(e.sym.pos, ""+e1.sym+" is defined twice");
+ e1 = scope.lookupNextEntry(e1);
+ }
}
+ e = e.next
}
- e = e.next
+ stats
}
- result
+ checkNoDoubleDefs(List.mapConserve(stats)(typedStat))
}
def typedArg(arg: Tree, mode: int, pt: Type): Tree = {
@@ -1640,7 +1643,6 @@ trait Typers requires Analyzer {
case ErrorType =>
expr1
case _ =>
-// Console.println(expr1.tpe.isInstanceOf[PolyType])
errorTree(expr1, "`&' must be applied to method type; cannot be applied to " + expr1.tpe)
}