Skip to content
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

Fix #16680 by registering Ident not containing a symbol #16689

Merged
merged 1 commit into from
Jan 16, 2023
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
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ class CheckUnused extends MiniPhase:
ctx

override def prepareForIdent(tree: tpd.Ident)(using Context): Context =
_key.unusedDataApply(_.registerUsed(tree.symbol, Some(tree.name)))
if tree.symbol.exists then
_key.unusedDataApply(_.registerUsed(tree.symbol, Some(tree.name)))
else if tree.hasType then
_key.unusedDataApply(_.registerUsed(tree.tpe.classSymbol, Some(tree.name)))
else
ctx

override def prepareForSelect(tree: tpd.Select)(using Context): Context =
_key.unusedDataApply(_.registerUsed(tree.symbol, Some(tree.name)))
Expand Down
12 changes: 11 additions & 1 deletion tests/neg-custom-args/fatal-warnings/i15503a.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,14 @@ package foo.testing.imports.precedence:
package foo.test.enums:
enum A: // OK
case B extends A // OK
case C extends A // OK
case C extends A // OK

package foo.test.typeapply.hklamdba.i16680:
package foo:
trait IO[A]

package bar:
import foo.IO // OK

def f[F[_]]: String = "hello"
def go = f[IO]