Skip to content
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

When feature warnings and deprecation ones are both present, :warnings only shows deprecation warnings (& other problems) #6307

Open
scabug opened this issue Sep 2, 2012 · 3 comments
Labels

Comments

@scabug
Copy link

scabug commented Sep 2, 2012

When feature warnings and deprecation ones are both present, :warnings only shows deprecation warnings. As an aside, the messages for deprecation/feature warnings, both in the compiler and in the REPL, suggest rerunning with extra options, while in the REPL they should suggest using the :warnings command.

Let's compare the warnings that :warnings shows us for the following two lines of code:

implicit def any2optionable(x : AnyRef) = new {def matchInstance[B: Manifest]: Option[B] = null}
implicit def any2optionable(x : AnyRef) = new {def matchInstance[B]: Option[B] = null}

The first will give deprecation and feature warnings, the second only feature warnings.

$ ./qbin/scala
Welcome to Scala version 2.10.0-20120828-070538-8ca87e36ba (OpenJDK 64-Bit Server VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.

scala> implicit def any2optionable(x : AnyRef) = new {def matchInstance[B: Manifest]: Option[B] = null}
warning: there were 2 deprecation warnings; re-run with -deprecation for details
warning: there were 1 feature warnings; re-run with -feature for details
any2optionable: (x: AnyRef)Object{def matchInstance[B](implicit evidence$1: Manifest[B]): Option[B]}

scala> :warnings
<console>:7: warning: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
       implicit def any2optionable(x : AnyRef) = new {def matchInstance[B: Manifest]: Option[B] = null}
                    ^
<console>:7: warning: type Manifest in object Predef is deprecated: Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead
       implicit def any2optionable(x : AnyRef) = new {def matchInstance[B: Manifest]: Option[B] = null}
                                                                         ^

scala> implicit def any2optionable(x : AnyRef) = new {def matchInstance[B]: Option[B] = null}
warning: there were 1 feature warnings; re-run with -feature for details
any2optionable: (x: AnyRef)Object{def matchInstance[B]: Option[B]}

scala> :warnings
<console>:8: warning: implicit conversion method any2optionable should be enabled
by making the implicit value language.implicitConversions visible.
This can be achieved by adding the import clause 'import language.implicitConversions'
or by setting the compiler option -language:implicitConversions.
See the Scala docs for value scala.language.implicitConversions for a discussion
why the feature should be explicitly enabled.
       implicit def any2optionable(x : AnyRef) = new {def matchInstance[B]: Option[B] = null}
                    ^

Finally, the count of feature warnings seems wrong (two counted, one shown):

scala> implicit def any2optionable(x : AnyRef) = new {def matchInstance[B]: Option[B] = null}
warning: there were 1 feature warnings; re-run with -feature for details
any2optionable: (x: AnyRef)Object{def matchInstance[B]: Option[B]}

scala> "".matchInstance
warning: there were 2 feature warnings; re-run with -feature for details
res0: Option[Nothing] = null

scala> :warnings
<console>:9: warning: reflective access of structural type member method matchInstance should be enabled
by making the implicit value language.reflectiveCalls visible.
This can be achieved by adding the import clause 'import language.reflectiveCalls'
or by setting the compiler option -language:reflectiveCalls.
See the Scala docs for value scala.language.reflectiveCalls for a discussion
why the feature should be explicitly enabled.
              "".matchInstance
                 ^

In the above example, also when using -feature one still gets a single feature warning.

@scabug
Copy link
Author

scabug commented Sep 2, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6307?orig=1
Reporter: @Blaisorblade
Affected Versions: 2.10.0-M7, 2.10.0

@scabug
Copy link
Author

scabug commented Nov 18, 2013

@paulp said:
Mostly this is fixed by 343127958c. The part which isn't is that it should say "run :warnings for details" in the repl.

@scabug
Copy link
Author

scabug commented Dec 22, 2014

@som-snytt said:
That was #6120. Now it needs a dash of configurable reporter.

scala> object X { @deprecated("","") def x(): Int = 42 }
defined object X

scala> X x
warning: there was one deprecation warning; re-run with -deprecation for details
warning: there was one feature warning; re-run with -feature for details
res0: Int = 42

scala> :warnings
<console>:9: warning: method x in object X is deprecated:
              X x
                ^
<console>:9: warning: postfix operator x should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scala docs for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
              X x
                ^

scala> :replay -deprecation
Replaying: object X { @deprecated("","") def x(): Int = 42 }
defined object X

Replaying: X x
<console>:9: warning: method x in object X is deprecated:
              X x
                ^
warning: there was one feature warning; re-run with -feature for details
res0: Int = 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant