summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2010-07-08 15:59:27 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2010-07-08 15:59:27 +0000
commit45528c7e3b392e7f4e934d264ff803527c7d79cc (patch)
treeed059c05e017ae2609a093284a7206635bda02d3 /src/compiler
parentb54e41621999d14ba52cbe40062a624e98e47066 (diff)
downloadscala-45528c7e3b392e7f4e934d264ff803527c7d79cc.tar.gz
scala-45528c7e3b392e7f4e934d264ff803527c7d79cc.tar.bz2
scala-45528c7e3b392e7f4e934d264ff803527c7d79cc.zip
closes #742.
review by extempore
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 15c5fb6c0e..9e10d3a408 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -394,9 +394,10 @@ trait Types extends reflect.generic.Types { self: SymbolTable =>
/** Replace formal type parameter symbols with actual type arguments.
*
- * Amounts to substitution except for higher-kinded types. (See overridden method in TypeRef) -- @M (contact adriaan.moors at cs.kuleuven.be)
+ * Amounts to substitution except for higher-kinded types. (See overridden method in TypeRef) -- @M
*/
- def instantiateTypeParams(formals: List[Symbol], actuals: List[Type]): Type = this.subst(formals, actuals)
+ def instantiateTypeParams(formals: List[Symbol], actuals: List[Type]): Type =
+ if(formals.length == actuals.length) this.subst(formals, actuals) else ErrorType
/** If this type is an existential, turn all existentially bound variables to type skolems.
* @param owner The owner of the created type skolems
@@ -1706,8 +1707,9 @@ A type's typeSymbol should never be inspected directly.
if (substTps.length == typeParams.length)
typeRef(pre, sym, actuals)
- else // partial application (needed in infer when bunching type arguments from classes and methods together)
+ else if(formals.length == actuals.length) // partial application (needed in infer when bunching type arguments from classes and methods together)
typeRef(pre, sym, dummyArgs).subst(formals, actuals)
+ else ErrorType
}
else
super.instantiateTypeParams(formals, actuals)
@@ -1726,21 +1728,15 @@ A type's typeSymbol should never be inspected directly.
if (sym == clazz && !args.isEmpty) args.head else this
def normalize0: Type =
- if (sym.isAliasType) { // beta-reduce
- if (sym.info.typeParams.length == args.length || !isHigherKinded) {
- /* !isHigherKinded && sym.info.typeParams.length != args.length only happens when compiling e.g.,
- `val x: Class' with -Xgenerics, while `type Class = java.lang.Class' had already been compiled without -Xgenerics */
- val xform = transform(sym.info.resultType)
- assert(xform ne this, this)
- xform.normalize // cycles have been checked in typeRef
- } else { // should rarely happen, if at all
- PolyType(sym.info.typeParams, transform(sym.info.resultType).normalize) // eta-expand -- for regularity, go through sym.info for typeParams
- // @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
- }
- } else if (isHigherKinded) {
+ if (isHigherKinded) {
// @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
// @M: initialize (by sym.info call) needed (see test/files/pos/ticket0137.scala)
PolyType(sym.info.typeParams, typeRef(pre, sym, dummyArgs)) // must go through sym.info for typeParams
+ } else if (sym.isAliasType) { // beta-reduce
+ if(sym.info.typeParams.length == args.length) // don't do partial application
+ transform(sym.info.resultType).normalize // cycles have been checked in typeRef
+ else
+ ErrorType
} else if (sym.isRefinementClass) {
sym.info.normalize // @MO to AM: OK?
//@M I think this is okay, but changeset 12414 (which fixed #1241) re-introduced another bug (#2208)