Skip to content

Optimize findRef #4156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,20 @@ object Types {
case tp1 => tp1
})
case tp: TypeRef =>
tp.denot.findMember(name, pre, excluded)
tp.denot match {
case d: ClassDenotation => d.findMember(name, pre, excluded)
case d => go(d.info)
}
case tp: AppliedType =>
goApplied(tp)
case tp: ThisType =>
tp.tycon match {
case tc: TypeRef if tc.symbol.isClass =>
go(tc)
case tc: HKTypeLambda =>
goApplied(tp, tc)
case _ =>
go(tp.superType)
}
case tp: ThisType => // ??? inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment?

goThis(tp)
case tp: RefinedType =>
if (name eq tp.refinedName) goRefined(tp) else go(tp.parent)
Expand Down Expand Up @@ -598,15 +608,9 @@ object Types {
}
}

def goApplied(tp: AppliedType) = tp.tycon match {
case tl: HKTypeLambda =>
go(tl.resType).mapInfo(info =>
tl.derivedLambdaAbstraction(tl.paramNames, tl.paramInfos, info).appliedTo(tp.args))
case tc: TypeRef if tc.symbol.isClass =>
go(tc)
case _ =>
go(tp.superType)
}
def goApplied(tp: AppliedType, tycon: HKTypeLambda) =
go(tycon.resType).mapInfo(info =>
tycon.derivedLambdaAbstraction(tycon.paramNames, tycon.paramInfos, info).appliedTo(tp.args))

def goThis(tp: ThisType) = {
val d = go(tp.underlying)
Expand All @@ -623,6 +627,7 @@ object Types {
// loadClassWithPrivateInnerAndSubSelf in ShowClassTests
go(tp.cls.typeRef) orElse d
}

def goParam(tp: TypeParamRef) = {
val next = tp.underlying
ctx.typerState.constraint.entry(tp) match {
Expand All @@ -632,12 +637,14 @@ object Types {
go(next)
}
}

def goSuper(tp: SuperType) = go(tp.underlying) match {
case d: JointRefDenotation =>
typr.println(i"redirecting super.$name from $tp to ${d.symbol.showLocated}")
new UniqueRefDenotation(d.symbol, tp.memberInfo(d.symbol), d.validFor)
case d => d
}

def goAnd(l: Type, r: Type) = {
go(l) & (go(r), pre, safeIntersection = ctx.pendingMemberSearches.contains(name))
}
Expand Down