Skip to content

Handle creator applications in nested companion objects #11422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2021
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
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3696,8 +3696,12 @@ class Typer extends Namer
val Select(qual, nme.apply) = tree; @unchecked
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
val tpt = qual match
case Ident(name) => cpy.Ident(qual)(name.toTypeName)
case Select(pre, name) => cpy.Select(qual)(pre, name.toTypeName)
case Ident(name) =>
cpy.Ident(qual)(name.toTypeName)
case Select(pre, name) =>
cpy.Select(qual)(pre, name.toTypeName)
case qual: This if qual.symbol.is(ModuleClass) =>
cpy.Ident(qual)(qual.symbol.name.sourceModuleName.toTypeName)
typed(
untpd.Select(
untpd.New(untpd.TypedSplice(tpt.withType(tycon))),
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i11420.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo {
class Bar(i: Int)

object Bar {
def zero = Bar(0)
}
}