Intersection types made specializable.

Formerly a specializable type parameter would be missed if in
an intersection.

  trait Trait[@specialized T] {
    def f[T](x: Foo[T] with Bar) = x
  }

Now that is specialized, as it already was in the "Foo[T]" case.
Closes SI-4794, no review.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25613 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-09-06 02:48:52 +00:00
parent 3d631fe87d
commit 9cf65a8d6c
3 changed files with 14 additions and 0 deletions

View File

@ -346,6 +346,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case ExistentialType(_, res) => specializedTypeVars(res)
case AnnotatedType(_, tp, _) => specializedTypeVars(tp)
case TypeBounds(lo, hi) => specializedTypeVars(List(lo, hi))
case RefinedType(parents, _) => parents flatMap specializedTypeVars toSet
case _ => Set()
}

View File

@ -0,0 +1 @@
10

View File

@ -0,0 +1,12 @@
trait Mutable[@specialized A] { def a: A; def a_=(a0: A): Unit }
trait NotSpecialized { }
class Arr[@specialized A](val arr: Array[A]) {
def bippy(m: Mutable[A]) { m.a = arr(0) }
def quux(m: Mutable[A] with NotSpecialized) { m.a = arr(0) }
}
object Test {
def main(args: Array[String]): Unit = {
println(classOf[Arr[_]].getMethods filter (_.getName contains "quux") size) // expect 10, not 1
}
}