Skip to content

Commit 9a47f25

Browse files
authored
Merge pull request #39012 from dotnet/merges/master-to-features/local-function-attributes
Merge master to features/local-function-attributes
2 parents 788024a + c350cf3 commit 9a47f25

File tree

85 files changed

+3843
-860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3843
-860
lines changed

docs/compilers/CSharp/Compiler Breaking Changes - post VS2019.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ In Visual Studio version 16.4, the nullable analysis will be more stringent for
8080
class C<T> where T : I<(int a, int b)>, I<(int c, int d)> { } // error
8181
```
8282

83+
12. Previously, the language version was not checked for `this ref` and `this in` orderings of parameter modifiers. In *Visual Studio 2019 version 16.4* these orderings produce an error with langversion below 7.2. See https://github.com/dotnet/roslyn/issues/38486

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ProductDependencies>
44
</ProductDependencies>
55
<ToolsetDependencies>
6-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19480.3">
6+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19501.4">
77
<Uri>https://github.com/dotnet/arcade</Uri>
8-
<Sha>238f1bbb23ba67616818d0b242c5b55a18edec55</Sha>
8+
<Sha>c21a409f11386d22c6083198176868d3974de832</Sha>
99
</Dependency>
1010
</ToolsetDependencies>
1111
</Dependencies>

eng/common/tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function MSBuild {
332332
# Work around issues with Azure Artifacts credential provider
333333
# https://github.com/dotnet/arcade/issues/3932
334334
if [[ "$ci" == true ]]; then
335-
dotnet nuget locals http-cache -c
335+
"$_InitializeBuildTool" nuget locals http-cache -c
336336

337337
export NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20
338338
export NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20

eng/docker/Mono/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
#
55

6+
FROM ubuntu:16.04 as Info
7+
8+
# install wget
9+
RUN apt-get update && \
10+
apt-get install -y wget
11+
12+
# we always want to download the content of the release file, regardless of cache
13+
ARG CACHE_BUST=0
14+
RUN wget https://download.mono-project.com/repo/ubuntu/dists/nightly-xenial/Release
15+
616
FROM ubuntu:16.04
717

818
# Install the base toolchain we need to build anything
@@ -41,9 +51,10 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E03280
4151
apt-get clean
4252

4353

54+
# Copy will check the hash of the release file. If it's changed it will be copied and everything from this point will re-run regardless of cache status
55+
COPY --from=Info /Release .
56+
4457
# Update previously installed mono-devel.
45-
# Cache bust ensures we'll always run the commands following regardless of docker cache status
46-
ARG CACHE_BUST=0
4758
RUN apt-get update && apt-get upgrade -y
4859

4960
# Setup User to match Host User, and give superuser permissions
@@ -60,4 +71,4 @@ RUN chmod -R 755 /usr/lib/sudo
6071
USER ${USER_ID}
6172

6273
# Set working directory
63-
WORKDIR /opt/code
74+
WORKDIR /opt/code

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"xcopy-msbuild": "16.3.0-alpha"
88
},
99
"msbuild-sdks": {
10-
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19480.3"
10+
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19501.4"
1111
}
1212
}

src/Compilers/CSharp/Portable/Binder/Binder.WithQueryLambdaParametersBinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private BoundExpression SelectField(SimpleNameSyntax node, BoundExpression recei
8282
node,
8383
LookupResultKind.Empty,
8484
ImmutableArray.Create<Symbol>(receiver.ExpressionSymbol),
85-
ImmutableArray.Create(receiver),
85+
ImmutableArray.Create(BindToTypeForErrorRecovery(receiver)),
8686
new ExtendedErrorTypeSymbol(this.Compilation, "", 0, info));
8787
}
8888

src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ protected BoundExpression CreateConversion(
5353
ConversionGroup conversionGroupOpt,
5454
bool wasCompilerGenerated,
5555
TypeSymbol destination,
56-
DiagnosticBag diagnostics)
56+
DiagnosticBag diagnostics,
57+
bool hasErrors = false)
5758
{
5859
Debug.Assert(source != null);
5960
Debug.Assert((object)destination != null);
@@ -109,7 +110,6 @@ protected BoundExpression CreateConversion(
109110
if (source.Kind == BoundKind.UnconvertedSwitchExpression)
110111
{
111112
TypeSymbol type = source.Type;
112-
bool hasErrors = false;
113113
if (type is null)
114114
{
115115
Debug.Assert(!conversion.Exists);
@@ -128,7 +128,7 @@ protected BoundExpression CreateConversion(
128128
{
129129
// User-defined conversions are likely to be represented as multiple
130130
// BoundConversion instances so a ConversionGroup is necessary.
131-
return CreateUserDefinedConversion(syntax, source, conversion, isCast: isCast, conversionGroupOpt ?? new ConversionGroup(conversion), destination, diagnostics);
131+
return CreateUserDefinedConversion(syntax, source, conversion, isCast: isCast, conversionGroupOpt ?? new ConversionGroup(conversion), destination, diagnostics, hasErrors);
132132
}
133133

134134
ConstantValue constantValue = this.FoldConstantConversion(syntax, source, conversion, destination, diagnostics);
@@ -146,7 +146,8 @@ protected BoundExpression CreateConversion(
146146
explicitCastInCode: isCast && !wasCompilerGenerated,
147147
conversionGroupOpt,
148148
constantValueOpt: constantValue,
149-
type: destination)
149+
type: destination,
150+
hasErrors: hasErrors)
150151
{ WasCompilerGenerated = wasCompilerGenerated };
151152
}
152153

@@ -172,13 +173,22 @@ private BoundExpression ConvertSwitchExpression(BoundUnconvertedSwitchExpression
172173
source.DefaultLabel, source.ReportedNotExhaustive, destination, hasErrors || source.HasErrors);
173174
}
174175

175-
private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool isCast, ConversionGroup conversionGroup, TypeSymbol destination, DiagnosticBag diagnostics)
176+
private BoundExpression CreateUserDefinedConversion(
177+
SyntaxNode syntax,
178+
BoundExpression source,
179+
Conversion conversion,
180+
bool isCast,
181+
ConversionGroup conversionGroup,
182+
TypeSymbol destination,
183+
DiagnosticBag diagnostics,
184+
bool hasErrors)
176185
{
177186
Debug.Assert(conversionGroup != null);
178187

179188
if (!conversion.IsValid)
180189
{
181-
GenerateImplicitConversionError(diagnostics, syntax, conversion, source, destination);
190+
if (!hasErrors)
191+
GenerateImplicitConversionError(diagnostics, syntax, conversion, source, destination);
182192

183193
return new BoundConversion(
184194
syntax,
@@ -226,7 +236,7 @@ private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpr
226236
source: source,
227237
conversion: conversion.UserDefinedFromConversion,
228238
isCast: false,
229-
conversionGroup,
239+
conversionGroupOpt: conversionGroup,
230240
wasCompilerGenerated: false,
231241
destination: conversion.BestUserDefinedConversionAnalysis.FromType,
232242
diagnostics: diagnostics);
@@ -243,7 +253,7 @@ private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpr
243253
source: convertedOperand,
244254
conversion: Conversions.ClassifyStandardConversion(null, convertedOperand.Type, conversionParameterType, ref useSiteDiagnostics),
245255
isCast: false,
246-
conversionGroup,
256+
conversionGroupOpt: conversionGroup,
247257
wasCompilerGenerated: true,
248258
destination: conversionParameterType,
249259
diagnostics: diagnostics);
@@ -287,7 +297,7 @@ private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpr
287297
source: userDefinedConversion,
288298
conversion: Conversions.ClassifyStandardConversion(null, conversionReturnType, conversionToType, ref useSiteDiagnostics),
289299
isCast: false,
290-
conversionGroup,
300+
conversionGroupOpt: conversionGroup,
291301
wasCompilerGenerated: true,
292302
destination: conversionToType,
293303
diagnostics: diagnostics);
@@ -317,7 +327,7 @@ private BoundExpression CreateUserDefinedConversion(SyntaxNode syntax, BoundExpr
317327
source: userDefinedConversion,
318328
conversion: toConversion,
319329
isCast: false,
320-
conversionGroup,
330+
conversionGroupOpt: conversionGroup,
321331
wasCompilerGenerated: true, // NOTE: doesn't necessarily set flag on resulting bound expression.
322332
destination: destination,
323333
diagnostics: diagnostics);

src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind res
167167
return new BoundBadExpression(syntax,
168168
resultKind,
169169
symbols,
170-
childNodes,
170+
childNodes.SelectAsArray((e, self) => self.BindToTypeForErrorRecovery(e), this),
171171
CreateErrorType());
172172
}
173173

@@ -207,7 +207,7 @@ private BoundExpression ToBadExpression(BoundExpression expr, LookupResultKind r
207207
expr.Syntax,
208208
resultKind,
209209
symbols.ToImmutableAndFree(),
210-
ImmutableArray.Create(expr),
210+
ImmutableArray.Create(BindToTypeForErrorRecovery(expr)),
211211
resultType ?? CreateErrorType());
212212
}
213213
}
@@ -234,6 +234,19 @@ internal BoundExpression BindRValueWithoutTargetType(ExpressionSyntax node, Diag
234234
return BindToNaturalType(BindValue(node, diagnostics, BindValueKind.RValue), diagnostics, reportDefaultMissingType);
235235
}
236236

237+
internal BoundExpression BindToTypeForErrorRecovery(BoundExpression expression, TypeSymbol type = null)
238+
{
239+
if (expression is null)
240+
return null;
241+
var discardedDiagnostics = DiagnosticBag.GetInstance();
242+
var result =
243+
(!expression.NeedsToBeConverted() || expression.WasConverted) ? expression :
244+
type is null ? BindToNaturalType(expression, discardedDiagnostics) :
245+
GenerateConversionForAssignment(type, expression, discardedDiagnostics);
246+
discardedDiagnostics.Free();
247+
return result;
248+
}
249+
237250
/// <summary>
238251
/// Bind an rvalue expression to its natural type. For example, a switch expression that has not been
239252
/// converted to another type has to be converted to its own natural type by applying a conversion to
@@ -651,7 +664,7 @@ private BoundExpression BindExpressionInternal(ExpressionSyntax node, Diagnostic
651664
return BindRefExpression(node, diagnostics);
652665

653666
case SyntaxKind.DeclarationExpression:
654-
return BindDeclarationExpression((DeclarationExpressionSyntax)node, diagnostics);
667+
return BindDeclarationExpressionAsError((DeclarationExpressionSyntax)node, diagnostics);
655668

656669
case SyntaxKind.SuppressNullableWarningExpression:
657670
return BindSuppressNullableWarningExpression((PostfixUnaryExpressionSyntax)node, diagnostics);
@@ -735,7 +748,7 @@ private static bool IsThrowExpressionInProperContext(ThrowExpressionSyntax node)
735748
}
736749

737750
// Bind a declaration expression where it isn't permitted.
738-
private BoundExpression BindDeclarationExpression(DeclarationExpressionSyntax node, DiagnosticBag diagnostics)
751+
private BoundExpression BindDeclarationExpressionAsError(DeclarationExpressionSyntax node, DiagnosticBag diagnostics)
739752
{
740753
// This is an error, as declaration expressions are handled specially in every context in which
741754
// they are permitted. So we have a context in which they are *not* permitted. Nevertheless, we
@@ -746,13 +759,13 @@ private BoundExpression BindDeclarationExpression(DeclarationExpressionSyntax no
746759
AliasSymbol alias;
747760
var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type, ref isConst, out isVar, out alias);
748761
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, node);
749-
return BindDeclarationVariables(declType, node.Designation, node, diagnostics);
762+
return BindDeclarationVariablesForErrorRecovery(declType, node.Designation, node, diagnostics);
750763
}
751764

752765
/// <summary>
753766
/// Bind a declaration variable where it isn't permitted. The caller is expected to produce a diagnostic.
754767
/// </summary>
755-
private BoundExpression BindDeclarationVariables(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, DiagnosticBag diagnostics)
768+
private BoundExpression BindDeclarationVariablesForErrorRecovery(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, DiagnosticBag diagnostics)
756769
{
757770
declTypeWithAnnotations = declTypeWithAnnotations.HasType ? declTypeWithAnnotations : TypeWithAnnotations.Create(CreateErrorType("var"));
758771
switch (node.Kind())
@@ -761,7 +774,7 @@ private BoundExpression BindDeclarationVariables(TypeWithAnnotations declTypeWit
761774
{
762775
var single = (SingleVariableDesignationSyntax)node;
763776
var result = BindDeconstructionVariable(declTypeWithAnnotations, single, syntax, diagnostics);
764-
return result;
777+
return BindToTypeForErrorRecovery(result);
765778
}
766779
case SyntaxKind.DiscardDesignation:
767780
{
@@ -776,7 +789,7 @@ private BoundExpression BindDeclarationVariables(TypeWithAnnotations declTypeWit
776789

777790
foreach (var n in tuple.Variables)
778791
{
779-
builder.Add(BindDeclarationVariables(declTypeWithAnnotations, n, n, diagnostics));
792+
builder.Add(BindDeclarationVariablesForErrorRecovery(declTypeWithAnnotations, n, n, diagnostics));
780793
namesBuilder.Add(InferTupleElementName(n));
781794
}
782795
ImmutableArray<BoundExpression> subExpressions = builder.ToImmutableAndFree();
@@ -1364,7 +1377,7 @@ private BoundExpression BindIdentifier(
13641377
syntax: node,
13651378
resultKind: LookupResultKind.WrongArity,
13661379
symbols: ImmutableArray.Create(symbol),
1367-
childBoundNodes: ImmutableArray.Create(expression),
1380+
childBoundNodes: ImmutableArray.Create(BindToTypeForErrorRecovery(expression)),
13681381
type: expression.Type,
13691382
hasErrors: isError);
13701383
}
@@ -2150,23 +2163,14 @@ private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression oper
21502163
diagnostics.Add(node, useSiteDiagnostics);
21512164

21522165
var conversionGroup = new ConversionGroup(conversion, targetTypeWithAnnotations);
2153-
if (operand.HasAnyErrors || targetType.IsErrorType() || !conversion.IsValid || targetType.IsStatic)
2166+
bool suppressErrors = operand.HasAnyErrors || targetType.IsErrorType();
2167+
bool hasErrors = !conversion.IsValid || targetType.IsStatic;
2168+
if (hasErrors && !suppressErrors)
21542169
{
21552170
GenerateExplicitConversionErrors(diagnostics, node, conversion, operand, targetType);
2156-
2157-
return new BoundConversion(
2158-
node,
2159-
operand,
2160-
conversion,
2161-
@checked: CheckOverflowAtRuntime,
2162-
explicitCastInCode: true,
2163-
conversionGroup,
2164-
constantValueOpt: ConstantValue.NotAvailable,
2165-
type: targetType,
2166-
hasErrors: true);
21672171
}
21682172

2169-
return CreateConversion(node, operand, conversion, isCast: true, conversionGroup, wasCompilerGenerated: wasCompilerGenerated, destination: targetType, diagnostics: diagnostics);
2173+
return CreateConversion(node, operand, conversion, isCast: true, conversionGroupOpt: conversionGroup, wasCompilerGenerated: wasCompilerGenerated, destination: targetType, diagnostics: diagnostics, hasErrors: hasErrors | suppressErrors);
21702174
}
21712175

21722176
private void GenerateExplicitConversionErrors(
@@ -6155,7 +6159,7 @@ private BoundExpression BindMemberAccessBadResult(
61556159
node,
61566160
lookupKind,
61576161
(object)symbolOpt == null ? ImmutableArray<Symbol>.Empty : ImmutableArray.Create(symbolOpt),
6158-
boundLeft == null ? ImmutableArray<BoundExpression>.Empty : ImmutableArray.Create(boundLeft),
6162+
boundLeft == null ? ImmutableArray<BoundExpression>.Empty : ImmutableArray.Create(BindToTypeForErrorRecovery(boundLeft)),
61596163
GetNonMethodMemberType(symbolOpt));
61606164
}
61616165

@@ -7036,7 +7040,9 @@ private BoundExpression BindArrayAccess(ExpressionSyntax node, BoundExpression e
70367040
? arrayType
70377041
: arrayType.ElementType;
70387042

7039-
return new BoundArrayAccess(node, expr, convertedArguments.AsImmutableOrNull(), resultType, hasErrors);
7043+
return hasErrors
7044+
? new BoundArrayAccess(node, BindToTypeForErrorRecovery(expr), convertedArguments.Select(e => BindToTypeForErrorRecovery(e)).AsImmutableOrNull(), resultType, hasErrors: true)
7045+
: new BoundArrayAccess(node, expr, convertedArguments.AsImmutableOrNull(), resultType, hasErrors: false);
70407046
}
70417047

70427048
private BoundExpression ConvertToArrayIndex(BoundExpression index, SyntaxNode node, DiagnosticBag diagnostics, bool allowIndexAndRange)

0 commit comments

Comments
 (0)