Skip to content

Importing from a deprecated element does not warn #15479

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

Closed
som-snytt opened this issue Jun 19, 2022 · 3 comments · Fixed by #15489
Closed

Importing from a deprecated element does not warn #15479

som-snytt opened this issue Jun 19, 2022 · 3 comments · Fixed by #15489
Assignees
Milestone

Comments

@som-snytt
Copy link
Contributor

som-snytt commented Jun 19, 2022

Compiler version

3.1.2

Minimized code

package deptest {
  @deprecated("Not used any more", since="7")
  object DeprecatedThing {
    val oldValue = 42
  }
}

package depuser {
  import deptest.DeprecatedThing._
  //import deptest.DeprecatedThing

  object DepUser {
    def main(args: Array[String]): Unit = println {
      oldValue
      //DeprecatedThing.oldValue  // warns
    }
  }
}

Output

  scalac -d /tmp dep.scala
  sdk use scala 2.13.8
==== BROADCAST =================================================================
* 2022-06-19: schemacrawler 16.16.18 available on SDKMAN! https://www.schemacrawler.com/changes-report.html
* 2022-06-10: gradle 7.5-rc-2 available on SDKMAN!
* 2022-06-10: scala 2.12.16 available on SDKMAN! https://github.com/scala/scala/releases/tag/v2.12.16
================================================================================

Using scala version 2.13.8 in this shell.
  scalac -d /tmp dep.scala
warning: 1 deprecation (since 7); re-run with -deprecation for details
1 warning
  scalac -d /tmp -Xlint dep.scala
dep.scala:16: warning: object DeprecatedThing in package deptest is deprecated (since 7): Not used any more
      oldValue
      ^
1 warning

Expectation

Selecting from a deprecated thing should warn, even if an import is implicated. (Edited for clarity.)

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 19, 2022
@odersky
Copy link
Contributor

odersky commented Jun 19, 2022

An import selector is a selection.

It isn't actually. An import selector is an envelope of a number of possible selections of term or type names, and their overloaded variants. Mixing this with deprecation checking would be a large step towards attaining final big ball of mud status without gaining anything substantial.

@odersky odersky closed this as completed Jun 19, 2022
@som-snytt
Copy link
Contributor Author

This is for the warning at the reference, though, not at the import.

In the example, deptest.DeprecatedThing.oldValue.

@odersky
Copy link
Contributor

odersky commented Jun 19, 2022

Ah I misunderstood. Reopening.

@odersky odersky reopened this Jun 19, 2022
@odersky odersky removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jun 20, 2022
@odersky odersky self-assigned this Jun 20, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Jun 21, 2022
 - keep all imports around until erasure
 - traverse import qualifiers to do cross version checks on their constituents
 - fix parts of the build that imported the deprecated package scala.collection.JavaConverters

Fixes scala#15479
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants