summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-27 07:57:13 +0000
committerPaul Phillips <paulp@improving.org>2011-01-27 07:57:13 +0000
commit64da770afeb9b383e94228ad7d9f31b8f6e45dee (patch)
tree8c68ed5093ac1e6a1deeb5039130532a991c00e2
parentd884d63800ad09a4f6cd540d419cbede91c08d9c (diff)
downloadscala-64da770afeb9b383e94228ad7d9f31b8f6e45dee.tar.gz
scala-64da770afeb9b383e94228ad7d9f31b8f6e45dee.tar.bz2
scala-64da770afeb9b383e94228ad7d9f31b8f6e45dee.zip
More cleaning up long neglected regions.
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala43
3 files changed, 24 insertions, 30 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index cd46232a21..f89e005858 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -15,12 +15,10 @@ abstract class Erasure extends AddInterfaces
with typechecker.Analyzer
with ast.TreeDSL
{
- import global._ // the global environment
- import definitions._ // standard classes and methods
+ import global._
+ import definitions._
import CODE._
- def typedPos(pos: Position)(tree: Tree) = this.typer.typedPos(pos)(tree)
-
val phaseName: String = "erasure"
def newTransformer(unit: CompilationUnit): Transformer =
@@ -868,7 +866,7 @@ abstract class Erasure extends AddInterfaces
val level = unboundedGenericArrayLevel(arg.tpe)
def isArrayTest(arg: Tree) =
gen.mkRuntimeCall("isArray", List(arg, Literal(Constant(level))))
- typedPos(tree.pos) {
+ global.typer.typedPos(tree.pos) {
if (level == 1) isArrayTest(qual)
else
gen.evalOnce(qual, currentOwner, unit) { qual1 =>
@@ -888,7 +886,7 @@ abstract class Erasure extends AddInterfaces
if (unboundedGenericArrayLevel(qual.tpe.widen) == 1)
// convert calls to apply/update/length on generic arrays to
// calls of ScalaRunTime.array_xxx method calls
- typedPos(tree.pos) { gen.mkRuntimeCall("array_"+name, qual :: args) }
+ global.typer.typedPos(tree.pos) { gen.mkRuntimeCall("array_"+name, qual :: args) }
else
// store exact array erasure in map to be retrieved later when we might
// need to do the cast in adaptMember
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 7213d00f60..929eb0c4f3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -299,7 +299,6 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
MethodType(List(protAcc.newSyntheticValueParam(objType)),
memberType.cloneInfo(protAcc).asSeenFrom(qual.tpe, sym.owner))
}
- if (settings.debug.value) log("accType: " + accType)
var protAcc = clazz.info.decl(accName).suchThat(s => s == NoSymbol || s.tpe =:= accType(s))
if (protAcc == NoSymbol) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index ac259ab7ff..c406f8cca9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -11,22 +11,23 @@ import symtab.Flags._
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
-/** <ul>
- * <li>
- * <code>productArity</code>, <code>element</code> implementations added
- * to case classes
- * </li>
- * <li>
- * <code>equals</code>, <code>hashCode</code> and </code>toString</code>
- * methods are added to case classes, unless they are defined in the
- * class or a baseclass different from <code>java.lang.Object</code>
- * </li>
- * <li>
- * <code>toString</code> method is added to case objects, unless they
- * are defined in the class or a baseclass different from
- * <code>java.lang.Object</code>
- * </li>
- * </ul>
+/** Synthetic method implementations for case classes and case objects.
+ *
+ * Added to all case classes/objects:
+ * def productArity: Int
+ * def productElement(n: Int): Any
+ * def productPrefix: String
+ * def productIterator: Iterator[Any]
+ *
+ * Selectively added to case classes/objects, unless a non-default
+ * implementation already exists:
+ * def equals(other: Any): Boolean
+ * def hashCode(): Int
+ * def canEqual(other: Any): Boolean
+ * def toString(): String
+ *
+ * Special handling:
+ * protected def readResolve(): AnyRef
*/
trait SyntheticMethods extends ast.TreeDSL {
self: Analyzer =>
@@ -34,11 +35,6 @@ trait SyntheticMethods extends ast.TreeDSL {
import global._ // the global environment
import definitions._ // standard classes and methods
- // @S: type hack: by default, we are used from global.analyzer context
- // so this cast won't fail. If we aren't in global.analyzer, we have
- // to override this method anyways.
- protected def typer : Typer = global.typer.asInstanceOf[Typer]
-
/** In general case classes/objects are not given synthetic equals methods if some
* non-AnyRef implementation is inherited. However if you let a case object inherit
* an implementation from a case class, it creates an asymmetric equals with all the
@@ -54,8 +50,9 @@ trait SyntheticMethods extends ast.TreeDSL {
* the opportunity for removal arises, this can be simplified.
*/
def addSyntheticMethods(templ: Template, clazz: Symbol, context: Context): Template = {
- val localContext = if (reporter.hasErrors) context makeSilent false else context
- val localTyper = newTyper(localContext)
+ val localTyper = newTyper(
+ if (reporter.hasErrors) context makeSilent false else context
+ )
def hasOverridingImplementation(meth: Symbol): Boolean = {
val sym = clazz.info nonPrivateMember meth.name