Skip to content
This repository
Browse code

SI-7638 Superaccessor lookup after specialization

The crash was caused by a symbol lookup to rewire the super calls,
done after pickler, but specialization added new traits and new
members, thus making the super rewiring impossible. To avoid such
problems, this patch moves symbol lookup after specialization,
so the changes done by specialization (and miniboxing) become
visible to mixin.

NOTE: This patch will be followed by a similar patch to master.

Review by @adriaanm or @retronym.
  • Loading branch information...
commit 504b5f3b157de639633c962ea21f7e89152da77f 1 parent 54cb6af
Vlad Ureche VladUreche authored
2  src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -119,7 +119,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
119 119 * @param mixinClass The mixin class that produced the superaccessor
120 120 */
121 121 private def rebindSuper(base: Symbol, member: Symbol, mixinClass: Symbol): Symbol =
122   - afterPickler {
  122 + afterSpecialize {
123 123 var bcs = base.info.baseClasses.dropWhile(mixinClass != _).tail
124 124 var sym: Symbol = NoSymbol
125 125 debuglog("starting rebindsuper " + base + " " + member + ":" + member.tpe +
51 test/files/pos/SI-7638.scala
... ... @@ -0,0 +1,51 @@
  1 +package miniboxing.tests.compile
  2 +
  3 +trait Ordering[@specialized(Int) A] {
  4 + def eqv(x: Array[A], y: Array[A]): Boolean = false
  5 +}
  6 +
  7 +trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] {
  8 + override def eqv(x: Array[A], y: Array[A]): Boolean = super.eqv(x, y)
  9 +}
  10 +
  11 +object vectorOrder {
  12 + implicit def arrayOrder[@specialized(Int) A]() =
  13 + /*
  14 + * Before applying patch:
  15 + *
  16 + * while compiling: SI-7638.scala
  17 + * during phase: mixin
  18 + * library version: version 2.10.3-20130625-164027-d22e8d282c
  19 + * compiler version: version 2.10.3-20130627-153946-54cb6af7db
  20 + * reconstructed args:
  21 + *
  22 + * last tree to typer: TypeTree(class Array)
  23 + * symbol: class Array in package scala (flags: final)
  24 + * symbol definition: final class Array[T >: ? <: ?] extends Object
  25 + * tpe: Array[Int]
  26 + * symbol owners: class Array -> package scala
  27 + * context owners: anonymous class anon$1 -> package compile
  28 + *
  29 + * == Expanded type of tree ==
  30 + *
  31 + * TypeRef(
  32 + * TypeSymbol(final class Array[T >: ? <: ?] extends Object)
  33 + * args = List(TypeRef(TypeSymbol(final abstract class Int extends )))
  34 + * )
  35 + *
  36 + * unhandled exception while transforming SI-7638.scala
  37 + * error: uncaught exception during compilation: java.lang.UnsupportedOperationException
  38 + * error: java.lang.UnsupportedOperationException: tail of empty list
  39 + * at scala.collection.immutable.Nil$.tail(List.scala:339)
  40 + * at scala.collection.immutable.Nil$.tail(List.scala:334)
  41 + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:123)
  42 + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:122)
  43 + * at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:207)
  44 + * at scala.reflect.internal.SymbolTable.afterPhase(SymbolTable.scala:216)
  45 + * at scala.tools.nsc.Global.afterPickler(Global.scala:1104)
  46 + * at scala.tools.nsc.transform.Mixin.scala$tools$nsc$transform$Mixin$$rebindSuper(Mixin.scala:122)
  47 + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:339)
  48 + * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:292)
  49 + */
  50 + new ArrayVectorOrder[A] { }
  51 +}

0 comments on commit 504b5f3

Please sign in to comment.
Something went wrong with that request. Please try again.