Oh jeez. Reitveld just dropped a huge comment I had due to an invalid XSRF token. Let's try again.
Scala puts $ in class names, e.g. "Foo$.class" for objects, so scalagwt would have classes like "Foo$$Bar" or "Foo$$anon$2" that messed up the usual "Foo$Bar" -> "Foo.Bar" source name heuristic. This led to CompilationState and TypeOracle being incorrectly populated, which later led to various things blowing up. The strategy for fixing this was twofold: 1) Get CompilationState and TypeOracle correctly populated 2) Avoid toSourceName/etc. calls as much as possible. --- For 1), this was done by realizing the bytecode has an InnerClass attribute (OuterClass was already being captured by TypeData) which can be used to deterministically calc the source name. For 2), avoiding name conversion basically meant always keeping two maps (one by internal or binary, and one by source). Fortunately: * CompilationState already had two maps. * TypeOracle had a by-source map, but TypeOracleMediator had a map of the same values, by-internal, so TypeOracle could easily borrow it to have both available. * JProgram had a by-binary map, so now has a new by-source map (this is the only new map introduced) Once both maps were in the right places, it was just a matter of finding all the places clients were doing their own name mangling (because a client wanted to call TypeOracle, but had an internal name, so would do it's own toSourceName conversion), and changing them to directly pass the unmolested name in for look up. * CompilationState already had two ways of looking up, so didn't need an API change * TypeOracle only had findType(sourceName), so got some new methods to do non-source name look up (e.g. sourceOrBinary for jsni) * JProgram's getFromTypeMap already took sourceOrBinary name as an argument, so new method is needed, getFromTypeMap is now implemented by checking both maps instead of doing name mangling of source names to binary. All things considered, I feel good about the patch. Although a bit scattered about, I think the changes are at least somewhat straightforward. The only thing I'm really displeased about is the JDT giving qualified refs as source names, which need to be converted to internal names for the Dependencies. This conversion is still done deterministically, but it took a bit of JDT poking that would have been nice to avoid. I think that's it (again...copy/pasting to notepad). Let me know if I missed anything or if you have any questions. Thanks! http://gwt-code-reviews.appspot.com/1542804/ -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
