Skip to content

Commit 55f07c4

Browse files
committed
Allow for unqualified apply as context functions
Fixes #15414
1 parent cec9aa3 commit 55f07c4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3981,7 +3981,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
39813981

39823982
/** Convert constructor proxy reference to a new expression */
39833983
def newExpr =
3984-
val Select(qual, nme.apply) = tree: @unchecked
3984+
val qual = (tree: @unchecked) match
3985+
case Select(qual, nme.apply) => qual
3986+
case Ident(nme.apply) => This(tree.symbol.owner.asClass).withSpan(tree.span)
39853987
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
39863988
val tpt = qual match
39873989
case Ident(name) =>

tests/new/i15414.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class C()
2+
object C {
3+
val c = apply()
4+
}

0 commit comments

Comments
 (0)