-
Notifications
You must be signed in to change notification settings - Fork 3.1k
SI-7629 Deprecate view bounds #2909
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
Conversation
Todo:
|
|
I think this commit would use a non-empty description. |
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.
def f[A, B](a: A)(implicit ev: A => B)?
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.
Mhh, good question.
Then it would have to look like f[B, A <% B](a: A) --> f: [B, A](a: A)(implicit ev: A => B).
Maybe one should pick an actual existing bound as an example instead ...
|
@xeno-by Updated. |
|
@soc Looks like the proposed fix in the error message still lacks a type parameter :) |
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.
The message is missing whitespace. This should be tested in neg test with -Xfatal-warnings.
IntelliJ still incorrectly flags mixing implicit parameter lists and implicit bounds, we should get that fixed before we start instructing people to do this. http://youtrack.jetbrains.com/issue/SCL-3487
|
Weird ... I wonder whether I messed something up. The tests are gone completely. I'll redo this commit again. Sorry guys! |
|
Ok, extremely weird. I can't get the tests to fail in partest, the compiler doesn't emit the warnings. Did anything change recently in regard to partest? |
|
Not sure what you mean by "doesn't emit the warnings." I tried your branch and it WFM. I'll try to PR to the PR, but if I fail, I suggest this version of the warning or similar: where the change is to use the bounds in the example and use platform newline. I will also suggest .flags with -deprecation with updated checks, or fix the test, or if testing a deprecated feature, deprecate the |
|
Thanks @som-snytt. I have added tests locally to test/files/neg, but the issue is that they don't fail as expected. I'm starting to wonder whether partest somehow decided to pick the last stable Scala build instead of the one built from the source. |
|
Of course, by fail as expected, you mean succeed by failing (as expected). If these two tests emit deprecations, then any neg test will, too, right? I'll try it, since it's set up. Meanwhile, I'm not sure about the sample value param list; I considered an ellipsis instead: |
|
Yes, to confirm, just copying over iterator-from to neg with -Xfatal-warnings and -deprecation will fail (i.e. correctly). I did notice it has an inline warning filter; remember warnings are only emitted once for a location, so a test could theoretically emit inline warning (for instance), have it filtered by partest, but then because you were really interested in an another warning you expected at the same position, you wind up confused. I don't know yet if that happened here, but it's a big caveat. |
|
To run partest from the command line as it will be done in the test suite: If the test fails spuriously under -optimize, you can use a |
|
Isn't that cheating? If you lose patience with it, just add |
|
I'm not sure whether / how |
|
Ok, found my stupid mistake (if I want to test the deprecation of @som-snytt I adopted some of your wording because it is better. I think if you managed to get something working which would be robust for all inputs, e. g. |
|
Review by @gkossakowski, please. |
|
@gkossakowski Thanks for the notice! @retronym, could you have a look? |
|
PLS REBUILD/pr-scala@801866c |
|
(kitty-note-to-self: ignore 24949656) |
|
I'm still in two minds about merging this without giving a more specific instruction about how to fix it. One task that is definitely still needed is a commit that migrates usages of view bounds in our codebase to implicit parameters. |
|
Yep. This is exactly what this commit is about. There already exists IDE code for both a quick fix and a refactoring. That code depends on getting a warning from the compiler to trigger properly. This is what this commit enables:
|
|
How about you in the first step you make it deprecated with |
This introduces a warning(/error with -Xfuture) with a general migration advice. The IDE can use the warning to offer a quick fix with the specific refactoring necessary.
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.
"Use a context bound or an implicit parameter instead." --> wish we could link directly to an html-version of the spec here
|
I'm happy for this to go in under |
SI-7629 Deprecate view bounds
As they're deprecated (scala/scala#2909). Most of that section describes the common alternative to view bounds, though, so that probably deserves to remain in the FAQ
Fixes scala/bug#10719 scala#2909 deprecated view bounds under -Xfuture. This deprecates it without it, and drops it under -Xsource:2.14.

This introduces a warning(/error with -Xfuture) with a general
migration advice. The IDE can use the warning to offer a quick fix
with the specific refactoring necessary.