From fada1ef6b315326ac0329d9e78951cfc95ad0eb0 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 16 May 2013 14:58:09 -0700 Subject: SI-6815 untangle isStable and hasVolatileType `Symbol::isStable` is now independent of `Symbol::hasVolatileType`, so that we can allow stable identifiers that are volatile in ident patterns. This split is validated by SI-6815 and the old logic in RefChecks, which seems to assume this independence, and thus I don't think ever worked: ``` if (member.isStable && !otherTp.isVolatile) { if (memberTp.isVolatile) overrideError("has a volatile type; cannot override a member with non-volatile type") ``` Introduces `admitsTypeSelection` and `isStableIdentifierPattern` in treeInfo, and uses them instead of duplicating that logic all over the place. Since volatility only matters in the context of type application, `isStableIdentifierPattern` is used to check patterns (resulting in `==` checks) and imports. --- src/interactive/scala/tools/nsc/interactive/Global.scala | 6 +++--- src/interactive/scala/tools/nsc/interactive/Picklers.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/interactive') diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index c9b4603d74..6a833ab864 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -925,14 +925,14 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } def stabilizedType(tree: Tree): Type = tree match { - case Ident(_) if tree.symbol.isStable => + case Ident(_) if treeInfo.admitsTypeSelection(tree) => singleType(NoPrefix, tree.symbol) - case Select(qual, _) if qual.tpe != null && tree.symbol.isStable => + case Select(qual, _) if treeInfo.admitsTypeSelection(tree) => singleType(qual.tpe, tree.symbol) case Import(expr, selectors) => tree.symbol.info match { case analyzer.ImportType(expr) => expr match { - case s@Select(qual, name) => singleType(qual.tpe, s.symbol) + case s@Select(qual, name) if treeInfo.admitsTypeSelection(expr) => singleType(qual.tpe, s.symbol) case i : Ident => i.tpe case _ => tree.tpe } diff --git a/src/interactive/scala/tools/nsc/interactive/Picklers.scala b/src/interactive/scala/tools/nsc/interactive/Picklers.scala index b184afd0f5..900a06333d 100644 --- a/src/interactive/scala/tools/nsc/interactive/Picklers.scala +++ b/src/interactive/scala/tools/nsc/interactive/Picklers.scala @@ -96,7 +96,7 @@ trait Picklers { self: Global => if (!sym.isRoot) { ownerNames(sym.owner, buf) buf += (if (sym.isModuleClass) sym.sourceModule else sym).name - if (!sym.isType && !sym.isStable) { + if (!sym.isType && !sym.isStable) { // TODO: what's the reasoning behind this condition!? val sym1 = sym.owner.info.decl(sym.name) if (sym1.isOverloaded) { val index = sym1.alternatives.indexOf(sym) -- cgit v1.2.3