Skip to content
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

Add IsRef property to IConditionalOperation and ISimpleAssignmentOperation, add RefKind property to ILocalSymbol. #22933

Merged
merged 2 commits into from
Nov 3, 2017

Conversation

AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented Oct 31, 2017

…ation, add RefKind property to ILocalSymbol.

Closes dotnet#21311.
@AlekseyTs AlekseyTs added Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature - IOperation IOperation labels Oct 31, 2017
@AlekseyTs AlekseyTs added this to the 15.5 milestone Oct 31, 2017
@AlekseyTs AlekseyTs requested review from cston and a team October 31, 2017 17:13
@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Oct 31, 2017

@dotnet/roslyn-compiler, @dotnet/analyzer-ioperation, @mavasani, @cston Please review 15.5 IOperation fix. #Resolved

@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented Oct 31, 2017

CC @jaredpar, @gafter, @AnthonyDGreen For public API change on ILocalSymbol. #Resolved

{
AddKeyword(SyntaxKind.ReadOnlyKeyword);
AddSpace();
}
Copy link
Member

Choose a reason for hiding this comment

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

Should the SymbolDisplay change be a separate PR, perhaps post 15.5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the SymbolDisplay change be a separate PR, perhaps post 15.5?

Do you have concerns about this change? It feels low risk to me.

@@ -23,11 +23,17 @@ public interface ILocalSymbol : ISymbol
bool IsConst { get; }

/// <summary>
/// Returns true if this local is a ref-local.
/// Returns true if this local is a ref local or a ref readonly local.
/// Use <see cref="RefKind"/> to get more detailed information.
/// </summary>
bool IsRef { get; }
Copy link
Member

@tmat tmat Oct 31, 2017

Choose a reason for hiding this comment

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

Why keep this property if the same information is in RefKind? #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Oct 31, 2017

Choose a reason for hiding this comment

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

Why keep this property if the same information is in RefKind?

We already shipped it, cannot take it back. #Resolved

Copy link
Member

Choose a reason for hiding this comment

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

I see. Ok.


In reply to: 148093610 [](ancestors = 148093610)

/// <summary>
/// Is this a ref assignment
/// </summary>
bool IsRef { get; }
Copy link
Member

@tmat tmat Oct 31, 2017

Choose a reason for hiding this comment

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

bool IsRef { get; } [](start = 8, length = 19)

Why not expose RefKind property instead? #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Oct 31, 2017

Choose a reason for hiding this comment

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

Why not expose RefKind property instead?

Because the kind of the reference is irrelevant here. Even compiler doesn't capture the kind. #Resolved

Copy link
Member

Choose a reason for hiding this comment

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

OK. Thanks


In reply to: 148094214 [](ancestors = 148094214)

/// <summary>
/// Is result a managed reference
/// </summary>
bool IsRef { get; }
Copy link
Member

@tmat tmat Oct 31, 2017

Choose a reason for hiding this comment

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

bool IsRef { get; } [](start = 8, length = 19)

Expose RefKind property instead? #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Oct 31, 2017

Choose a reason for hiding this comment

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

Expose RefKind property instead?

Because the kind of the reference is irrelevant here. #Resolved

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -321,9 +321,9 @@ public object ConstantValue

internal abstract ImmutableArray<Diagnostic> GetConstantValueDiagnostics(BoundExpression boundInitValue);

public bool IsRef => RefKind == RefKind.Ref;
public bool IsRef => RefKind != RefKind.None;
Copy link
Member

@jcouv jcouv Oct 31, 2017

Choose a reason for hiding this comment

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

Consider updating some compiler tests for this. #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Oct 31, 2017

Choose a reason for hiding this comment

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

I added new tests along with symbol display. #Closed

@jcouv
Copy link
Member

jcouv commented Oct 31, 2017

            Return False

Should this be proactively updated?


Refers to: src/Compilers/VisualBasic/Portable/Symbols/Source/LocalSymbol.vb:285 in b70c08e. [](commit_id = b70c08e, deletion_comment = False)


