resolving package object imports

39 views
Skip to first unread message

Brian Kent

unread,
Feb 2, 2015, 12:49:54 PM2/2/15
to scala-i...@googlegroups.com
Hi,

Scala IDE (4.0.0-vfinal-20150113-0949-Typesafe) seems to handle importing package objects inconsistently.  Is that a known issue?

Given something like:

package object foo {
  trait Bar
}

if I try to reference Bar in another file and I
trigger autocomplete (cmd-space), then I get the following options in the listing:
"Bar - foo"  (correct)
"Bar - foo.`package`"  (technically correct, but redundant)
use the help/suggestion menu (cmd-1), then I get the following options in the listing:
"Bar - package"  (incorrect)
"Bar - package$"  (incorrect)

I tend to use the cmd-1 option instinctively, so I always have to go back and edit to the correct package.

Any insight would be appreciated.

Thanks!

- Brian

iulian dragos

unread,
Feb 2, 2015, 1:34:29 PM2/2/15
to scala-i...@googlegroups.com
Don't use traits/classes inside package objects. Not only for the IDE, but it's generally discouraged. There's for sure a number of posts on scala-user/internals about why that's bad (implementation restrictions).

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/fca52fc9-9f80-4c15-86d3-1715576f1253%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Brian Kent

unread,
Feb 2, 2015, 1:42:36 PM2/2/15
to scala-i...@googlegroups.com
Do you have a link? What I could find seems old (<= 2.10.x). (I am using Scala 2.11.5).

iulian dragos

unread,
Feb 3, 2015, 8:18:46 AM2/3/15
to scala-i...@googlegroups.com

On Mon, Feb 2, 2015 at 7:42 PM, Brian Kent <brian....@gmail.com> wrote:

Do you have a link? What I could find seems old (<= 2.10.x). (I am using Scala 2.11.5).

My 2.11.5 compiler warns me (using -Xlint):

it is not recommended to define classes/objects inside of package objects. If possible, define trait MyFooTrait in package test instead.

Screenshot attached.

cheers,


For more options, visit https://groups.google.com/d/optout.

Screen Shot 2015-02-03 at 14.17.25.png

Brian Kent

unread,
Feb 3, 2015, 12:03:38 PM2/3/15
to scala-i...@googlegroups.com

Many thanks, Iulian!  I had no idea that was considered bad form.
Reply all
Reply to author
Forward
0 new messages