-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Optimize findRef #4156
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
@@ -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) | ||
|
@@ -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 { | ||
|
@@ -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)) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this code match twice against
WildcardType
? I don't get it. In fact, the latter matches appear to be erased away:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It first matches against the object
WildcardType
, then the case below matches against any instance of the classWildcardType
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sorry, Allan explained me what's going on. But do we really know that the only instance of
WildcardType(NoType)
is theWildcardType
object?