Problem with imports in a scala program

I converted from Eclipse to Intellij (Ultimate, 14.1.6) a few months ago, and so far everything has been working fine. I'm currently working on a scala project (scala version 2.10) with some java code (1.6). The project is configured using Maven, the source is stored in Subversion. I'm using Windows 7.

A couple of days ago, Intellij started to mess up my import statements. Classes in the same project are marked as not found, and packages in external projects (jar-files) are marked as not found. However, classes in for instance apache projects seem ok.

I'll try to explain what happens using an example:

1. I delete all import statements from my scala class.

2. Internal classes are correctly highlighted in red font, when I hover over it it shows the message "Cannot resolve symbol xxx" (for some reason, the message is shown twice).

3. I press alt-enter, and the IDE brings up a popup with the expected options.

4. I select "import <the-class-i'm-looking-for>

5. The import statement is created correct as far as I can see, but the last part of it (the class name) is highlighted in red, and the error message says "Cannot resolve symbol xxxx". 

I KNOW that the jar-file is in the classpath. I can find the jar under "External Libraries", and I'm able to drill down to the class in question. The fact that Intellij suggests "import xxx" when I press alt-enter also indicates that this is true.

 

SECOND EXAMPLE:

1. I type the name of a class in an external jar-file.

2. I press alt-enter, Intellij shows the popup where the correct import statement is one of the options.

3. I select the import.

4. The correct import is created, but one component of the path is highlighted in red, cannot resolve symbol.

I've tried different options in Intellij settings, I've tried to re-create the project in Intellij, I've tried to restart Intellij and I've even tried to reboot my computer. Nothing helps...

 

1 comment
Comment actions Permalink

Solved it :-) 

The problem was that in my test sources, I had (in some way or another) created a package within another package. This new package had a long name which was more or less the correct package name twice. Seems like the compiler became very confused by this...

0

Please sign in to leave a comment.