aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Checking.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-09 13:35:33 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-09 13:39:22 +0100
commitaf337f0667fa559411f9a96355b9ceeabf95b232 (patch)
tree25d3e9e7c55b9adcce5e744108f0ff219bb7b874 /src/dotty/tools/dotc/typer/Checking.scala
parentd827b0180b05e7461856f668c3c4ca0ea6ed5d62 (diff)
downloaddotty-af337f0667fa559411f9a96355b9ceeabf95b232.tar.gz
dotty-af337f0667fa559411f9a96355b9ceeabf95b232.tar.bz2
dotty-af337f0667fa559411f9a96355b9ceeabf95b232.zip
Fix of #50 - volatile
Volatile checking needs to take all intersections into account; previously these could be discarded through needsChecking. Plus several refactorings and additions. 1) Module vals now have Final and Stable flags set 2) All logic around isVolatile is now in TypeOps; some of it was moved from Types. 3) Added stability checking to Select and SelectFromType typings. Todo: We should find a better name for isVolatile. Maybe define the negation instead under the name "isRealizable"?.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Checking.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Checking.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala
index 25e6a7aa7..ecf3eb9bc 100644
--- a/src/dotty/tools/dotc/typer/Checking.scala
+++ b/src/dotty/tools/dotc/typer/Checking.scala
@@ -23,6 +23,7 @@ trait NoChecking {
def checkValue(tree: Tree, proto: Type)(implicit ctx: Context): tree.type = tree
def checkBounds(args: List[tpd.Tree], poly: PolyType, pos: Position)(implicit ctx: Context): Unit = ()
def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit = ()
+ def checkLegalPrefix(tp: Type, pos: Position)(implicit ctx: Context): Unit = ()
def checkClassTypeWithStablePrefix(tp: Type, pos: Position, traitReq: Boolean)(implicit ctx: Context): Type = tp
def checkImplicitTptNonEmpty(defTree: untpd.ValOrDefDef)(implicit ctx: Context): Unit = ()
def checkImplicitParamsNotSingletons(vparamss: List[List[ValDef]])(implicit ctx: Context): Unit = ()
@@ -53,13 +54,17 @@ trait Checking extends NoChecking {
if (!(bounds.lo <:< arg.tpe)) notConforms("lower", bounds.lo)
}
- /** Check that type `tp` is stable.
+ /** Check that type `tp` is stable. */
+ override def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit =
+ if (!tp.isStable) ctx.error(i"$tp is not stable", pos)
+
+ /** Check that type `tp` is a legal prefix for '#'.
* @return The type itself
*/
- override def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit =
- if (!tp.isStable) ctx.error(i"Prefix of type ${tp.widenIfUnstable} is not stable", pos)
+ override def checkLegalPrefix(tp: Type, pos: Position)(implicit ctx: Context): Unit =
+ if (!tp.isLegalPrefix) ctx.error(i"$tp is not a valid prefix for '#'", pos)
- /** Check that `tp` is a class type with a stable prefix. Also, if `isFirst` is
+ /** Check that `tp` is a class type with a stable prefix. Also, if `isFirst` is
* false check that `tp` is a trait.
* @return `tp` itself if it is a class or trait ref, ObjectClass.typeRef if not.
*/