-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implicit scope caching: bug fixes and performance improvements #1288
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be418e0
Document why we cannot cache all implicit scopes
smarter 818bf0b
Fix implicit scope caching bug
smarter 088902c
Do not miss implicits in type parameters of parents
smarter 221e5d1
Never include self types in named parts of a type
smarter 5c2a19b
OfTypeImplicits: compute refs lazily
smarter 8d0312f
Avoid creating AndTypes with Any
smarter 044d29d
Don't compute implicit scopes for synthetic Lambda traits
smarter 295c981
Overloading resolution: prefer directly applicable methods
smarter 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
trait Dummy[T] | ||
|
||
|
||
trait A[T] extends B | ||
trait B extends Dummy[A[Int]] | ||
object B { | ||
implicit def theB: B = new B {} | ||
implicit def theA: A[Int] = new A[Int] {} | ||
} | ||
|
||
object Test { | ||
def getB(implicit b: B) = b | ||
def getA[T](implicit a: A[T]) = a | ||
|
||
getB | ||
getA | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class A | ||
object A { | ||
implicit def theA: A = new A | ||
} | ||
class Foo[T] | ||
object Foo { | ||
implicit def theFoo: Foo[A] = new Foo[A] | ||
} | ||
|
||
object Test { | ||
def getFooA(implicit foo: Foo[A]) = foo | ||
def getA(implicit a: A) = a | ||
|
||
getFooA | ||
getA | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Foo[T] | ||
class Bar extends Foo[A] | ||
|
||
class A | ||
object A { | ||
implicit val bar: Bar = new Bar | ||
} | ||
|
||
object Test { | ||
def getBar(implicit bar: Bar) = bar | ||
getBar | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
C1 |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class A | ||
class B | ||
|
||
class C1 { | ||
def f(x: A): Unit = println("C1") | ||
} | ||
class C2 extends C1 { | ||
def f(x: B): Unit = println("C2") | ||
} | ||
|
||
object Test extends C2 { | ||
implicit def a2b(x: A): B = new B | ||
def main(args: Array[String]): Unit = { | ||
f(new A) | ||
} | ||
} |
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.
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.
That changes the logic of overloading resolution. With the change, we prefer methods that are applicable without implicit conversions to other methods. That's not as specced I think. What is the motivation for the change?
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.
From the commit message of 7a060ba:
The motivation for this change is that I observed that many of the implicit searches when compiling dotty were caused by overloading resolution (e.g., every call to
Int#+
will check if the argument can be converted toChar
,Short
,Double
, etc even if the argument is anInt
) It's possible that I missed a case where this does change the semantics, if so could you give an example?