diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-31 14:40:06 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 09:33:12 +0200 |
commit | 24f40bc76493410f2688c8a74028ecb1db7306bf (patch) | |
tree | 1376406c3114b52c62d3350805c6c6c8323ecd7e /compiler/src/dotty/tools/dotc/transform | |
parent | a3f6ca5a5cd96e17d2f9a9c5187f45ff02b5dd61 (diff) | |
download | dotty-24f40bc76493410f2688c8a74028ecb1db7306bf.tar.gz dotty-24f40bc76493410f2688c8a74028ecb1db7306bf.tar.bz2 dotty-24f40bc76493410f2688c8a74028ecb1db7306bf.zip |
Make outer select names semantic
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform')
4 files changed, 12 insertions, 9 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index a6e643992..c302aa61b 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -11,6 +11,7 @@ import core.Decorators._ import core.StdNames.nme import core.Names._ import core.NameOps._ +import core.NameKinds.OuterSelectName import ast.Trees._ import SymUtils._ import dotty.tools.dotc.ast.tpd @@ -61,10 +62,11 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf /** Convert a selection of the form `qual.C_<OUTER>` to an outer path from `qual` to `C` */ override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo) = - if (tree.name.isOuterSelect) - outer.path(start = tree.qualifier, count = tree.name.outerSelectHops) - .ensureConforms(tree.tpe) - else tree + tree.name match { + case OuterSelectName(_, nhops) => + outer.path(start = tree.qualifier, count = nhops).ensureConforms(tree.tpe) + case _ => tree + } /** First, add outer accessors if a class does not have them yet and it references an outer this. * If the class has outer accessors, implement them. diff --git a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala index 37f978f11..a3cf71ef2 100644 --- a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -20,7 +20,7 @@ import scala.collection.mutable import DenotTransformers._ import typer.Checking import NameOps._ -import NameKinds.AvoidClashName +import NameKinds.{AvoidClashName, OuterSelectName} import StdNames._ @@ -77,7 +77,7 @@ class FirstTransform extends MiniPhaseTransform with InfoTransformer with Annota override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { tree match { - case Select(qual, name) if !name.isOuterSelect && tree.symbol.exists => + case Select(qual, name) if !name.is(OuterSelectName) && tree.symbol.exists => assert(qual.tpe derivesFrom tree.symbol.owner, i"non member selection of ${tree.symbol.showLocated} from ${qual.tpe} in $tree") case _: TypeTree => case _: Import | _: NamedArg | _: TypTree => diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala index 583834fb3..80d9091fb 100644 --- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -11,7 +11,7 @@ import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTrans import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._ import util.Positions._ import Decorators._ -import NameKinds.{ProtectedAccessorName, ProtectedSetterName} +import NameKinds.{ProtectedAccessorName, ProtectedSetterName, OuterSelectName} import Symbols._, TypeUtils._ /** This class performs the following functions: @@ -152,7 +152,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) { */ private def ensureProtectedAccessOK(sel: Select, targs: List[Tree])(implicit ctx: Context) = { val sym = sel.symbol - if (sym.isTerm && !sel.name.isOuterSelect && needsProtectedAccessor(sym, sel.pos)) { + if (sym.isTerm && !sel.name.is(OuterSelectName) && needsProtectedAccessor(sym, sel.pos)) { ctx.debuglog("Adding protected accessor for " + sel) protectedAccessorCall(sel, targs) } else sel diff --git a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index 9bb00e683..44c26ecd9 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -13,6 +13,7 @@ import core.Flags._ import core.Constants._ import core.StdNames._ import core.NameOps._ +import core.NameKinds.OuterSelectName import core.Decorators._ import core.TypeErasure.isErasedType import core.Phases.Phase @@ -339,7 +340,7 @@ class TreeChecker extends Phase with SymTransformer { val sym = tree.symbol if (!tpe.isInstanceOf[WithFixedSym] && sym.exists && !sym.is(Private) && - !tree.name.isOuterSelect // outer selects have effectively fixed symbols + !tree.name.is(OuterSelectName) // outer selects have effectively fixed symbols ) { val qualTpe = tree.qualifier.typeOpt val member = |