summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-14 12:41:40 -0800
committerPaul Phillips <paulp@improving.org>2012-01-14 14:34:46 -0800
commit3024efcbf902417017b6ec0a442a3db4cf930d22 (patch)
tree1eacda2125fe6da847db5959c047ba2df86ecbdf /src/compiler/scala/reflect/internal/Types.scala
parent2ca7d4ff90fedcd2dba654100bd8d6ce1f1ad36b (diff)
downloadscala-3024efcbf902417017b6ec0a442a3db4cf930d22.tar.gz
scala-3024efcbf902417017b6ec0a442a3db4cf930d22.tar.bz2
scala-3024efcbf902417017b6ec0a442a3db4cf930d22.zip
Putting some of the symbol potential to work.
Renamed the parameter to all the newXXX symbol creators to "newFlags" because I've seen too many bugs which arose from having a parameter name which shadows a field and where mistakes can inflict subtle bugs which won't be found until much later (yes I'm trying to describe "flags" right now.) Opportunistically cleaned up some symbol creations.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 3bcd36131d..3d3dd81f1b 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -1814,13 +1814,18 @@ trait Types extends api.Types { self: SymbolTable =>
override def typeConstructor = this
// eta-expand, subtyping relies on eta-expansion of higher-kinded types
- // override protected def normalizeImpl: Type =
- // if (isHigherKinded) etaExpand else super.normalizeImpl
+
+ override protected def normalizeImpl: Type =
+ if (isHigherKinded) etaExpand else super.normalizeImpl
}
trait ClassTypeRef extends TypeRef {
// !!! There are scaladoc-created symbols arriving which violate this require.
// require(sym.isClass, sym)
+
+ override protected def normalizeImpl: Type =
+ if (sym.isRefinementClass) sym.info.normalize // I think this is okay, but see #1241 (r12414), #2208, and typedTypeConstructor in Typers
+ else super.normalizeImpl
override def baseType(clazz: Symbol): Type =
if (sym == clazz) this
@@ -1873,8 +1878,20 @@ trait Types extends api.Types { self: SymbolTable =>
override def typeSymbol = if (this ne normalize) normalize.typeSymbol else sym
// beta-reduce, but don't do partial application -- cycles have been checked in typeRef
- // override protected zzImpl =
- // if (typeParamsMatchArgs) betaReduce.normalize else ErrorType
+ override protected def normalizeImpl =
+ if (typeParamsMatchArgs) betaReduce.normalize
+ else if (isHigherKinded) super.normalizeImpl
+ else ErrorType
+
+ // isHKSubType0 introduces synthetic type params so that
+ // betaReduce can first apply sym.info to typeArgs before calling
+ // asSeenFrom. asSeenFrom then skips synthetic type params, which
+ // are used to reduce HO subtyping to first-order subtyping, but
+ // which can't be instantiated from the given prefix and class.
+ //
+ // this crashes pos/depmet_implicit_tpbetareduce.scala
+ // appliedType(sym.info, typeArgs).asSeenFrom(pre, sym.owner)
+ def betaReduce = transform(sym.info.resultType)
// #3731: return sym1 for which holds: pre bound sym.name to sym and
// pre1 now binds sym.name to sym1, conceptually exactly the same
@@ -1961,33 +1978,20 @@ trait Types extends api.Types { self: SymbolTable =>
// corresponding type parameters (unbound type variables)
def transform(tp: Type): Type
- private def normalize0: Type = (
- if (pre eq WildcardType) WildcardType // arises when argument-dependent types are approximated (see def depoly in implicits)
- else if (isHigherKinded) etaExpand // eta-expand, subtyping relies on eta-expansion of higher-kinded types
- else if (sym.isAliasType && typeParamsMatchArgs) betaReduce.normalize // beta-reduce, but don't do partial application -- cycles have been checked in typeRef
- else if (sym.isRefinementClass) sym.info.normalize // I think this is okay, but see #1241 (r12414), #2208, and typedTypeConstructor in Typers
- else if (sym.isAliasType) ErrorType //println("!!error: "+(pre, sym, sym.info, sym.info.typeParams, args))
- else super.normalize
- )
+ // eta-expand, subtyping relies on eta-expansion of higher-kinded types
+ protected def normalizeImpl: Type = if (isHigherKinded) etaExpand else super.normalize
- // TODO: test case that is compiled in a specific order and in different runs
- override def normalize: Type = {
- if (phase.erasedTypes) normalize0
+ // TODO: test case that is compiled in a specific order and in different runs
+ final override def normalize: Type = {
+ // arises when argument-dependent types are approximated (see def depoly in implicits)
+ if (pre eq WildcardType) WildcardType
+ else if (phase.erasedTypes) normalizeImpl
else {
if (normalized eq null)
- normalized = normalize0
+ normalized = normalizeImpl
normalized
}
}
- // isHKSubType0 introduces synthetic type params so that
- // betaReduce can first apply sym.info to typeArgs before calling
- // asSeenFrom. asSeenFrom then skips synthetic type params, which
- // are used to reduce HO subtyping to first-order subtyping, but
- // which can't be instantiated from the given prefix and class.
- //
- // this crashes pos/depmet_implicit_tpbetareduce.scala
- // appliedType(sym.info, typeArgs).asSeenFrom(pre, sym.owner)
- def betaReduce = transform(sym.info.resultType)
def etaExpand: Type = {
// must initialise symbol, see test/files/pos/ticket0137.scala