Skip to content

Change order of override error checks #9187

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 1 commit into from
Jun 22, 2020

Conversation

FabioPinheiro
Copy link
Contributor

@FabioPinheiro FabioPinheiro commented Jun 15, 2020

The error check that is not possible to override an extension/normal
methods, because it should be as declared. Should come before the check
that the override modifier is needed.

Example of what the PR is trying to improve:

trait A { def [T](t: T).m: String = "trait"}
given A { def m[T](x: T): String  = "given" }

On the code above we will have the error:

error overriding method m in trait A of type [T](t: T): String;
method m of type [T](x: T): String needs `override` modifier

Just to discover after adding the override modifier that:

error overriding method m in trait A of type [T](t: T): String;
method m of type [T](x: T): String is a normal method, cannot override an extension method

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@@ -143,6 +143,7 @@ object RefChecks {
*
* 1.1. M must have the same or stronger access privileges as O.
* 1.2. O must not be effectively final.
* 1.9.2 If M or O are extension methods, they must both be extension methods.
Copy link
Contributor Author

@FabioPinheiro FabioPinheiro Jun 15, 2020

Choose a reason for hiding this comment

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

I didn't think about if it makes sense in relation to the other checks.
Unless there are tests or those numbers (1.9.2) have some order meaning. I did not saw any expressed logic for the order.
Restrictions between the order of check should be documented.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ordering is just a notational device to align the coment and the code. We should change it to the new status.

So:

   1.9.2 --> 1.3
   1.3 --> 1.4
   1.4 --> 1.5
   1.9.1 --> 1.9

We can keep it at that since 1.5 is currently unused.

@FabioPinheiro FabioPinheiro force-pushed the override_check_order branch from 4756ac2 to d4835fa Compare June 22, 2020 14:17
@FabioPinheiro FabioPinheiro changed the title [WIP] Change order of override error checks Change order of override error checks Jun 22, 2020
@odersky odersky self-requested a review June 22, 2020 14:18
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@@ -143,6 +143,7 @@ object RefChecks {
*
* 1.1. M must have the same or stronger access privileges as O.
* 1.2. O must not be effectively final.
* 1.9.2 If M or O are extension methods, they must both be extension methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

The ordering is just a notational device to align the coment and the code. We should change it to the new status.

So:

   1.9.2 --> 1.3
   1.3 --> 1.4
   1.4 --> 1.5
   1.9.1 --> 1.9

We can keep it at that since 1.5 is currently unused.

@@ -143,6 +143,8 @@ object RefChecks {
*
* 1.1. M must have the same or stronger access privileges as O.
* 1.2. O must not be effectively final.
* 1.9.2 If M or O are extension methods, they must both be extension methods.
* (Should be before the check for the need of `override` modifier.)
* 1.3. O is deferred, or M has `override` modifier.
* 1.4. If O is stable, then so is M.
* // @M: LIFTED 1.5. Neither M nor O are a parameterized type alias
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment is out of date, can be dropped.

The error check that is not possible to override an extension/normal
methods, because it should be as declared. Shound come before the check
that the `override` modifier is needed.
Add test case for this: 'override-extension_normal-methods'
@FabioPinheiro FabioPinheiro force-pushed the override_check_order branch from d4835fa to 6beb516 Compare June 22, 2020 14:46
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Thanks for the quick update!

@odersky odersky merged commit f000afe into scala:master Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants