Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,16 @@ object Checking {
if sym.isNoValue && !ctx.isJava then
report.error(JavaSymbolIsNotAValue(sym), tree.srcPos)

/** Check that `tree` refers to a value, unless `tree` is selected or applied
* (singleton types x.type don't count as selections).
*/
def checkValue(tree: Tree, proto: Type)(using Context): tree.type =
tree match
case tree: RefTree
if tree.name.isTermName
&& !proto.isInstanceOf[SelectionProto]
&& !proto.isInstanceOf[FunOrPolyProto] =>
checkValue(tree)
case tree: RefTree if tree.name.isTermName =>
proto match
case _: SelectionProto if proto ne SingletonTypeProto => // no value check
case _: FunOrPolyProto => // no value check
case _ => checkValue(tree)
case _ =>
tree

Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i18109.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package foo {}

package bar {
object Test {
def qux[A] = 123
def main(args: Array[String]): Unit = {
val y = qux[foo.type] // error
val x = valueOf[foo.type] // error
}
}
}