Skip to content

"method is deprecated" warning is not produced for kotlin.Deprecated #12714

@unkarjedy

Description

@unkarjedy

Reproduction steps

Scala 2.13.10

  1. Use this example project.
    It contains usages of Java, Scala and Kotlin deprecated methods.
ThisBuild / scalacOptions ++= Seq("-deprecation")

lazy val root = (project in file("."))
  .settings(
    name := "scala-java-kotlin-deprecated-warnings",
    scalaVersion := "2.13.10",
    libraryDependencies ++= Seq(
      "org.jetbrains.kotlin" % "kotlin-stdlib" % "1.7.22"
    )
  )
object MainScala {
  def main(args: Array[String]): Unit = {
    //Scala deprecated
    scala.io.Source.fromRawBytes(Array())

    //Java deprecated
    (null: java.rmi.server.LoaderHandler).loadClass(null, null)

    //Kotlin deprecated fun
    (null: kotlin.DeepRecursiveScope[_, _]).invoke(null, null)

    //Kotlin deprecated class
    abstract class MyClass extends kotlin.UseExperimental//(null) needed for Scala 3 only
  }
}
  1. Compile

Actual result

Observe deprecation warnings (1 for Scala, 2 for Java):

method fromRawBytes in object Source is deprecated (since 2.13.9): Use `fromBytes` and specify an encoding
method loadClass in trait LoaderHandler is deprecated
trait LoaderHandler in package server is deprecated

There are no deprecation warnings for Kotlin members (marked with kotlin.Deprecated annotation)

Expected result

Deprecation warnings are generated for Kotlin members (marked with kotlin.Deprecated annotation)

Note 1

Scala 3 compiler can generate deprecation warnings for Kotlin members

Note 2

In IntelliJ Scala Plugin we are strongly bound to IntelliJ platform jars.
A huge part of it is written in Kotlin.
We use "fatal warnings" not to miss important deprecations from the platform in new updates.
Usually, there are a lot of deprecations and we want to detect them.
Today I noticed that our build doesn't fail if the IntelliJ platform deprecates some API written in Kotlin.
The fix seems to be relatively easy, so would be grateful to see it in minor scala releases.

image

image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions