-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Experiment] Drop prioritization of givens over implicits #21273
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2549aec
Update check-files and error annotations
EugeneFlesselle 59102c5
Drop prioritization of `given`s over `implicit`s
EugeneFlesselle dd57f6d
Weigh ownerScore more than type score for implicit search
odersky cd686a0
Use old prioritization for old-style implicits if new is ambiguous
odersky b7bff9a
Adapt scala-collection-compat to priority changes
odersky 43bf127
Revert PPRint changes
odersky 7895b54
Cleanup: Drop isNotGivenClass check
odersky 9348538
Use owner score over type score only ss last fallback
odersky 36a74b0
Reuse `compareAlternatives#prev` computation
EugeneFlesselle e1cc065
Drop using owner score as fallback over type score
EugeneFlesselle 39c49ad
Fix ownerscore disambiguation
odersky 1ea5485
Use "prefer owner score over type score" trick only under new resolut…
odersky 8f85da5
Fix Formatting.Show for types X | Null.
odersky 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
Submodule scala-collection-compat
updated
1 files
+4 −4 | compat/src/test/scala/test/scala/collection/BuildFromTest.scala |
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
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,28 @@ | ||
|
||
trait Foo[-T] | ||
trait Bar[-T] extends Foo[T] | ||
|
||
object Test { | ||
|
||
locally: | ||
implicit val fa: Foo[Int] = ??? | ||
implicit val ba: Bar[Int] = ??? | ||
summon[Foo[Int]] // ok | ||
|
||
locally: | ||
implicit val fa: Foo[Int] = ??? | ||
implicit val ba: Bar[Any] = ??? | ||
summon[Foo[Int]] // ok | ||
|
||
locally: | ||
given fa: Foo[Any] = ??? | ||
given ba: Bar[Int] = ??? | ||
summon[Foo[Int]] // error: now ambiguous, | ||
// was resolving to `ba` when using intermediate rules: | ||
// better means specialize, but map all type arguments downwards | ||
|
||
locally: | ||
implicit val fa: Foo[Any] = ??? | ||
implicit val ba: Bar[Int] = ??? | ||
summon[Foo[Int]] // is OK since we fall back to old rules for old-style implicits as a tie breaker | ||
} |
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,24 @@ | ||
/* These tests show various mechanisms available for implicit prioritization. | ||
*/ | ||
import language.`3.6` | ||
|
||
class A // The type for which we infer terms below | ||
class B extends A | ||
|
||
/* First, two schemes that require a pre-planned architecture for how and | ||
* where given instances are defined. | ||
* | ||
* Traditional scheme: prioritize with location in class hierarchy | ||
*/ | ||
class LowPriorityImplicits: | ||
given g1: A() | ||
|
||
object NormalImplicits extends LowPriorityImplicits: | ||
given g2: B() | ||
|
||
def test1 = | ||
import NormalImplicits.given | ||
val x = summon[A] | ||
val _: B = x | ||
val y = summon[B] | ||
val _: B = y |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1 @@ | ||
barFoo | ||
fooFoo |
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
Oops, something went wrong.
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.