diff options
Diffstat (limited to 'src/dotty/tools/dotc/typer/Checking.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 13 |
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) { |