File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -748,13 +748,16 @@ object Checking {
748748 if sym.isNoValue && ! ctx.isJava then
749749 report.error(JavaSymbolIsNotAValue (sym), tree.srcPos)
750750
751+ /** Check that `tree` refers to a value, unless `tree` is selected or applied
752+ * (singleton types x.type don't count as selections).
753+ */
751754 def checkValue (tree : Tree , proto : Type )(using Context ): tree.type =
752755 tree match
753- case tree : RefTree
754- if tree.name.isTermName
755- && ! proto. isInstanceOf [ SelectionProto ]
756- && ! proto. isInstanceOf [ FunOrPolyProto ] =>
757- checkValue(tree)
756+ case tree : RefTree if tree.name.isTermName =>
757+ proto match
758+ case _ : SelectionProto if proto ne SingletonTypeProto => // no value check
759+ case _ : FunOrPolyProto => // no value check
760+ case _ => checkValue(tree)
758761 case _ =>
759762 tree
760763
Original file line number Diff line number Diff line change 1+ package foo {}
2+
3+ package bar {
4+ object Test {
5+ def qux [A ] = 123
6+ def main (args : Array [String ]): Unit = {
7+ val y = qux[foo.type ] // error
8+ val x = valueOf[foo.type ] // error
9+ }
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments