Skip to content

3.3.0-RC4 -Wunused:imports false positive for imports that are only used in imports #17314

Closed
@Lasering

Description

@Lasering

Compiler version

3.3.0-RC4

Minimized code

Define some givens in a base package:

package com.base

import java.net.URI
import io.circe.Codec
import io.circe.derivation.Configuration

given Configuration = ???
given Codec[URI] = ???

Import those givens explicitly by type in another package:

package com.base.models

import java.net.URI
import io.circe.Codec
import io.circe.derivation.{Configuration, ConfiguredCodec}
import com.base.{given Configuration, given Codec[URI]}

case class Operator(url: Option[URI]) derives ConfiguredCodec

Output

The compiler gives the following warnings:

import io.circe.Codec
                ^^^^^
                unused import
import io.circe.derivation.{Configuration, ConfiguredCodec}
                            ^^^^^^^^^^^^^
                            unused import
import com.base.{given Configuration, given Codec[URI]}
                                      ^^^^^^^^^^^^^^^^
                                      unused import

Expectation

No warning should be emitted. Please note:

  • Configuration and Codec were only imported to be used in import com.base.{given Configuration, given Codec[URI]} the rest of the file does not use those types.
  • the method ConfiguredCodec.derived expects a Configuration instance to be in the implicit scope.
  • Codec[URI] will be used while deriving the ConfiguredCodec.

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions