Skip to content

Commit

Permalink
Allow for unqualified apply as context functions
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jun 10, 2022
1 parent cec9aa3 commit 55f07c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3981,7 +3981,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer

/** Convert constructor proxy reference to a new expression */
def newExpr =
val Select(qual, nme.apply) = tree: @unchecked
val qual = (tree: @unchecked) match
case Select(qual, nme.apply) => qual
case Ident(nme.apply) => This(tree.symbol.owner.asClass).withSpan(tree.span)
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
val tpt = qual match
case Ident(name) =>
Expand Down
4 changes: 4 additions & 0 deletions tests/new/i15414.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class C()
object C {
val c = apply()
}

0 comments on commit 55f07c4

Please sign in to comment.