scala/scala — pull request #999 by VladUreche (2012-07-26 14:44:15+00:00)
Title: Hiding AnyRef specialization under a flag

As discussed on SI-6103: https://issues.scala-lang.org/browse/SI-6103

The reasoning is the following: the current implementation is fragile,
so we'll let the users choose whether to use it or not via the
-Xanyref-specialization flag. Source can be compiled against previously
AnyRef-specialized code without the flag, and will use the AnyRef-specd
classes, but will not be AnyRef-specialized itself.

Since the specialization information is pickled into the classfile,
we need to filter AnyRef out of the specialized annotation before we
pickle it. This is exactly what this patch does -- it expands the
specialized types in superaccessors, warns if it notices AnyRef, and
replaces the modified annotation.

THIS PATCH BREAKS BACKWARD COMPATIBILITY AT BYTECODE LEVEL:
- previously un-expanded specializations won't work anymore
- since Function*, Tuple* and Option were previously specialized
on AnyRef but are no more, older code that uses the specialized classes
won't work anymore

Another less intrusive solution suggested by Lukas is to add an
anti-annotation @noAnyRefspecialization that we can add in
superaccessors and read in specialization to remove AnyRef from
the specialized list. WDYT?

Review by @paulp and @dragos pls. KTHXBYE