aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-04-06 10:51:17 +0200
committerMartin Odersky <odersky@gmail.com>2015-04-07 23:53:58 +0200
commit0f4111cb798960cbbe642633b623f9c5ce7e2d01 (patch)
tree49cddb82e13914fe4051f78283da4689e5afb1ac /src/dotty/tools/dotc/core/Types.scala
parent300fad54d986d6e654961cf703fc9a8f5d8b3233 (diff)
downloaddotty-0f4111cb798960cbbe642633b623f9c5ce7e2d01.tar.gz
dotty-0f4111cb798960cbbe642633b623f9c5ce7e2d01.tar.bz2
dotty-0f4111cb798960cbbe642633b623f9c5ce7e2d01.zip
Allow change of symbols in WithFixedSym#newLikeThis
The symbol might be overridden, in which case the overriding symbol should be chosen. This was observered when trying to pickle test all of ast. Compiling Trees and untpd together gave discrepancies involving `untpd.dotty$tools$dotc$ast$Trees$$Instance$$T`. It was found that the symbol referred to by that type refers to the abstract type in Trees.Instance, not the alias in untpd. The bad type was produced by an asSeenFrom of the `WithFixedSym` type `Instance.this.untpd.dotty$tools$dotc$ast$Trees$$Instance$$T` as seen from `untpd`. The as seen from did not pick the new instance in `untpd`.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index ea4101558..9d692f39f 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1506,8 +1506,11 @@ object Types {
override def withSym(sym: Symbol, signature: Signature)(implicit ctx: Context): ThisType =
unsupported("withSym")
- override def newLikeThis(prefix: Type)(implicit ctx: Context): NamedType =
- NamedType.withFixedSym(prefix, fixedSym)
+ override def newLikeThis(prefix: Type)(implicit ctx: Context): NamedType = {
+ var newSym = prefix.member(fixedSym.name).symbol
+ if (!newSym.exists) newSym = fixedSym
+ NamedType.withFixedSym(prefix, newSym)
+ }
override def equals(that: Any) = that match {
case that: WithFixedSym => this.prefix == that.prefix && (this.fixedSym eq that.fixedSym)