summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-27 17:16:01 +0000
committerPaul Phillips <paulp@improving.org>2011-06-27 17:16:01 +0000
commit77c01a9baca66c1a5a099318d403dbedbe4feeeb (patch)
tree6ee2cd41fae1d25794fd16256d686dcfe30c846b /src/compiler/scala/reflect/internal/Types.scala
parent94a00c31680623cd2793b0db87c2bcfac10c9563 (diff)
downloadscala-77c01a9baca66c1a5a099318d403dbedbe4feeeb.tar.gz
scala-77c01a9baca66c1a5a099318d403dbedbe4feeeb.tar.bz2
scala-77c01a9baca66c1a5a099318d403dbedbe4feeeb.zip
Don't infer anonymous classes.
possible, just far enough to avoid all kinds of undesirable consequences which accompany the preservation of too much type information. (The problems are akin to inferring the singleton type too freely.) // Example of code which did not compile, but now does class A class B[T <: A](cons: T) object C extends B(new A {}) Closes #4110, #3048. I already ran this by moors, so review by odersky.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 6152cd70f5..bc9eda760c 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -5134,6 +5134,12 @@ A type's typeSymbol should never be inspected directly.
val rest = elimSuper(ts1 filter (t1 => !(t <:< t1)))
if (rest exists (t1 => t1 <:< t)) rest else t :: rest
}
+ def elimAnonymousClass(t: Type) = t match {
+ case TypeRef(pre, clazz, Nil) if clazz.isAnonymousClass =>
+ clazz.classBound.asSeenFrom(pre, clazz.owner)
+ case _ =>
+ t
+ }
/** A collector that tests for existential types appearing at given variance in a type */
class ContainsVariantExistentialCollector(v: Int) extends TypeCollector(false) {
@@ -5153,12 +5159,6 @@ A type's typeSymbol should never be inspected directly.
/** Eliminate from list of types all elements which are a subtype
* of some other element of the list. */
private def elimSub(ts: List[Type], depth: Int): List[Type] = {
- def elimAnonymousClass(t: Type) = t match {
- case TypeRef(pre, clazz, List()) if clazz.isAnonymousClass =>
- clazz.classBound.asSeenFrom(pre, clazz.owner)
- case _ =>
- t
- }
def elimSub0(ts: List[Type]): List[Type] = ts match {
case List() => List()
case t :: ts1 =>