aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Checking.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-06 19:01:42 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-07 11:15:38 +0100
commit6aa88d6dfe501a695183761c2b5f4bd201cdf2c0 (patch)
treebecb8b13bb8d94c9aac7e8e280cde50491ba3efa /src/dotty/tools/dotc/typer/Checking.scala
parentdbd5a4d22b6164b708a87b508d9b9f135b44a3ee (diff)
downloaddotty-6aa88d6dfe501a695183761c2b5f4bd201cdf2c0.tar.gz
dotty-6aa88d6dfe501a695183761c2b5f4bd201cdf2c0.tar.bz2
dotty-6aa88d6dfe501a695183761c2b5f4bd201cdf2c0.zip
Main Typer reorg.
Common code between tpd and Typer has been factored out into class TypeAssigner.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Checking.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Checking.scala13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala
index 5c21584bd..25e6a7aa7 100644
--- a/src/dotty/tools/dotc/typer/Checking.scala
+++ b/src/dotty/tools/dotc/typer/Checking.scala
@@ -5,7 +5,7 @@ package typer
import core._
import ast._
import Contexts._, Types._, Flags._, Denotations._, Names._, StdNames._, NameOps._, Symbols._
-import Trees._
+import Trees._, ProtoTypes._
import Constants._
import Scopes._
import annotation.unchecked
@@ -20,6 +20,7 @@ import collection.mutable
trait NoChecking {
import tpd._
+ 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 checkClassTypeWithStablePrefix(tp: Type, pos: Position, traitReq: Boolean)(implicit ctx: Context): Type = tp
@@ -33,6 +34,16 @@ trait Checking extends NoChecking {
import tpd._
+ /** Check that Java statics and packages can only be used in selections.
+ */
+ override def checkValue(tree: Tree, proto: Type)(implicit ctx: Context): tree.type = {
+ if (!proto.isInstanceOf[SelectionProto]) {
+ val sym = tree.tpe.termSymbol
+ if ((sym is Package) || (sym is JavaModule)) ctx.error(i"$sym is not a value", tree.pos)
+ }
+ tree
+ }
+
/** Check that type arguments `args` conform to corresponding bounds in `poly` */
override def checkBounds(args: List[tpd.Tree], poly: PolyType, pos: Position)(implicit ctx: Context): Unit =
for ((arg, bounds) <- args zip poly.paramBounds) {