permanently hidden warning in scala application

后端 未结 10 2157
臣服心动
臣服心动 2021-01-31 14:25

I get the following warning whenever I start my Scala application:

WARN - imported `SVNProperties\' is permanently hidden by definition of object SVNProperties in packag

相关标签:
10条回答
  • 2021-01-31 14:58

    Also, make sure the name of the package you import =/= object name.

    0 讨论(0)
  • 2021-01-31 15:02

    I got this warning when my class was importing classes in the same package.

    Once I removed the unnecessary import, the warnings were removed.

    0 讨论(0)
  • 2021-01-31 15:09

    Just to further expand on a comment posted by Nick, as this was the case for me:

    Another common cause is that SVNProperties is in the same package and so is already in scope. Trying to import it explicitly results in this warning.

    More concretely, you may have:

    package app.core
    
    // No need to import the following - it is already visible as 
    // you are in the same package
    import app.core.SVNProperties
    
    object SVNResource {
    

    Use instead:

    package app.core
    
    object SVNResource {
    

    (Opinion) As a matter of coding style you may want to camel case your variables differently like for eg. SvnProperties, SvnResource. It reads easier for most people, see also this question.

    0 讨论(0)
  • 2021-01-31 15:10

    This happened to me after moving a class from one package to another, like in astasiak's case. I ran sbt clean with no luck. For the life of me, I couldn't find the class in the old location.

    However, I had other errors preventing me from building. When I fixed those, this error disappeared. My guess is that until you can build cleanly, sbt still thinks you have the class is in the old package, and includes this error with any other build errors that are preventing you from building.

    My advice? Check for other compilation errors and fix those -- you might be erroneously getting this error due to sbt having an outdated view of your package structure since its last successful build.

    0 讨论(0)
  • 2021-01-31 15:11

    You probably have code that looks something like this:

    object Hidden {
      import scala.collection.immutable
      object immutable { def x = 7 }
    }
    

    except in a less obvious way. You're importing something--in my example, the package immutable--and then you go and define something else with the same name that prevents you from using what you imported.

    In particular, it looks like you tried to import SVNProperties into SVNResource.scala, except that SVNResource.scala defines its own SVNProperties which hides the import.

    0 讨论(0)
  • 2021-01-31 15:12

    I encountered this warning after moving some classes from one package to another. I guess there was some conflict between the new location and binaries from the old location. In my case this helped:

    sbt clean
    
    0 讨论(0)
提交回复
热议问题