diff options
author | Martin Odersky <odersky@gmail.com> | 2013-11-15 10:21:13 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-11-15 10:21:13 +0100 |
commit | 73ee6c8ab79f13d80899beacd3f0d16814ffb2db (patch) | |
tree | e42929543abb57ba49dab1d85dbc1cbf25a02d3f /src | |
parent | 157b9970ca99f2bbf080a96896a7c931d1c6ea1a (diff) | |
download | dotty-73ee6c8ab79f13d80899beacd3f0d16814ffb2db.tar.gz dotty-73ee6c8ab79f13d80899beacd3f0d16814ffb2db.tar.bz2 dotty-73ee6c8ab79f13d80899beacd3f0d16814ffb2db.zip |
Made stripTypeVar idempotent
The unstated assumption everywhere was that stripTypeVar would get rid of TypeVars. But it didn't if we had a TypeVar isntantiated to a TypeVar. Now it follows through chains of TypeVars.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index a230e9bbd..2cb14bf8f 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2047,15 +2047,20 @@ object Types { } } + /** Unwrap to instance (if instantiated) or origin (if not), until result + * is no longer a TypeVar + */ + override def stripTypeVar(implicit ctx: Context): Type = { // todo: what about multiple instantiations? + val inst = instanceOpt + if (inst.exists) inst.stripTypeVar else origin + } + /** If the variable is instantiated, its instance, otherwise its origin */ - override def stripTypeVar(implicit ctx: Context) = { // todo: what about multiple instantiations? + override def underlying(implicit ctx: Context): Type = { val inst = instanceOpt if (inst.exists) inst else origin } - /** Same as `stripTypeVar` */ - override def underlying(implicit ctx: Context): Type = stripTypeVar - override def hashCode: Int = System.identityHashCode(this) override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] |