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 IOperation support for variations of object creation expressions … #20962

Merged
merged 6 commits into from
Jul 19, 2017

Conversation

mavasani
Copy link
Contributor

@mavasani mavasani commented Jul 18, 2017

…(type parameter and dynamic)

Fixes #20119 and #20491

/// <summary>
/// List of applicable symbols that are dynamically bound to the <see cref="Name"/>.
/// </summary>
ImmutableArray<ISymbol> ApplicableSymbols { get; }
Copy link
Member

Choose a reason for hiding this comment

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

Could this be ImmutableArray<IMethodSymbol>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This interface will also be implemented by BoundDynamicIndexerAccess, which has applicable property symbols.

ImmutableArray<ISymbol> applicableSymbols = StaticCast<ISymbol>.From(boundDynamicObjectCreationExpression.ApplicableMethods);
Lazy<ImmutableArray<IOperation>> arguments = new Lazy<ImmutableArray<IOperation>>(() => boundDynamicObjectCreationExpression.Arguments.SelectAsArray(n => Create(n)));
ImmutableArray<string> argumentNames = boundDynamicObjectCreationExpression.ArgumentNamesOpt.NullToEmpty();
ImmutableArray<RefKind> argumentRefKinds = boundDynamicObjectCreationExpression.ArgumentRefKindsOpt.NullToEmpty();
Copy link
Member

Choose a reason for hiding this comment

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

ArgumentNames and ArgumentRefKinds should be default rather than Empty if not set.

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 thought we need to expose non default ImmutableArray for all public APIs. @dotnet/analyzer-ioperation, what is the preference here?

Copy link
Member

Choose a reason for hiding this comment

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

We could use Empty here if we're using Empty in all other cases. In the bound tree though, these properties are either unset (default) or populated with the same number of entries as Arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed #20974 to discuss this at the design meeting and make the behavior consistent across the factory.

/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this comment was copied from the interface unnecessarily. Same for other classes here.

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 will fix the comment.

@@ -241,7 +240,7 @@ private void VisitArray<T>(IEnumerable<T> list, string header, bool logElementCo
LogString($"{header}{elementCount}:");
LogNewLine();
Indent();
VisitArray(list);
elementVisitor(list);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps elementVisitor could be Action<T> with the foreach handled here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, will refactor.

@cston
Copy link
Member

cston commented Jul 19, 2017

LGTM

}
}

internal void VisitArrayElement<T>(T operation) where T : IOperation
Copy link
Member

Choose a reason for hiding this comment

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

Is T necessary or could this be VisitArrayElement(IOperation operation)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is necessary as it is also passed as a delegate to VisitArrayCommon in the OperationTreeVerifier.

@mavasani
Copy link
Contributor Author

windows_release_vs-integration_prtest failed due to flaky test failure: #15497

@mavasani
Copy link
Contributor Author

@dotnet-bot retest windows_release_vs-integration_prtest please

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Looks good other than the random addition of nulls to conversion expressions.

@@ -1904,6 +1904,7 @@ class C2 : C1
Variables: Local_1: C1 c1
Initializer: IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: C1) (Syntax: 'new T()')
ITypeParameterObjectCreationExpression (OperationKind.TypeParameterObjectCreationExpression, Type: T) (Syntax: 'new T()')
null
Copy link
Member

Choose a reason for hiding this comment

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

What is this null from?

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 believe this is what Jinu's PR is fixing.

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.

5 participants