Scala Programming Language
  1. Scala Programming Language
  2. SI-4594

Possibility to enable things like "-deprecation" without restarting

    Details

      Description

      = problem =
      It is annoying to restart the REPL just to see some deprecation message, especially when there is already some amount of code evaluated.

      = analysis =
      There should be some way to activate things like "-migration", "-deprecation" without having to restart the REPL, maybe via some REPL command (those starting with ":").

      = enhancement recommendation =
      Add something like that.

        Activity

        Hide
        Jason Zaugg added a comment -

        There is already a way, although it's not well publicized.

        scala> case class A
        warning: there were 1 deprecation warnings; re-run with -deprecation for details
        defined class A
        
        scala> :power
        ** Power User mode enabled - BEEP BOOP WHIR **
        ** scala.tools.nsc._ has been imported      **
        ** global._ and definitions._ also imported **
        ** New vals! Try repl, intp, global, power  **
        ** New cmds! :help to discover them         **
        ** New defs! Type power.<tab> to reveal     **
        
        scala> settings.deprecation.value = true
        
        scala> case class A
        <console>:1: warning: case classes without a parameter list have been deprecated;
        use either case objects or case classes with `()' as parameter list.
               case class A
                           ^
        

        Migration:

        
        scala> settings.Xmigration28.value = true
        
        scala> Iterator.empty.collect { case x => x }
        <console>:22: warning: method collect in trait Iterator has changed semantics:
        This collect implementation bears no relationship to the one before 2.8.
        The previous behavior can be reproduced with toSeq.
               Iterator.empty.collect { case x => x }
                              ^
        res0: Iterator[Nothing] = empty iterator
        
        Show
        Jason Zaugg added a comment - There is already a way, although it's not well publicized. scala> case class A warning: there were 1 deprecation warnings; re-run with -deprecation for details defined class A scala> :power ** Power User mode enabled - BEEP BOOP WHIR ** ** scala.tools.nsc._ has been imported ** ** global._ and definitions._ also imported ** ** New vals! Try repl, intp, global, power ** ** New cmds! :help to discover them ** ** New defs! Type power.<tab> to reveal ** scala> settings.deprecation.value = true scala> case class A <console>:1: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class A ^ Migration: scala> settings.Xmigration28.value = true scala> Iterator.empty.collect { case x => x } <console>:22: warning: method collect in trait Iterator has changed semantics: This collect implementation bears no relationship to the one before 2.8. The previous behavior can be reproduced with toSeq. Iterator.empty.collect { case x => x } ^ res0: Iterator[Nothing] = empty iterator
        Hide
        Simon Ochsenreither added a comment -

        Would it be possible to have shortcurts for it, like
        {{ :deprecation }}, {{ : migration }}
        and changing the warning messages to point to them?

        Show
        Simon Ochsenreither added a comment - Would it be possible to have shortcurts for it, like {{ :deprecation }}, {{ : migration }} and changing the warning messages to point to them?
        Hide
        Commit Message Bot added a comment -

        (extempore in r25467) Don't discard deprecation/unchecked warnings regardless of settings.

        Changed warnings code to accumulate them rather than thoughtlessly
        discarding them and issuing its well-known taunt. In the repl you
        can take advantage of this with the :warnings command, which will show
        the suppressed warnings from the last line which had any. Be advised
        that at the moment it has some issues: unchecked warnings aren't
        making it out, and near repl startup neither are deprecation warnings,
        so don't open a bunch of tickets please.

        References SI-4594, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25467 ) Don't discard deprecation/unchecked warnings regardless of settings. Changed warnings code to accumulate them rather than thoughtlessly discarding them and issuing its well-known taunt. In the repl you can take advantage of this with the :warnings command, which will show the suppressed warnings from the last line which had any. Be advised that at the moment it has some issues: unchecked warnings aren't making it out, and near repl startup neither are deprecation warnings, so don't open a bunch of tickets please. References SI-4594 , no review.
        Show
        A. P. Marki added a comment - https://github.com/scala/scala/pull/2701
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/2701

          People

          • Assignee:
            A. P. Marki
            Reporter:
            Simon Ochsenreither
            TracCC:
            Simon Ochsenreither
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development