Skip to content

Adjust CheckedKeywordRecommender for checked user-defined operators.#60183

Merged
AlekseyTs merged 4 commits intodotnet:features/CheckedUserDefinedOperatorsfrom
AlekseyTs:CheckedUserDefinedOperators_09
Mar 17, 2022
Merged

Adjust CheckedKeywordRecommender for checked user-defined operators.#60183
AlekseyTs merged 4 commits intodotnet:features/CheckedUserDefinedOperatorsfrom
AlekseyTs:CheckedUserDefinedOperators_09

Conversation

@AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented Mar 15, 2022

Test plan #59458

@AlekseyTs AlekseyTs enabled auto-merge (squash) March 15, 2022 18:19
@AlekseyTs AlekseyTs disabled auto-merge March 15, 2022 18:26
{
if (targetToken.GetPreviousToken(includeSkipped: true).IsLastTokenOfNode<TypeSyntax>())
{
return true;
Copy link
Member

Choose a reason for hiding this comment

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

nit: consider adding comments to illustrate the situation (here and below)

Copy link
Contributor

Choose a reason for hiding this comment

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

note: i would prefer this as well. but it's not a problem to not have it.

@"ref int x = ref $$"));
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
Copy link
Member

Choose a reason for hiding this comment

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

Consider testing the recommendation in the declaration of an existing/complete operator (scenario is you copy/paste one operator, add checked, then tweak code)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 1)

@AlekseyTs
Copy link
Contributor Author

@CyrusNajmabadi Please review changes past the first commit.

@AlekseyTs
Copy link
Contributor Author

@CyrusNajmabadi Please review changes past the first commit.

@jcouv jcouv self-assigned this Mar 16, 2022
@AlekseyTs
Copy link
Contributor Author

@CyrusNajmabadi Please review changes made after the first commit.

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@CyrusNajmabadi Please review changes made after the first commit.


if (firstSpecifierToken.GetPreviousToken(includeSkipped: true).IsLastTokenOfNode<TypeSyntax>())
{
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

so 'checked' is allowed, in an explicit-impl, even without having 'explicit' in the sig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so 'checked' is allowed, in an explicit-impl, even without having 'explicit' in the sig?

An 'explicit' keyword has nothing to do with explicit interface implementation, it is part of a conversion operator declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we have a type before the specifier, this is not a conversion operator declaration

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, what i meant here is that this code checks if we're after an explicit-interface specifier, and then checks that right before that is a type-syntax. But it does not do the previousToken.Kind() == SyntaxKind.ExplicitKeyword check below. I'm trying to understand if that's ok and desirable behavior. I commented on the test that seems to be hitting this, and i was trying to understand if this is a legal language construct and what it means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A conversion operator cannot have a type between 'explicit' and 'operator', its type goes before parameters. For example:

public static explicit operator checked TypeToConvertTo(TypeToConvertFrom x) {}

{
await VerifyKeywordAsync(
@"class Goo {
public static int I1.operator $$");
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is legal from teh lang perspective? it doesn't need to be marked as 'explicit'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so this is legal from teh lang perspective? it doesn't need to be marked as 'explicit'?

If we have a type before the specifier, this is not a conversion operator declaration. The 'explicit' keyword is used only for conversion operators.

@AlekseyTs AlekseyTs merged commit 762b69b into dotnet:features/CheckedUserDefinedOperators Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants