Iltotore / iron

Strong type constraints for Scala
https://iltotore.github.io/iron/docs/
Apache License 2.0
427 stars 37 forks source link

deprecation warning does not show for `refine` #229

Closed 2m closed 3 months ago

2m commented 4 months ago

Scala environment: JVM Scala version: 3.4.0 Iron version: 2.5.0

Deprecation warnings are not generated for refine usage.

//> using scala 3.4.0
//> using dep io.github.iltotore::iron:2.5.0
//> using option -deprecation

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.numeric.*

def log(x: Double :| Positive): Double =
  Math.log(x) // Used like a normal `Double`

val runtimeValue: Double = 1.9
log(runtimeValue.refine)

Output:

Compiling project (Scala 3.4.0, JVM (21))
Compiled project (Scala 3.4.0, JVM (21))

An example of deprecated method usage from another library where deprecation warning shows up in scala-cli:

//> using scala 3.4.0
//> using dep com.monovore::decline:2.4.1
//> using option -deprecation

import com.monovore.decline.*

object MyApp
    extends CommandApp(
      name = "my-app",
      header = "This is a standalone application!",
      main = Opts.flag("fantastic", "Everything is working.")
    )

MyApp.main(Array.empty)

Output:

Compiling project (Scala 3.4.0, JVM (21))
[warn] ./decline.sc:14:1
[warn] method main in class CommandApp is deprecated since 0.3.0: 
[warn] The CommandApp.main method is not intended to be called by user code.
[warn] For suggested usage, see: http://monovore.com/decline/usage.html#defining-an-application
[warn] MyApp.main(Array.empty)
[warn] ^^^^^^^^^^
Compiled project (Scala 3.4.0, JVM (21))

The only difference I see is that decline used since in the deprecated annotation.

Iltotore commented 4 months ago

The only difference I see is that decline used since in the deprecated annotation.

I think it's either this or deprecated does not play well with inline methods.

2m commented 4 months ago

Yea, that's right. Just tried it in my local project, and as soon as I add inline, deprecation warning disappears.

Iltotore commented 4 months ago

I think you should open an issue on https://github.com/scala/scala3. Feel free to link the issue here once done.