8000 Optimizations in Namer and Typer by retronym · Pull Request #5875 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Optimizations in Namer and Typer #5875

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 12 commits into from
May 25, 2017
Prev Previous commit
Next Next commit
Avoid findMember in early implicit candidate filtering.
We're only interested in whether or not a candidate implicit
type has a member with a given name, which we can determine
cheaply by checking if any ancestor has a so-named decl.

We avoid both the as-seen-froms that FindMember uses to
differentiate overriding and overloading, and creation of
overloaded symbols.
  • Loading branch information
retronym committed May 23, 2017
commit 78713a9e4cc2e3ee94ecd114fdf69a6e13656dc1
5 changes: 4 additions & 1 deletion src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,12 @@ trait Implicits {
// We can only rule out a subtype relationship if the left hand
// side is a class, else we may not know enough.
case tr1 @ TypeRef(_, sym1, _) if sym1.isClass =>
def hasMember(tp: Type, name: Name) = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we narrow this helper method's scope a bit? typeRefHasNoMember? I fear a future refactoring could pull this out and miss that it's only valid under certain assumptions.

tp.baseClasses.exists(_.info.decls.lookupEntry(name) != null)
}
tp2.dealiasWiden match {
case TypeRef(_, sym2, _) => ((sym1 eq ByNameParamClass) != (sym2 eq ByNameParamClass)) || (sym2.isClass && !(sym1 isWeakSubClass sym2))
case RefinedType(parents, decls) => decls.nonEmpty && tr1.member(decls.head.name) == NoSymbol
case RefinedType(parents, decls) => decls.nonEmpty && !hasMember(tr1, decls.head.name) // opt avoid full call to .member
case _ => false
}
case _ => false
Expand Down
0