diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-09 12:36:43 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-09 12:36:43 +0200 |
commit | 0fc19e0e1ef7b56f9ca0649fde35765892cf1a53 (patch) | |
tree | d037ee483a3c89218acf35983006dd8bc4336b46 /src/dotty/tools/dotc/core/SymDenotations.scala | |
parent | 16c1ddd3bb86c61890418b8394d44486e7bbd9dd (diff) | |
download | dotty-0fc19e0e1ef7b56f9ca0649fde35765892cf1a53.tar.gz dotty-0fc19e0e1ef7b56f9ca0649fde35765892cf1a53.tar.bz2 dotty-0fc19e0e1ef7b56f9ca0649fde35765892cf1a53.zip |
Cleanup of new scheme for handling local type parameters and type members.
If a type parameter or local type member is co/contravariant, its instantiation is a special alias
type that remembers the variance. These alias types can be refined with subtypes in subclasses and
intersection and union translate to their bounds.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 8a4cdf1e5..9142e3185 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -117,7 +117,7 @@ object SymDenotations { } protected[dotc] final def info_=(tp: Type) = { - def illegal: String = s"illegal type for module $this: $tp" + def illegal: String = s"illegal type for $this: $tp" /* if (this is Module) // make sure module invariants that allow moduleClass and sourceModule to work are kept. tp match { @@ -646,7 +646,7 @@ object SymDenotations { def symRef(implicit ctx: Context): NamedType = NamedType.withSym(owner.thisType, symbol) - /** The variance of this type parameter as an Int, with + /** The variance of this type parameter or type member as an Int, with * +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter */ final def variance: Int = @@ -654,6 +654,14 @@ object SymDenotations { else if (this is Contravariant) -1 else 0 + /** If this is a privatye[this] or protected[this] type parameter or type member, + * its variance, otherwise 0. + */ + final def localVariance: Int = + if (this is LocalCovariant) 1 + else if (this is LocalContravariant) -1 + else 0 + override def toString = { val kindString = if (this is ModuleClass) "module class" |