scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Warn on unused given in class that only used for contructing the same class

Open eejbyfeldt opened this issue 4 days ago • 1 comments

Compiler version

3.7.4

Minimized example

object test {
  trait TC[X] {
    def notTrivial: Int
  }

  class C[T: TC]() {
    def mod: C[T] = new C()
  }
}

Output

No warning.

Expectation

If one removes the mod method one gets a warning. It would be nice if it would still warn even when mod is defined. Since the TC[T] instances only get used for calling Cs constructor it is effectively unused.

eejbyfeldt avatar Dec 08 '25 08:12 eejbyfeldt