if (operation.IsRef)
{
LogString(" (IsRef)");
Copy link
Member

@jcouv jcouv Oct 31, 2017

Choose a reason for hiding this comment

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

I didn't see which test exercises this. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see which test exercises this.

None at the moment. Only lowered tree can have nodes like this. Once ref reassignment feature is supported, then we can test this API.


In reply to: 148105993 [](ancestors = 148105993)

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 with one test suggestion.

@AlekseyTs
Copy link
Contributor Author

            Return False

VB doesn't support ref locals.


In reply to: 340882949 [](ancestors = 340882949)


Refers to: src/Compilers/VisualBasic/Portable/Symbols/Source/LocalSymbol.vb:285 in b70c08e. [](commit_id = b70c08e, deletion_comment = False)

@@ -23,11 +23,17 @@ public interface ILocalSymbol : ISymbol
bool IsConst { get; }

/// <summary>
/// Returns true if this local is a ref-local.
/// Returns true if this local is a ref local or a ref readonly local.
/// Use <see cref="RefKind"/> to get more detailed information.
/// </summary>
Copy link
Member

Choose a reason for hiding this comment

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

So, "IsRef" is true for readonly references as well.
I do not have a strong opinion on this, but we have similar API for methods/properties, should we make sure it is also "inclusive"?

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, "IsRef" is true for readonly references as well.

Yes.

I do not have a strong opinion on this, but we have similar API for methods/properties, should we make sure it is also "inclusive"?

IMethodSymbol and IPropertySymbol also have ReturnsByRefReadonly property, I'll let you decide what correlation should be between it and ReturnsByRef property. If any adjustments are needed, I think they are out of scope of this PR.

@jinujoseph
Copy link
Contributor

pre-approved to merge via link

@AlekseyTs AlekseyTs merged commit 79fc0a8 into dotnet:master Nov 3, 2017
333fred added a commit to 333fred/roslyn that referenced this pull request Nov 8, 2017
* dotnet/master: (36 commits)
  Remove usage of IOperation feature flag in newly added unit tests
  More fixes for IOperation tree. (dotnet#23028)
  Address PR feedback and remove unused resource and comment out unused error code
  Remove IOperation feature flag and internal registration APIs for operations
  Add unit test for VB
  Address review feedback and add more unit tests
  Fix unit tests
  Fix build errors from merge resolution
  Revert unintentional newline deletion
  Address recent feedback and do not generate an IParenthesizedOperation for C#. This change is now just a test-only change that verifies the current behavior.
  Address PR feedback and use singleton for null instance
  Address PR feedback
  Address PR feedback
  Do not invoke GetStandaloneNode helper in GetOperationWorker
  Fix InvalidCastException in CSharpOperationFactory for invalid nested member initializer (dotnet#22983)
  Use ICollection<string>.Contains to avoid Enumerator allocation
  Add IsRef property to IConditionalOperation and ISimpleAssignmentOperation, add RefKind property to ILocalSymbol. (dotnet#22933)
  Enable peverify-compat mode for langver < 7.2 (dotnet#22772)
  Properly detect root of a tree in Operation.SearchParentOperation (dotnet#22974)
  Fix IArgument and IArrayInitializer to have null types
  ...
333fred added a commit to 333fred/roslyn that referenced this pull request Nov 9, 2017
* dotnet/master: (28 commits)
  Fix the operation verifier code now that getoperationinternal no longer exists.
  Remove usage of IOperation feature flag in newly added unit tests
  More fixes for IOperation tree. (dotnet#23028)
  Address PR feedback and remove unused resource and comment out unused error code
  Remove IOperation feature flag and internal registration APIs for operations
  Add unit test for VB
  Address review feedback and add more unit tests
  Fix unit tests
  Fix build errors from merge resolution
  Revert unintentional newline deletion
  Address recent feedback and do not generate an IParenthesizedOperation for C#. This change is now just a test-only change that verifies the current behavior.
  Address PR feedback and use singleton for null instance
  Address PR feedback
  Address PR feedback
  Do not invoke GetStandaloneNode helper in GetOperationWorker
  Fix InvalidCastException in CSharpOperationFactory for invalid nested member initializer (dotnet#22983)
  Use ICollection<string>.Contains to avoid Enumerator allocation
  Add IsRef property to IConditionalOperation and ISimpleAssignmentOperation, add RefKind property to ILocalSymbol. (dotnet#22933)
  Enable peverify-compat mode for langver < 7.2 (dotnet#22772)
  Fix IArgument and IArrayInitializer to have null types
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved to merge Area-Compilers cla-already-signed Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature - IOperation IOperation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants