aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-19 04:45:24 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-19 04:48:11 +0200
commitb2dcc777e5a6a1e6d1fff89c7fa794129ad5d135 (patch)
tree2bac3a26ea6f7d62d713206687ba631c3c1cfad5 /src/dotty/tools/dotc/core/Types.scala
parent928a2a99288c3aa425654e63aea5ddc70359d4ac (diff)
downloaddotty-b2dcc777e5a6a1e6d1fff89c7fa794129ad5d135.tar.gz
dotty-b2dcc777e5a6a1e6d1fff89c7fa794129ad5d135.tar.bz2
dotty-b2dcc777e5a6a1e6d1fff89c7fa794129ad5d135.zip
Taking accessibility into account for &, |
Changed the algorithm for & (and also |) to take accessibility into account. Fixed various problems that opened up when doing this. Under -debug, new and old behavior of & are checked side-by-side and any discrepancy is noted.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 1a1789eeb..851eb1301 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -295,7 +295,7 @@ object Types {
*/
final def findDecl(name: Name, excluded: FlagSet)(implicit ctx: Context): Denotation = this match {
case tp: ClassInfo =>
- tp.decls.denotsNamed(name).filterExcluded(excluded).toDenot
+ tp.decls.denotsNamed(name).filterExcluded(excluded).toDenot(NoPrefix)
case tp: TypeProxy =>
tp.underlying.findDecl(name, excluded)
}
@@ -317,7 +317,7 @@ object Types {
case tp: RefinedType =>
val pdenot = tp.parent.findMember(name, pre, excluded)
if (name eq tp.refinedName)
- pdenot & new JointRefDenotation(NoSymbol, tp.refinedInfo.substThis(tp, pre), Period.allInRun(ctx.runId))
+ pdenot & (new JointRefDenotation(NoSymbol, tp.refinedInfo.substThis(tp, pre), Period.allInRun(ctx.runId)), pre)
else
pdenot
case tp: ThisType =>
@@ -341,9 +341,9 @@ object Types {
case tp: ClassInfo =>
tp.cls.findMember(name, pre, excluded)
case AndType(l, r) =>
- l.findMember(name, pre, excluded) & r.findMember(name, pre, excluded)
+ l.findMember(name, pre, excluded) & (r.findMember(name, pre, excluded), pre)
case OrType(l, r) =>
- (l.findMember(name, pre, excluded) | r.findMember(name, pre, excluded))(pre)
+ l.findMember(name, pre, excluded) | (r.findMember(name, pre, excluded), pre)
case NoType =>
NoDenotation
} /* !!! DEBUG ensuring { denot =>
@@ -1527,12 +1527,12 @@ object Types {
if (optSelfType.exists) optSelfType else cls.typeConstructor
def rebase(tp: Type)(implicit ctx: Context): Type =
- if (prefix eq cls.owner.thisType) tp
- else tp.substThis(cls, prefix)
+ if ((prefix eq cls.owner.thisType) || !cls.owner.isClass) tp
+ else tp.substThis(cls.owner.asClass, prefix)
def typeConstructor(implicit ctx: Context): Type =
if ((cls is PackageClass) || cls.owner.isTerm) TypeRef.withSym(prefix, cls)
- else TypeRef(prefix, cls.name).withDenot(cls.denot.asSeenFrom(prefix))
+ else TypeRef(prefix, cls.name).withDenot(cls.denot.asSeenFrom(prefix)) // this ???
// cached because baseType needs parents
private var parentsCache: List[TypeRef] = null
@@ -1584,6 +1584,7 @@ object Types {
override def & (that: Type)(implicit ctx: Context) = that match {
case that: TypeBounds => this & that
+ case that: ClassInfo => this & that.bounds
}
override def | (that: Type)(implicit ctx: Context) = that match {
@@ -1733,6 +1734,9 @@ object Types {
tp.derivedTypeBounds(this(lo), this(hi))
}
+ case tp @ ClassInfo(prefix, _, _, _, _) =>
+ tp.derivedClassInfo(this(prefix))
+
case tp @ AnnotatedType(annot, underlying) =>
tp.derivedAnnotatedType(mapOver(annot), this(underlying))