Skip to content

Denotation#matches: avoid now-unnecessary slow path #9148

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 1 commit into from
Jun 9, 2020
Merged
Changes from all commits
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
11 changes: 3 additions & 8 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -972,20 +972,15 @@ object Denotations {
final def matches(other: SingleDenotation)(implicit ctx: Context): Boolean =
val d = signature.matchDegree(other.signature)

/** Slower check used if the signatures alone do not tell us enough to be sure about matching */
def slowCheck = info.matches(other.info)

d match
case FullMatch =>
if infoOrCompleter.isInstanceOf[PolyType] || other.infoOrCompleter.isInstanceOf[PolyType] then
slowCheck
else
true
true
case MethodNotAMethodMatch =>
// Java allows defining both a field and a zero-parameter method with the same name
!ctx.erasedTypes && !(symbol.is(JavaDefined) && other.symbol.is(JavaDefined))
case ParamMatch =>
!ctx.erasedTypes && slowCheck
// The signatures do not tell us enough to be sure about matching
!ctx.erasedTypes && info.matches(other.info)
case noMatch =>
false
end matches
Expand Down