summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-14 15:59:41 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2011-02-14 15:59:41 +0000
commit274be9370407d482c1c50a4b9e4343a1bd8ec85a (patch)
treebb224a07e4ac7054b6c1f696cde20863765b2e8f
parentba5118b24c921d1616288affbd05e376ad790f7a (diff)
downloadscala-274be9370407d482c1c50a4b9e4343a1bd8ec85a.tar.gz
scala-274be9370407d482c1c50a4b9e4343a1bd8ec85a.tar.bz2
scala-274be9370407d482c1c50a4b9e4343a1bd8ec85a.zip
A fix for #4243.
No review.
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala16
-rw-r--r--test/files/pos/t4243.scala18
2 files changed, 30 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index d6b1f54c71..04ea443313 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -212,10 +212,15 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case _ => false
}
+ private def str(tp: Type): AnyRef = tp match {
+ case TypeRef(pre, sym, args) => (str(pre), sym, args)
+ case _ => "nontpref sym: " + tp.typeSymbol + ", " + tp.getClass
+ }
+
// If we replace `isBoundedGeneric` with (tp <:< AnyRefClass.tpe), then pos/spec-List.scala fails - why?
// Does this kind of check fail for similar reasons? Does `sym.isAbstractType` make a difference?
private def subtypeOfAnyRef(tp: Type) = {
- log(tp + " <:< AnyRef " + isBoundedGeneric(tp) + ", " + tp.typeSymbol.isAbstractType)
+ // log(tp + " <:< AnyRef? tp has symbol: " + tp.typeSymbol + ", " + tp.typeSymbol.ownerChain)
!isValueClass(tp.typeSymbol) && isBoundedGeneric(tp)
}
@@ -225,9 +230,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val pre1 = this(pre)
// when searching for a specialized class, take care to map all
// type parameters that are subtypes of AnyRef to AnyRef
- val args1 = args map {
- case x if subtypeOfAnyRef(x) => AnyRefClass.tpe // used to be: case x if x <:< AnyRefClass.tpe
- case x => x
+ // log("Mapping " + args.map(_.typeSymbol) + ", from " + sym + " with params " + sym.typeParams + " with annots " + sym.typeParams.map(_.annotations))
+ val args1 = (args zip sym.typeParams) map {
+ case (x, orig) if isSpecializedOnAnyRef(orig) && subtypeOfAnyRef(x) => AnyRefClass.tpe // used to be: case x if x <:< AnyRefClass.tpe
+ case (x, _) => x
}
// log("!!! specializedType " + tp + ", " + pre1 + ", " + args1)
specializedClass.get((sym, TypeEnv.fromSpecialization(sym, args1))) match {
@@ -514,7 +520,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
*/
def specializedParents(parents: List[Type]): List[Type] = {
val res = new mutable.ListBuffer[Type]
+ // log(cls + ": seeking specialized parents of class with parents: " + parents.map(_.typeSymbol))
for (p <- parents) {
+ // log(p.typeSymbol)
val stp = atPhase(phase.next)(specializedType(p))
if (stp != p)
if (p.typeSymbol.isTrait) res += stp
diff --git a/test/files/pos/t4243.scala b/test/files/pos/t4243.scala
new file mode 100644
index 0000000000..e6c66faff0
--- /dev/null
+++ b/test/files/pos/t4243.scala
@@ -0,0 +1,18 @@
+
+
+
+
+object wrap {
+
+ trait DomainLike[@specialized(Int) A, +This <: Domain[A]]
+
+ trait Domain[@specialized(Int) B]
+ extends DomainLike[B, Domain[B]]
+
+ trait IterableDomainLike[@specialized(Int) C, +This <: IterableDomain[C]]
+ extends DomainLike[C, This]
+
+ trait IterableDomain[@specialized(Int) D]
+ extends Domain[D] with IterableDomainLike[D, IterableDomain[D]]
+
+}