Skip to content

Commit

Permalink
Merge remote-tracking branch 'dotnet/features/ioperation' into ilabel…
Browse files Browse the repository at this point in the history
…statement-refactor

* dotnet/features/ioperation: (71 commits)
  Rename parameters.
  renamed methods.
  Rename method.
  Move integration test machines to 15.3 RTM (dotnet#21535)
  Update comment
  Fixed unintentional capitalization change, corrected grammar.
  Do a better job with leading trivia on types when moving types to a new file.
  Remove Release subdir from template output path (dotnet#21482)
  Fix bug in 'this' optimization for classes (dotnet#21510)
  Add test.
  Improve find-refs behavior when the user invokes it with a symbol selected.
  Fix regression in VB attribute classification.
  Fixed unintentional capitalization change.
  fix merge issues
  OSS sign debugger binaries. (dotnet#21468)
  More test fixes.
  Fixed misgenerated tests.
  Use default tuple fields in conversion since fields from inferred names are marked not usable in C#7
  Add note that while we could implement dynamic invocations, we chose not to
  Refactor comments in local function binder
  ...
  • Loading branch information
333fred committed Aug 17, 2017
2 parents eadeba8 + 0af5c44 commit 443d458
Show file tree
Hide file tree
Showing 147 changed files with 3,690 additions and 690 deletions.
5 changes: 3 additions & 2 deletions build/Targets/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<EnvDTEVersion>8.0.1</EnvDTEVersion>
<EnvDTE80Version>8.0.0</EnvDTE80Version>
<FakeSignVersion>0.9.2</FakeSignVersion>
<GitLinkVersion>3.0.0-unstable0090</GitLinkVersion>
<GitLinkVersion>3.0.0</GitLinkVersion>
<LibGit2SharpVersion>0.22.0</LibGit2SharpVersion>
<MicroBuildCoreVersion>0.2.0</MicroBuildCoreVersion>
<MicroBuildCoreSentinelVersion>1.0.0</MicroBuildCoreSentinelVersion>
Expand Down Expand Up @@ -106,6 +106,7 @@
<MicrosoftVisualStudioShellInterop121DesignTimeVersion>12.1.30328</MicrosoftVisualStudioShellInterop121DesignTimeVersion>
<MicrosoftVisualStudioShellInterop140DesignTimeVersion>14.3.25407</MicrosoftVisualStudioShellInterop140DesignTimeVersion>
<MicrosoftVisualStudioShellInterop150DesignTimeVersion>15.0.26606-alpha</MicrosoftVisualStudioShellInterop150DesignTimeVersion>
<MicrosoftVisualStudioShellInterop153DesignTimeVersion>15.0.26606</MicrosoftVisualStudioShellInterop153DesignTimeVersion>
<MicrosoftVisualStudioShellInterop80Version>8.0.50727</MicrosoftVisualStudioShellInterop80Version>
<MicrosoftVisualStudioShellInterop90Version>9.0.30729</MicrosoftVisualStudioShellInterop90Version>
<MicrosoftVisualStudioTelemetryVersion>15.0.26606-alpha</MicrosoftVisualStudioTelemetryVersion>
Expand Down Expand Up @@ -231,4 +232,4 @@
<xunitrunnerwpfVersion>1.0.41</xunitrunnerwpfVersion>
</PropertyGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion build/config/SignToolData.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"Vsix\\VisualStudioSetup.Next\\Roslyn.VisualStudio.Setup.Next.vsix",
"Vsix\\VisualStudioSetup\\Roslyn.VisualStudio.Setup.vsix",
"Vsix\\Roslyn\\RoslynDeployment.vsix",
"Vsix\\Templates\\Roslyn Templates\\Release\\Roslyn SDK.vsix"
"Vsix\\Templates\\Roslyn SDK.vsix"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/run_perf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Invoke-WebRequest -Uri http://dotnetci.blob.core.windows.net/roslyn-perf/cpc.zip
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
[IO.Compression.ZipFile]::ExtractToDirectory('cpc.zip', $CPCLocation)

./build/scripts/cibuild.ps1 -release -testPerfRun
./build/scripts/cibuild.cmd -release -testPerfRun

if ( -not $? )
{
Expand Down
2 changes: 1 addition & 1 deletion netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ commitPullList.each { isPr ->

def triggerPhraseOnly = false
def triggerPhraseExtra = ""
Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-dev15-3-preview7')
Utilities.setMachineAffinity(myJob, 'Windows_NT', 'latest-dev15-3')
Utilities.addXUnitDotNETResults(myJob, '**/xUnitResults/*.xml')
addRoslynJob(myJob, jobName, branchName, isPr, triggerPhraseExtra, triggerPhraseOnly)
}
Expand Down
49 changes: 37 additions & 12 deletions src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,14 @@ private BoundExpression BindLocalFunctionInvocationWithDynamicArgument(
CSharpSyntaxNode queryClause,
MethodGroupResolution resolution)
{
// Invocations of local functions with dynamic arguments
// don't need to be dispatched as dynamic invocations
// since they cannot be overloaded. Instead, we'll just
// emit a standard call with dynamic implicit conversions
// for any dynamic arguments. The one exception is params
// arguments which cannot be targeted by dynamic arguments
// because there is an ambiguity between an array target
// and the params element target. See
// https://github.com/dotnet/roslyn/issues/10708
// Invocations of local functions with dynamic arguments don't need
// to be dispatched as dynamic invocations since they cannot be
// overloaded. Instead, we'll just emit a standard call with
// dynamic implicit conversions for any dynamic arguments. There
// are two exceptions: "params", and unconstructed generics. While
// implementing those cases with dynamic invocations is possible,
// we have decided the implementation complexity is not worth it.
// Refer to the comments below for the exact semantics.

Debug.Assert(resolution.IsLocalFunctionInvocation);
Debug.Assert(resolution.OverloadResolutionResult.Succeeded);
Expand All @@ -650,9 +649,10 @@ private BoundExpression BindLocalFunctionInvocationWithDynamicArgument(
var methodResult = validResult.Result;

// We're only in trouble if a dynamic argument is passed to the
// params parameter and is ambiguous at compile time between
// normal and expanded form i.e., there is exactly one dynamic
// argument to a params parameter
// params parameter and is ambiguous at compile time between normal
// and expanded form i.e., there is exactly one dynamic argument to
// a params parameter
// See https://github.com/dotnet/roslyn/issues/10708
if (OverloadResolution.IsValidParams(localFunction) &&
methodResult.Kind == MemberResolutionKind.ApplicableInNormalForm)
{
Expand Down Expand Up @@ -682,6 +682,31 @@ private BoundExpression BindLocalFunctionInvocationWithDynamicArgument(
}
}

// If we call an unconstructed generic local function with a
// dynamic argument in a place where it influences the type
// parameters, we need to dynamically dispatch the call (as the
// function must be constructed at runtime). We cannot do that, so
// disallow that. However, doing a specific analysis of each
// argument and its corresponding parameter to check if it's
// generic (and allow dynamic in non-generic parameters) may break
// overload resolution in the future, if we ever allow overloaded
// local functions. So, just disallow any mixing of dynamic and
// inferred generics. (Explicit generic arguments are fine)
// See https://github.com/dotnet/roslyn/issues/21317
if (boundMethodGroup.TypeArgumentsOpt.IsDefaultOrEmpty && localFunction.IsGenericMethod)
{
Error(diagnostics,
ErrorCode.ERR_DynamicLocalFunctionTypeParameter,
syntax, localFunction.Name);
return BindDynamicInvocation(
syntax,
boundMethodGroup,
resolution.AnalyzedArguments,
resolution.OverloadResolutionResult.GetAllApplicableMembers(),
diagnostics,
queryClause);
}

return BindInvocationExpressionContinued(
node: syntax,
expression: expression,
Expand Down
9 changes: 9 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -5111,4 +5111,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="IConversionExpressionIsNotCSharpConversion" xml:space="preserve">
<value>{0} is not a valid C# conversion expression</value>
</data>
<data name="ERR_DynamicLocalFunctionTypeParameter" xml:space="preserve">
<value>Cannot pass argument with dynamic type to generic local function '{0}' with inferred type arguments.</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ internal enum ErrorCode
#region diagnostics introduced for C# 7.2
ERR_FeatureNotAvailableInVersion7_2 = 8320,
WRN_UnreferencedLocalFunction = 8321,
ERR_DynamicLocalFunctionTypeParameter = 8322,
#endregion diagnostics introduced for C# 7.2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,13 @@ private void InlineThisOnlyEnvironments()
}
else
{
// Class-based 'this' closures can move member functions
// to the top-level type and environments which capture
// the 'this' environment can capture 'this' directly
// Class-based 'this' closures can move member functions to
// the top-level type and environments which capture the 'this'
// environment can capture 'this' directly.
// Note: the top-level type is treated as the initial containing
// environment, so by removing the 'this' environment, all
// nested environments which captured a pointer to the 'this'
// environment will now capture 'this'
RemoveEnv();
VisitClosures(ScopeTree, (scope, closure) =>
{
Expand All @@ -257,35 +261,6 @@ private void InlineThisOnlyEnvironments()
closure.ContainingEnvironmentOpt = null;
}
});

// Find all environments in the scope below that could
// capture the parent. If there are any, add 'this' to
// the list of captured variables and remove the parent
// link
VisitFirstLevelScopes(ScopeTree);
void VisitFirstLevelScopes(Scope scope)
{
var classEnvs = scope.DeclaredEnvironments.Where(e => !e.IsStruct);
if (classEnvs.IsEmpty())
{
// Keep looking for nested environments
foreach (var nested in scope.NestedScopes)
{
VisitFirstLevelScopes(nested);
}
}
else
{
foreach (var declEnv in classEnvs)
{
if (declEnv.CapturesParent)
{
declEnv.CapturedVariables.Insert(0, thisParam);
declEnv.CapturesParent = false;
}
}
}
}
}

void RemoveEnv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ private LambdaRewriter(
_assignLocals = assignLocals;
_currentTypeParameters = method.TypeParameters;
_currentLambdaBodyTypeMap = TypeMap.Empty;
_innermostFramePointer = null;
_currentFrameThis = thisParameterOpt;
_innermostFramePointer = _currentFrameThis = thisParameterOpt;
_framePointers[thisType] = thisParameterOpt;
_seenBaseCall = method.MethodKind != MethodKind.Constructor; // only used for ctors
_synthesizedFieldNameIdDispenser = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,8 @@ private BoundExpression RewriteTupleConversion(

for (int i = 0; i < numElements; i++)
{
var field = srcElementFields[i];

DiagnosticInfo useSiteInfo = field.GetUseSiteDiagnostic();
if ((object)useSiteInfo != null && useSiteInfo.Severity == DiagnosticSeverity.Error)
{
Symbol.ReportUseSiteDiagnostic(useSiteInfo, _diagnostics, syntax.Location);
}
var fieldAccess = MakeTupleFieldAccess(syntax, field, savedTuple, null, LookupResultKind.Empty);
var fieldAccess = MakeTupleFieldAccessAndReportUseSiteDiagnostics(savedTuple, syntax, srcElementFields[i]);
var convertedFieldAccess = MakeConversionNode(syntax, fieldAccess, elementConversions[i], destElementTypes[i], @checked, explicitCastInCode);

fieldAccessorsBuilder.Add(convertedFieldAccess);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,7 @@ private ImmutableArray<BoundExpression> AccessTupleFields(BoundExpression expres
var builder = ArrayBuilder<BoundExpression>.GetInstance(numElements);
for (int i = 0; i < numElements; i++)
{
var field = fields[i];

// Use default field rather than implicitly named fields since
// fields from inferred names are not usable in C# 7.0.
field = field.CorrespondingTupleField ?? field;

DiagnosticInfo useSiteInfo = field.GetUseSiteDiagnostic();
if ((object)useSiteInfo != null && useSiteInfo.Severity == DiagnosticSeverity.Error)
{
Symbol.ReportUseSiteDiagnostic(useSiteInfo, _diagnostics, expression.Syntax.Location);
}
var fieldAccess = MakeTupleFieldAccess(expression.Syntax, field, tuple, null, LookupResultKind.Empty);
var fieldAccess = MakeTupleFieldAccessAndReportUseSiteDiagnostics(tuple, expression.Syntax, fields[i]);
builder.Add(fieldAccess);
}
return builder.ToImmutableAndFree();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.CSharp.Symbols;
using System.Diagnostics;

namespace Microsoft.CodeAnalysis.CSharp
{
Expand Down Expand Up @@ -90,5 +89,20 @@ private BoundExpression MakeTupleFieldAccess(
// make a field access for the most local access
return _factory.Field(rewrittenReceiver, underlyingField);
}

private BoundExpression MakeTupleFieldAccessAndReportUseSiteDiagnostics(BoundExpression tuple, SyntaxNode syntax, FieldSymbol field)
{
// Use default field rather than implicitly named fields since
// fields from inferred names are not usable in C# 7.0.
field = field.CorrespondingTupleField ?? field;

DiagnosticInfo useSiteInfo = field.GetUseSiteDiagnostic();
if ((object)useSiteInfo != null && useSiteInfo.Severity == DiagnosticSeverity.Error)
{
Symbol.ReportUseSiteDiagnostic(useSiteInfo, _diagnostics, syntax.Location);
}

return MakeTupleFieldAccess(syntax, field, tuple, null, LookupResultKind.Empty);
}
}
}
22 changes: 11 additions & 11 deletions src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,23 +635,23 @@ private IOperation CreateUnboundLambdaOperation(UnboundLambda unboundLambda)
// We are counting on the fact that will do the error recovery and actually create the BoundLambda node appropriate for
// this syntax node.
var lambdaOperation = _semanticModel.GetOperationInternal(unboundLambda.Syntax);
Debug.Assert(lambdaOperation.Kind == OperationKind.LambdaExpression);
Debug.Assert(lambdaOperation.Kind == OperationKind.AnonymousFunctionExpression);
return lambdaOperation;
}

private ILambdaExpression CreateBoundLambdaOperation(BoundLambda boundLambda)
private IAnonymousFunctionExpression CreateBoundLambdaOperation(BoundLambda boundLambda)
{
IMethodSymbol signature = boundLambda.Symbol;
IMethodSymbol symbol = boundLambda.Symbol;
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundLambda.Body));
SyntaxNode syntax = boundLambda.Syntax;
// This matches the SemanticModel implementation. This is because in VB, lambdas by themselves
// do not have a type. To get the type of a lambda expression in the SemanticModel, you need to look at
// TypeInfo.ConvertedType, rather than TypeInfo.Type. We replicate that behavior here. To get the type of
// an ILambdaExpression, you need to look at the parent IConversionExpression.
// an IAnonymousFunctionExpression, you need to look at the parent IConversionExpression.
ITypeSymbol type = null;
Optional<object> constantValue = ConvertToOptional(boundLambda.ConstantValue);
bool isImplicit = boundLambda.WasCompilerGenerated;
return new LazyLambdaExpression(signature, body, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyAnonymousFunctionExpression(symbol, body, _semanticModel, syntax, type, constantValue, isImplicit);
}

private ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(BoundLocalFunctionStatement boundLocalFunctionStatement)
Expand Down Expand Up @@ -914,15 +914,15 @@ private IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(Bou
return new LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue, isImplicit);
}

private INullCoalescingExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator)
private ICoalesceExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator)
{
Lazy<IOperation> primaryOperand = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.LeftOperand));
Lazy<IOperation> secondaryOperand = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.RightOperand));
Lazy<IOperation> expression = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.LeftOperand));
Lazy<IOperation> whenNull = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.RightOperand));
SyntaxNode syntax = boundNullCoalescingOperator.Syntax;
ITypeSymbol type = boundNullCoalescingOperator.Type;
Optional<object> constantValue = ConvertToOptional(boundNullCoalescingOperator.ConstantValue);
bool isImplicit = boundNullCoalescingOperator.WasCompilerGenerated;
return new LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyCoalesceExpression(expression, whenNull, _semanticModel, syntax, type, constantValue, isImplicit);
}

private IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitExpression boundAwaitExpression)
Expand Down Expand Up @@ -1299,14 +1299,14 @@ private IReturnStatement CreateBoundYieldReturnStatementOperation(BoundYieldRetu

private ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boundLockStatement)
{
Lazy<IOperation> lockedObject = new Lazy<IOperation>(() => Create(boundLockStatement.Argument));
Lazy<IOperation> expression = new Lazy<IOperation>(() => Create(boundLockStatement.Argument));
Lazy<IOperation> body = new Lazy<IOperation>(() => Create(boundLockStatement.Body));
SyntaxNode syntax = boundLockStatement.Syntax;
ITypeSymbol type = null;
Optional<object> constantValue = default(Optional<object>);
bool isImplicit = boundLockStatement.WasCompilerGenerated;

return new LazyLockStatement(lockedObject, body, _semanticModel, syntax, type, constantValue, isImplicit);
return new LazyLockStatement(expression, body, _semanticModel, syntax, type, constantValue, isImplicit);
}

private IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatement boundBadStatement)
Expand Down
Loading

0 comments on commit 443d458

Please sign in to comment.