bug icon indicating copy to clipboard operation
bug copied to clipboard

False warning for an unused type alias if its member type is used

Open noresttherein opened this issue 3 years ago • 1 comments

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] }

noresttherein avatar Jun 04 '22 22:06 noresttherein

➜  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")))))

som-snytt avatar Jun 05 '22 02:06 som-snytt

I wish I had read my comment. I forgot about -Yprint-trees:compact.

som-snytt avatar Aug 09 '23 09:08 som-snytt