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

Spurious warning for implicit classes declared in package objects

    Details

      Description

      package scala.reflect
      
      package object api {
        implicit class PimpedExpr[T](expr: Universe # Expr[T]) {
          def runtimeEval: T = {
            println("hello, dear")
            expr.eval
          }
        }
      }
      
      Eval.scala:4: warning: it is not recommended to define classes/objects inside of package objects.
      If possible, define class PimpedExpr in package api instead.
      

        Activity

        Hide
        Lukas Rytz added a comment -

        for the moment, just drop the warning for implicit classes and hope for the best

        Show
        Lukas Rytz added a comment - for the moment, just drop the warning for implicit classes and hope for the best
        Hide
        Paul Phillips added a comment -

        I moved the warning behind -Xlint a while before this ticket was opened. I don't think there's anything left to do here.

        Show
        Paul Phillips added a comment - I moved the warning behind -Xlint a while before this ticket was opened. I don't think there's anything left to do here.
        Hide
        A. P. Marki added a comment -

        "-Xlint would have told you not to do that".

        I didn't want to be the first to comment. That was a couple of hours before I opened SI-5760.

        Show
        A. P. Marki added a comment - "-Xlint would have told you not to do that". I didn't want to be the first to comment. That was a couple of hours before I opened SI-5760 .
        Hide
        Lukas Rytz added a comment - - edited

        @paul ok, but the -Xlint warning is still wrong for implicit classes, they cannot be top-level.

        Show
        Lukas Rytz added a comment - - edited @paul ok, but the -Xlint warning is still wrong for implicit classes, they cannot be top-level.
        Hide
        Paul Phillips added a comment -

        Right, that's true. I think I was subconsciously taking the position that imperfections in -Xlint output are "trees falling in a forest" but one never knows. If you assign this to me I'll fix it, or it's all yours.

        Show
        Paul Phillips added a comment - Right, that's true. I think I was subconsciously taking the position that imperfections in -Xlint output are "trees falling in a forest" but one never knows. If you assign this to me I'll fix it, or it's all yours.
        Hide
        Lukas Rytz added a comment -

        who could say no to a volunteer! thanks.

        Show
        Lukas Rytz added a comment - who could say no to a volunteer! thanks.
        Hide
        Paul Phillips added a comment -

        Fixed back in 006e12a119 .

        Show
        Paul Phillips added a comment - Fixed back in 006e12a119 .

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development