1

I have cloned the latest version of sbt's sources from the git repository and started browsing the Scala code. I am using Eclipse (Kepler) and the Scala compiler seems to choke on several files in util/collection/src/main/scala.

For example, TypeFunctions.scala contains the trait ~> with 2 methods which have bizarre-looking names .

This weird-looking character only appears as a single symbol if I use UTF-8 encoding for the file. A binary editor shows it as a sequence of these 3 hex values: E2 88 99

Can anyone explain this please?

2 Answers2

0

tl;dr Use UTF-8 for the sources or switch to IntelliJ IDEA.

I've never looked at the file before and didn't find it an issue. Mainly because IntelliJ IDEA I use uses UTF-8 by default and the final defs display fine.

The trait ~> builds fine when sbt publishLocal also so it seems more an issue of Eclipse IDE that uses platform-dependent encoding for the source files than the sources themselves.

There's a simpler answer to your question - use a seemingly better IDE, i.e. IntelliJ IDEA or change the encoding to UTF-8.

p.s. Scala people love picking weird-looking names for their vals so get used to it :)

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Hmm. Thanks for that @Jacek. I have loaded this in IntelliJ and it does compile there.What I don't quite understand is why using the same, as far as I can see, Scala compiler, it compiles in IntelliJ and does not in Eclipse? There must a difference in the actual Scala plugins. Still, I would question the wisdom of inserting a character which is not available on all keyboards. – Krzysiek Novak Aug 02 '14 at 06:58
  • I'm not that sure about it but the point of encoding setting in an IDE **should** influence what parameters are passed to the Scala compiler as otherwise some letters in scaladoc for example would break compilation. I'd expect that. Find out what the command line for the compiler is to verify it. – Jacek Laskowski Aug 02 '14 at 07:24
  • 1
    I was wrong. Eclipse and IntelliJ seem to use their own Scala compilers. Quoting from the Scala IDE doco at http://scala-ide.org/docs/dev/architecture/presentation-compiler.html : "The Scala IDE for Eclipse uses the Scala Presentation Compiler, a faster asynchronous version of the Scala Compiler." – Krzysiek Novak Aug 02 '14 at 08:16
  • How does my answer look like now after the finding? I'm pretty sure the encoding does have an effect on the compiler anyway. See http://stackoverflow.com/q/23224219/1305344 – Jacek Laskowski Aug 02 '14 at 08:37
  • 1
    You're right. The editor and the compiler have to be bound fairly tight together.
    However, when I change the file's encoding it doesn't fix the Eclipse's Scala compiler problem. I think it means, the compiler should, but doesn't look at this setting. There is a number of various options that can be set for Eclipse's Scala plugin and none seems to be related to the file encoding.
    I am actually quite impressed by IntelliJ's ability to import SBT projects. I might even decide to switch to it from Eclipse :-).
    – Krzysiek Novak Aug 02 '14 at 09:19
  • Do the switch and forget the past annoyances! IDEA rocks once you let yourself feel the goodies it offers. – Jacek Laskowski Aug 02 '14 at 12:32
  • After a closer inspection, the shine came off IntelliJ a bit. Its Scala plugin, like Eclipse's, struggled when up against a fairly complex SBT build. The biggest failing, in my opinion, was the fact that its Problem window does not show much for a project beyond the first error the compiler comes across, even after a full project Make. Still, this remark probably doesn't belong here. – Krzysiek Novak Aug 04 '14 at 07:56
0

As I finally found out today, an answer to my problem can be found at Does the Scala compiler work with UTF-8 encoded source files?. After adding the extra Scala compiler command-line parameter (as described there), and making sure a project's files use UTF-8 encoding, things started working.

Community
  • 1
  • 1
  • The correct way is to change the Workspace encoding settings, and not the command line parameter (the Scala plugin adds -encoding itself passing the Eclipse preference, so that might, or might not, override your manually-added parameters) – Iulian Dragos Aug 04 '14 at 12:56
  • Specifically, Windows->Preferences->General->Workspace and "Text file encoding" there. Works without changing the Scala plugin configuration, thx Iulian. – Krzysiek Novak Aug 05 '14 at 04:37