Question

Is there a way to run a Scala application or unit test within the Scala IDE 2.0.2 (Eclipse 3.7) if there are (unrelated!) compilation errors in the project?

In Java, this is no problem, but Scala IDE keeps telling me:

Project contains compilation errors (therefore, no binaries have been produced).

All I want to do is to run a small test during a major refactoring process, but I can't fix all compilation errors right now. And I don't want to start commenting things out, as those compilation errors are good reminders of tasks that still need to be done.

Was it helpful?

Solution

Currently the Scala IDE does not support this behavior, but it would be nice if it could.

To be aware of this, I created a ticket:

JDT allows to execute Java code despite of compilation problems in the sources. Internally JDT replaces the defective code with an exception, which is thrown if the relevant code is executed. But if the defective code is never called during execution, nothing bad happens. It would be nice if SDT supports similar behavior.

OTHER TIPS

If you are using Scala 2.10, a good option is to use the newly introduced ??? notation. This way your code will compile even if the function is not yet implemented.

There is certainly a better way but this one will still be better than commenting code.

As suggested by Jesper, you can still implement ??? if you are working with previous versions of Scala:

def ??? : Nothing = throw new Error("Not implemented") 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top