-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix comment in isAsSpecificValue type and add test #4329
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
object Test extends App { | ||
|
||
// toplevel contra | ||
implicit def f: String => String = x => "f" | ||
implicit def g: Object => String = x => "g" | ||
def h(implicit x: String => String) = x("") | ||
assert(h == "f", h) | ||
|
||
// nested contra | ||
implicit def fs: List[String => String] = List(f) | ||
implicit def gs: List[Object => String] = List(g) | ||
def hs(implicit xs: List[String => String]) = xs.head("") | ||
assert(hs == "f", hs) | ||
|
||
// covariant subapplication nested in toplevel contra | ||
implicit def f2: (Unit => String) => String = x => "f2" | ||
implicit def g2: (Unit => Object) => String = x => "g2" | ||
def h2(implicit x: (Unit => String) => String) = x(_ => "") | ||
assert(h2 == "f2", h2) | ||
|
||
// covariant subapplication nested in nested contra | ||
implicit def fs2: List[(Unit => String) => String] = List(f2) | ||
implicit def gs2: List[(Unit => Object) => String] = List(g2) | ||
def hs2(implicit xs: List[(Unit => String) => String]) = xs.head(_ => "") | ||
assert(hs2 == "f2", hs2) | ||
} |
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.
Is this PR just about changing comments or also about changing behavior?
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.
Is the dropping of "top-level" intentional? I'm not sure I see that change reflected in the code.
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.
@smarter @milessabin The PR essentially adapts the comment to what the code now does. Dropping the
TypeBounds
case should have no effect except for wildcard arguments. When we still used refinements for type parameters it did have the effect of restricting to top-level. But with the change to direct parameter encoding that effect was lost, so that change caused a change in behavior.I am actually quite unsure what the right behavior would be. Toplevel or not? What does toplevel mean, precisely? I don't have a good testcase that would demonstrate why restricting to toplevel is important. So I opted for the solution that's simpler to specify.