diff options
author | Martin Odersky <odersky@gmail.com> | 2007-06-09 13:03:55 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-06-09 13:03:55 +0000 |
commit | 8414ebada9615aac0e8b436e7bdbeee5986ccaa3 (patch) | |
tree | f62c23aec3d9f49446aebd76963667be8468f48d /src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | |
parent | 6ad83dae6960a78d6014c6fcfee1889a322ad5d7 (diff) | |
download | scala-8414ebada9615aac0e8b436e7bdbeee5986ccaa3.tar.gz scala-8414ebada9615aac0e8b436e7bdbeee5986ccaa3.tar.bz2 scala-8414ebada9615aac0e8b436e7bdbeee5986ccaa3.zip |
added existential types
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 8fc956715b..fb32cdcec1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -38,10 +38,11 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT class SuperAccTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { private var validCurrentOwner = true private var accDefs: List[(Symbol, ListBuffer[Tree])] = List() + private val typer = analyzer.newTyper(analyzer.rootContext(unit)) private def accDefBuf(clazz: Symbol) = accDefs.dropWhile(_._1 != clazz).head._2 - +/* private def transformArgs(args: List[Tree], formals: List[Type]) = { if (!formals.isEmpty && formals.last.symbol == definitions.ByNameParamClass) ((args take (formals.length - 1) map transform) ::: @@ -49,6 +50,24 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT else args map transform } +*/ + private def transformArgs(args: List[Tree], formals: List[Type]) = + List.map2(args, formals){ (arg, formal) => + if (formal.symbol == definitions.ByNameParamClass) + withInvalidOwner { checkPackedConforms(transform(arg), formal.typeArgs.head) } + else transform(arg) + } ::: + (args drop formals.length map transform) + + private def checkPackedConforms(tree: Tree, pt: Type): Tree = { + if (tree.tpe exists (_.symbol.isExistentialSkolem)) { + val packed = typer.typed(Pack(tree) setPos tree.pos) + println("packed: "+packed+":"+packed.tpe+", pt = "+pt) + if (!(packed.tpe <:< pt)) + typer.infer.typeError(tree.pos, packed.tpe, pt) + } + tree + } override def transform(tree: Tree): Tree = tree match { case ClassDef(_, _, _, _) => @@ -301,7 +320,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT if (host.thisSym != host) { if (host.thisSym.tpe.symbol.hasFlag(JAVA) || currentOwner.enclClass.isTrait) unit.error(pos, "Implementation restriction: " + currentOwner.enclClass + " accesses protected " - + sym + " from 'required' " + host.thisSym.tpe) + + sym + " from self type " + host.thisSym.tpe) false } else res } else res |