bug
bug copied to clipboard
False warning for an unused type alias if its member type is used
Reproduction steps
Scala version: 2.13.7
class Private {
private type Curry[A] = { type T[B] = Either[A, B] }
def m2[T[A]] :Unit = ()
m2[Curry[Int]#T]
}
Problem
compiled with -Wunused:privates,locals,patvars:
private type Curry in class Private is never used
private type Curry[A] = { type T[B] = Either[A, B] }
➜ scalac -d /tmp -Wunused -Vprint:typer t12600.scala
t12600.scala:3: warning: private type Curry in class Private is never used
private type Curry[A] = { type T[B] = Either[A, B] }
^
[[syntax trees at end of typer]] // t12600.scala
package <empty> {
class Private extends scala.AnyRef {
def <init>(): Private = {
Private.super.<init>();
()
};
private type Curry[A] = AnyRef{type T[B] = Either[A,B]};
def m2[T[A] >: [A]Nothing <: [A]Any]: Unit = ();
Private.this.m2[[B]scala.util.Either[Int,B]]
}
}
1 warning
-Yprint-trees:compact says that is a
TypeApply(Select(This(TypeName("Private")), TermName("m2")), List(TypeTree().setOriginal(SelectFromTypeTree(TypeTreeWithDeferredRefCheck(), TypeName("T")))))
I wish I had read my comment. I forgot about -Yprint-trees:compact.