-
Notifications
You must be signed in to change notification settings - Fork 21
Some of my Scala files have lines marked as errors despite being valid Scala code #2767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2767?orig=1
|
spiros said: If you are using 2.7.x, is this bug the same as SI-1277? |
John Ky (newhoggy) said: |
John Ky (newhoggy) said: |
spiros said: BTW thank you for you interest in improving SDT by submitting a bug report. Bug reports are always helpful, but they are more helpful if they provide a specific way to reproduce the bug using a small self-contained code example. For example see #2689, the code provided is minimal and has no dependencies so the developers can easily see the problem or use the provided code in a test case. It would be extremely helpful, if this bug is not a duplicate of #2689, if you could find the smallest example that reproduces the misbehavior that you have observed. |
John Ky (newhoggy) said: I've got a screencast showing the errors I am getting with a slightly more simplified class, but I think it must be part of the project. http://www.screencast.com/users/newhoggy/folders/Jing/media/cc7e1259-b0af-4175-9e5b-857a0a3d53f0 Let me know if there is anything else I can provide to help diagnose the problem. |
spiros said: BTW when you are using the nightly builds you don't have to report the whole version number, you can just use the revision. In you case it is r19928. |
John Ky (newhoggy) said: |
@milessabin said: |
John Ky (newhoggy) said: |
spiros said: |
spiros said: |
John Ky (newhoggy) said: For some reason, it doesn't like: case NULL => { NULL and ValueReference. case lexical.Operator( case lexical.CommentLit(n) => n I'm using r20423 |
@milessabin said: |
spiros said: |
@milessabin said: |
spiros said: any compiler related fix is more than welcome, I am looking forward to test the next nightly. Replying to [comment:15 milessabin]:
|
spiros said: |
@milessabin said: |
spiros said: the below code gives a bogus error message in the Scala editor: package test
import javax.persistence._
class User {
@Temporal(TemporalType.TIMESTAMP)
var lastLogin: java.util.Date = _
} The message is: "annotation argument needs to be a constant; found: TemporalType{}.TIMESTAMP{}" and I believe that it happens because the Scala compiler believes that Java Enums are not valid values for annotation arguments (TemportalType is a Java Enum). Sorry for the external dependency to JPA but this does not work if the annotation and the enum are defined in the same project as the User class (maybe due to a compiler bug, I'll file another bug report). |
@milessabin said: |
spiros said: If the Java annotation, Java enum and the Scala class are in the same project then we get the compiler bug and Eclipse correctly reports this error in both the editor and the problems view (Eclipse does not know that the compiler has a bug). In the case that I wrote in my comment the code compiles and runs so the error is bogus since compilation completed successfully. The problem with Eclipse here is that an error that produced during compilation and was later (during compilation) removed is shown in the Scala editor. |
spiros said:
and I believe that since the code gets compiled this might be an instance of this behavior. |
spiros said: |
@milessabin said: |
spiros said: |
@milessabin said: |
spiros said: |
spiros said: The creator of the bug said that the attached Scala file (which is the same as the example that I used in my comment) produces a compilation error but the code runs (so it compiles). I believe that he was seeing a bogus message (not reported in the Problems View). The message must be bogus since the he said that the code runs. If we get a compilation error we cannot run the code. Then when you tried to minimize the dependencies of the example code you found the real bug with the code that you wrote in your first comment. In this comment the annotation, enum and Scala class are defined (and hence compiled) in the same project so the compiler bug get triggered (Eclipse here correctly reports the compilation error which is result of the bug since it does not know that the compiler has a bug). In this case you cannot run the code and hence the compilation error in valid (although the result of a compiler bug). I expect the code that uses the JPA annotations not to produce any errors because as rytz said in a later comment of #2764 "it works when compiling against the compiled java files" which is the case with JPA since the annotation and the enum are compiled in the JPA jar. Also when we compile from the command line we do not get any compiler messages. |
@milessabin said: The foregoing is assuming that you do have source in this case ... hence my earlier question about source attachments. |
@milessabin said: I suspect that the fix for #2931 will have improved the situation for this ticket as well, but there are still likely to be issues in the presentation compiler with types which are contained in source files which aren't named for the type. If automatic building is enabled, then the class file generated for such a type will provide a reference back to the source file it was built from irrespective of the source file name. But if there's no class file there's no way (currently) for the presentation compiler to locate the source file for a given type (unless it already knows about it because that type's source file is open in an editor). Hopefully that gives you some context for my previous request ... |
spiros said: |
@milessabin said: |
spiros said:
Of course I will! I just hope that the nightly build won't be broken again so I can update tomorrow morning (last success was 2 days 17 hr ago). |
@milessabin said: |
@ijuma said: |
spiros said:
Yeap! If I am correct there are some scaladoc errors that prevent the build to succeed so the update site does not get updated. |
@ijuma said: |
spiros said:
Sorry my mistake :-( I quickly saw the console output from hudson and thought it was a scaladoc problem. Good to know that the problem is fixed. |
spiros said: |
@milessabin said: A.scala object Misnamed B.scala object B {
val a = Misnamed
} If at least one of,
Note that in the both the error and the non-error case the presentation compiler might need a little nudge to exhibit the behaviour as described (e.g to make the incorrect error go away by opening A.scala you might also need to make a single character edit to B.scala; to make the error reappear you might need to reinstantiate the presentation compiler by doing a clean). I think that this example probably covers all the remaining cases of this ticket, so if you're seeing incorrect behaviour which is clearly different from the incorrect behaviour I've just described, then please let me know. |
spiros said: I have a small 58 file project. In that project almost all of the classes are placed in files that correspond to their class names except for one exception which is placed in a file called exceptions.scala. In that project when I do a Clean&Build I get the bogus errors despite exceptions.scala being open and .class file being present in the hard disk. Closing the file and reopening it does not remove the errors. To remove them I have to edit the file and save it. From my testing so far, what appears to have changed in the recent nightly is that we don't longer get bogus error messages for incremental compilation. Now to trigger the bug we need to do a clean. BTW I can privately share two projects that have this behavior. They are 25 and 58 files and they only depend on JUnit. I've tried to trimmed them down to a 5 files project but the errors disappear. If you want I can send them via email. |
@milessabin said: |
spiros said: |
@milessabin said: |
spiros said: Related in my previous comment meant that the fix for #2710 and the fix this bug might be in the same area so #2710 might be a good bug to tackle after this one. |
@milessabin said: |
spiros said: |
@milessabin said: |
@milessabin said: The IDE now maintains a map from top-level symbols to source files, and uses this to add additional compilation units to the presentation compiler run to resolve symbols which can't be resolved via the Java source naming convention. Building the map requires parsing the sources to extract top-level symbols. This adds a (small) one-time overhead the first time a project is touched after a restart or a clean, and a (very small) overhead on each source file save. I think this overhead is acceptable (4s for the initial whole-project scan for the scala project, 10s of ms for single file scans), but if that turns out not to be the case it should be possible to persist some or all of the map across restarts and cleans. I believe that this fixes all of the issues mentioned in this ticket so far. However, there might be further cases where the presentation compiler reports spurious errors. Please use your judgement when deciding whether to reopen this ticket or create a fresh one: if you have a very specific, easily reproducible example, then a fresh ticket would be appropriate. |
spiros said: From my testing so far the errors are greatly reduced but they still exist. At first I thought that the errors were only for packages and package objects but I also saw an error for an object. I will investigate this further and try to report specific ways to reproduce. All the errors are for Scala top level elements that are defined in files that do not correspond to their qualified names that is why I reopen this issue instead of a new one. |
@milessabin said: |
spiros said: I am using r20879 and I definitely see spurious errors. If you cannot reproduce this bug using the instructions in my email please let me know and I'll try to come up with another example. |
@milessabin said: |
To reproduce, please install Scala plugin and subclipse plugin and import the source code from https://asn1gen.googlecode.com/svn/trunk/asn1gen as an eclipse project.
Then open the file asn1gen/src/org.asn1gen.parsing.asn1.Asn1ParserBase.scala
Here, I get a lot of "not found" and "not a member" errors.
This is despite the fact that whole project builds fine and the corresponding unit tests at https://asn1gen.googlecode.com/svn/trunk/asn1gentest all pass.
The text was updated successfully, but these errors were encountered: