Skip to content

Commit

Permalink
Fix registering Ident not containing a symbol
Browse files Browse the repository at this point in the history
- Register their type
- Fix scala#16680
- Update test suit
  • Loading branch information
PaulCoral authored and little-inferno committed Jan 25, 2023
1 parent 9195e42 commit abffc80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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]

0 comments on commit abffc80

Please sign in to comment.