Skip to content

Drill through type lambda for tree symbol #23699

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dotty.tools.dotc.ast.tpd.*
import dotty.tools.dotc.ast.untpd, untpd.ImportSelector
import dotty.tools.dotc.config.ScalaSettings
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Decorators.*
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.Names.{Name, SimpleName, DerivedName, TermName, termName}
import dotty.tools.dotc.core.NameOps.{isAnonymousFunctionName, isReplWrapperName, setterName}
Expand Down Expand Up @@ -80,7 +81,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
&& tree.qualifier.tpe.match
case ThisType(_) | SuperType(_, _) => false
case qualtpe => qualtpe.isStable
if tree.srcPos.isSynthetic && tree.symbol == defn.TypeTest_unapply then
val sym = tree.symbol.orElse(tree.typeOpt.resultType.typeSymbol)
if tree.srcPos.isSynthetic && sym == defn.TypeTest_unapply then
tree.qualifier.tpe.underlying.finalResultType match
case AppliedType(tycon, args) =>
val res =
Expand All @@ -90,11 +92,11 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
val target = res.dealias.typeSymbol
resolveUsage(target, target.name, res.importPrefix.skipPackageObject) // case _: T =>
case _ =>
else if isImportable || name.exists(_ != tree.symbol.name) then
else if isImportable || name.exists(_ != sym.name) then
if !ignoreTree(tree) then
resolveUsage(tree.symbol, name, tree.qualifier.tpe)
resolveUsage(sym, name, tree.qualifier.tpe)
else if !ignoreTree(tree) then
refUsage(tree.symbol)
refUsage(sym)
refInfos.isAssignment = false
tree

Expand Down
13 changes: 13 additions & 0 deletions tests/warn/i23694.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//> using options -Wunused:privates

trait A:
def get: Any = new A.C

object A:
private class C[T]

trait B:
def get: Any = new B.C

object B:
private class C
Loading