File tree 2 files changed +19
-5
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -758,13 +758,16 @@ object Checking {
758
758
if sym.isNoValue && ! ctx.isJava then
759
759
report.error(JavaSymbolIsNotAValue (sym), tree.srcPos)
760
760
761
+ /** Check that `tree` refers to a value, unless `tree` is selected or applied
762
+ * (singleton types x.type don't count as selections).
763
+ */
761
764
def checkValue (tree : Tree , proto : Type )(using Context ): tree.type =
762
765
tree match
763
- case tree : RefTree
764
- if tree.name.isTermName
765
- && ! proto. isInstanceOf [ SelectionProto ]
766
- && ! proto. isInstanceOf [ FunOrPolyProto ] =>
767
- checkValue(tree)
766
+ case tree : RefTree if tree.name.isTermName =>
767
+ proto match
768
+ case _ : SelectionProto if proto ne SingletonTypeProto => // no value check
769
+ case _ : FunOrPolyProto => // no value check
770
+ case _ => checkValue(tree)
768
771
case _ =>
769
772
tree
770
773
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