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

-Wunused against lila #22642

Open
som-snytt opened this issue Feb 23, 2025 · 1 comment · May be fixed by #22663
Open

-Wunused against lila #22642

som-snytt opened this issue Feb 23, 2025 · 1 comment · May be fixed by #22663
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug itype:crash

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.7.0-RC1-bin-SNAPSHOT

Minimized code

object Bus:

  type Payload            = Matchable
  type SubscriberFunction = PartialFunction[Payload, Unit]

  def pub[T <: Payload](payload: T)(using wc: WithChannel[T]) =
    publish(payload, wc.channel)

  def sub[T <: Payload: Typeable](f: PartialFunction[T, Unit])(using wc: WithChannel[T]) =
    subscribeFun(wc.channel):
      case x: T => f.applyOrElse(x, _ => ())

Output (click arrow to expand)

[error] java.lang.IndexOutOfBoundsException: 1
[error]         at scala.collection.LinearSeqOps.apply(LinearSeq.scala:131)
[error]         at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:128)
[error]         at scala.collection.immutable.List.apply(List.scala:79)
[error]         at dotty.tools.dotc.transform.CheckUnused.transformSelect(CheckUnused.scala:72)
[error]         at dotty.tools.dotc.transform.CheckUnused.transformSelect(CheckUnused.scala:67)
[error]         at dotty.tools.dotc.transform.MegaPhase.goSelect(MegaPhase.scala:636)

which is

  override def transformSelect(tree: Select)(using Context): tree.type =
    val name = tree.removeAttachment(OriginalName).getOrElse(nme.NO_NAME)
    if tree.span.isSynthetic && tree.symbol == defn.TypeTest_unapply then
      tree.qualifier.tpe.underlying.finalResultType match
      case AppliedType(_, args) => // tycon.typeSymbol == defn.TypeTestClass
        val res = args(1) // T in TypeTest[-S, T]

Maybe because of the alias. The code here assumes there are two type args.

@som-snytt som-snytt added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 23, 2025
@som-snytt som-snytt self-assigned this Feb 23, 2025
@som-snytt
Copy link
Contributor Author

som-snytt commented Feb 23, 2025

This was to test the rewrite.

ThisBuild / scalacOptions ++= Seq("-unchecked", "-deprecation", "-Wunused:all", "-rewrite")

and

val globalScalaVersion = "3.7.0-RC1-bin-SNAPSHOT"

at c95f43e1f50f2d247c4d9a129faa55d46d19159d

@som-snytt som-snytt added area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 23, 2025
@som-snytt som-snytt linked a pull request Feb 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug itype:crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant