aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-10 11:37:30 +0200
committerMartin Odersky <odersky@gmail.com>2014-07-17 11:02:01 +0200
commit8d41e9dcee916e2fa4c7f096eb491d38e1185c1c (patch)
tree4afece7763a8cd157974a4ff7158fef438327fd7 /src
parent8b1e58ffb847706cada8fc5834c5ac6bcfcd8421 (diff)
downloaddotty-8d41e9dcee916e2fa4c7f096eb491d38e1185c1c.tar.gz
dotty-8d41e9dcee916e2fa4c7f096eb491d38e1185c1c.tar.bz2
dotty-8d41e9dcee916e2fa4c7f096eb491d38e1185c1c.zip
Make TypeParamCreation flags depend on owner
Type params should have different flags, depending on whether they are owned by a method or a class. Only class type parameters are marked Deferred, protected, and Local.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala2
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala4
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala7
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala2
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala2
6 files changed, 13 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 5e335e240..d04a26883 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -37,7 +37,7 @@ class Definitions {
scope.enter(newSymbol(cls, name, flags, TypeBounds.empty))
private def newTypeParam(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope) =
- newTypeField(cls, name, flags | TypeParamCreationFlags, scope)
+ newTypeField(cls, name, flags | ClassTypeParamCreationFlags, scope)
private def newSyntheticTypeParam(cls: ClassSymbol, scope: MutableScope, paramFlags: FlagSet, suffix: String = "T0") =
newTypeParam(cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index b68e7dc42..c467a553f 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -452,8 +452,8 @@ object Flags {
/** The flags of the self symbol */
final val SelfSymFlags = Private | Local | Deferred
- /** The flags of a type parameter */
- final val TypeParamCreationFlags = TypeParam | Deferred | Protected | Local
+ /** The flags of a class type parameter */
+ final def ClassTypeParamCreationFlags = TypeParam | Deferred | Protected | Local
/** Flags that can apply to both a module val and a module class, except those that
* are added at creation anyway
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index f55817505..7d1948784 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -828,6 +828,11 @@ object SymDenotations {
else if (this is Contravariant) -1
else 0
+ /** The flags to be used for a type parameter owned by this symbol.
+ * Overridden by ClassDenotation.
+ */
+ def typeParamCreationFlags: FlagSet = TypeParam
+
override def toString = {
val kindString =
if (myFlags is ModuleClass) "module class"
@@ -1080,6 +1085,8 @@ object SymDenotations {
(symbol eq defn.NothingClass) ||
(symbol eq defn.NullClass) && (base ne defn.NothingClass))
+ final override def typeParamCreationFlags = ClassTypeParamCreationFlags
+
private[this] var myMemberFingerPrint: FingerPrint = FingerPrint.unknown
private def computeMemberFingerPrint(implicit ctx: Context): FingerPrint = {
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala
index 9d60c9985..ab083a128 100644
--- a/src/dotty/tools/dotc/core/Symbols.scala
+++ b/src/dotty/tools/dotc/core/Symbols.scala
@@ -251,7 +251,7 @@ trait Symbols { this: Context =>
val tparams = tparamBuf.toList
val bounds = boundsFn(trefBuf.toList)
for ((name, tparam, bound) <- (names, tparams, bounds).zipped)
- tparam.denot = SymDenotation(tparam, owner, name, flags | TypeParamCreationFlags, bound)
+ tparam.denot = SymDenotation(tparam, owner, name, flags | owner.typeParamCreationFlags, bound)
tparams
}
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index f2b81072a..59658c9c1 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -353,7 +353,7 @@ class ClassfileParser(
val tpname = subName(':'.==).toTypeName
val expname = if (owner.isClass) tpname.expandedName(owner) else tpname
val s = ctx.newSymbol(
- owner, expname, Flags.TypeParamCreationFlags,
+ owner, expname, owner.typeParamCreationFlags,
typeParamCompleter(index), coord = indexCoord(index))
if (owner.isClass) owner.asClass.enter(s, owner.decls)
tparams = tparams + (tpname -> s)
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 5b41d1382..36b2c99bf 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -453,7 +453,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
var flags1 = flags
if (flags is TypeParam) {
name1 = name1.expandedName(owner)
- flags1 |= TypeParamCreationFlags | ExpandedName
+ flags1 |= owner.typeParamCreationFlags | ExpandedName
}
ctx.newSymbol(owner, name1, flags1, localMemberUnpickler, coord = start)
case CLASSsym =>