summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Definitions.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-13 09:34:03 -0800
committerPaul Phillips <paulp@improving.org>2012-02-13 16:06:36 -0800
commit92fc4e351300e927ae1a8b0a6c383d00e3968c5d (patch)
tree3ff2366a45c04ad15013479995e34f3e5e43f7c0 /src/compiler/scala/reflect/internal/Definitions.scala
parent6548dcf12d83e327df2f90048140fb95346b7e95 (diff)
downloadscala-92fc4e351300e927ae1a8b0a6c383d00e3968c5d.tar.gz
scala-92fc4e351300e927ae1a8b0a6c383d00e3968c5d.tar.bz2
scala-92fc4e351300e927ae1a8b0a6c383d00e3968c5d.zip
Existential printing, plus more compiler testing infrastructure.
Direct compiler internals testing. It's really easy, you should probably use it about 1000 times each. Look at the test: run/existentials-in-compiler.scala The checkfile contains the (string representations of the) actual existentials from the compiler to make sure they correspond properly to the ones in the source. Existentials were being printed with wildcards too freely; this has been tightened up.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Definitions.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index e05ac1087b..5b2c61701d 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -586,14 +586,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
case _ => NoType
}
- /** To avoid unchecked warnings on polymorphic classes, translate
- * a Foo[T] into a Foo[_] for use in the pattern matcher.
- */
- def typeCaseType(clazz: Symbol) = clazz.tpe.normalize match {
- case TypeRef(_, sym, args) if args.nonEmpty => newExistentialType(sym.typeParams, clazz.tpe)
- case tp => tp
- }
-
def seqType(arg: Type) = appliedType(SeqClass.typeConstructor, List(arg))
def arrayType(arg: Type) = appliedType(ArrayClass.typeConstructor, List(arg))
def byNameType(arg: Type) = appliedType(ByNameParamClass.typeConstructor, List(arg))
@@ -609,6 +601,26 @@ trait Definitions extends reflect.api.StandardDefinitions {
def vmClassType(arg: Type): Type = ClassType(arg)
def vmSignature(sym: Symbol, info: Type): String = signature(info) // !!!
+ /** Given a class symbol C with type parameters T1, T2, ... Tn
+ * which have upper/lower bounds LB1/UB1, LB1/UB2, ..., LBn/UBn,
+ * returns an existential type of the form
+ *
+ * C[E1, ..., En] forSome { E1 >: LB1 <: UB1 ... en >: LBn <: UBn }.
+ */
+ def classExistentialType(clazz: Symbol): Type =
+ newExistentialType(clazz.typeParams, clazz.tpe)
+
+ /** Given type U, creates a Type representing Class[_ <: U].
+ */
+ def boundedClassType(upperBound: Type) =
+ appliedTypeAsUpperBounds(ClassClass.typeConstructor, List(upperBound))
+
+ /** To avoid unchecked warnings on polymorphic classes, translate
+ * a Foo[T] into a Foo[_] for use in the pattern matcher.
+ */
+ @deprecated("Use classExistentialType", "2.10.0")
+ def typeCaseType(clazz: Symbol): Type = classExistentialType(clazz)
+
//
// .NET backend
//