Skip to content

Commit 02fdd7a

Browse files
authored
Merge pull request #36807 from dotnet/merges/master-to-master-vs-deps
Merge master to master-vs-deps
2 parents 72444d3 + a571221 commit 02fdd7a

37 files changed

+349
-64
lines changed

eng/build.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ function BuildSolution {
234234
local test=false
235235
local test_runtime=""
236236
local mono_tool=""
237+
local test_runtime_args=""
237238
if [[ "$test_mono" == true ]]; then
238-
239-
mono_path="$scriptroot/invoke-mono.sh"
240-
# Echo out the mono version to the comamnd line so it's visible in CI logs. It's not fixed
239+
mono_path=`command -v mono`
240+
# Echo out the mono version to the command line so it's visible in CI logs. It's not fixed
241241
# as we're using a feed vs. a hard coded package.
242242
if [[ "$ci" == true ]]; then
243243
mono --version
244-
chmod +x "$mono_path"
245244
fi
246245

247246
test=true
248247
test_runtime="/p:TestRuntime=Mono"
249248
mono_tool="/p:MonoTool=\"$mono_path\""
249+
test_runtime_args="--debug"
250250
elif [[ "$test_core_clr" == true ]]; then
251251
test=true
252252
test_runtime="/p:TestRuntime=Core /p:TestTargetFrameworks=netcoreapp3.0%3Bnetcoreapp2.1"
@@ -273,6 +273,7 @@ function BuildSolution {
273273
/p:ContinuousIntegrationBuild=$ci \
274274
/p:TreatWarningsAsErrors=true \
275275
/p:RestoreDisableParallel=$disable_parallel_restore \
276+
/p:TestRuntimeAdditionalArguments=$test_runtime_args \
276277
$test_runtime \
277278
$mono_tool \
278279
$properties

eng/invoke-mono.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ private BoundExpression CheckValue(BoundExpression expr, BindValueKind valueKind
246246

247247
// Since we have a concrete member in hand, we can resolve the receiver.
248248
var typeOrValue = (BoundTypeOrValueExpression)receiver;
249-
receiver = otherSymbol.IsStatic
250-
? null // no receiver required
251-
: typeOrValue.Data.ValueExpression;
249+
receiver = otherSymbol.RequiresInstanceReceiver()
250+
? typeOrValue.Data.ValueExpression
251+
: null; // no receiver required
252252
}
253253
return new BoundBadExpression(
254254
expr.Syntax,
@@ -868,7 +868,7 @@ private bool CheckIsValidReceiverForVariable(SyntaxNode node, BoundExpression re
868868
/// </remarks>
869869
private static bool RequiresVariableReceiver(BoundExpression receiver, Symbol symbol)
870870
{
871-
return !symbol.IsStatic
871+
return symbol.RequiresInstanceReceiver()
872872
&& symbol.Kind != SymbolKind.Event
873873
&& receiver?.Type?.IsValueType == true;
874874
}
@@ -1114,7 +1114,7 @@ bool isRefEscape
11141114
//• the safe-to-escape of all argument expressions(including the receiver)
11151115
//
11161116

1117-
if (symbol.IsStatic)
1117+
if (!symbol.RequiresInstanceReceiver())
11181118
{
11191119
// ignore receiver when symbol is static
11201120
receiverOpt = null;
@@ -1221,7 +1221,7 @@ bool isRefEscape
12211221
// o no ref or out argument(excluding the receiver and arguments of ref-like types) may have a narrower ref-safe-to-escape than E1; and
12221222
// o no argument(including the receiver) may have a narrower safe-to-escape than E1.
12231223

1224-
if (symbol.IsStatic)
1224+
if (!symbol.RequiresInstanceReceiver())
12251225
{
12261226
// ignore receiver when symbol is static
12271227
receiverOpt = null;
@@ -1327,7 +1327,7 @@ private static bool CheckInvocationArgMixing(
13271327
// - If there is a ref or out argument of a ref struct type (including the receiver), with safe-to-escape E1, then
13281328
// - no argument (including the receiver) may have a narrower safe-to-escape than E1.
13291329

1330-
if (symbol.IsStatic)
1330+
if (!symbol.RequiresInstanceReceiver())
13311331
{
13321332
// ignore receiver when symbol is static
13331333
receiverOpt = null;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ private BoundMethodGroup FixMethodGroupWithTypeOrValue(BoundMethodGroup group, C
485485
BoundExpression receiverOpt = group.ReceiverOpt;
486486
Debug.Assert(receiverOpt != null);
487487
Debug.Assert((object)conversion.Method != null);
488-
receiverOpt = ReplaceTypeOrValueReceiver(receiverOpt, conversion.Method.IsStatic && !conversion.IsExtensionMethod, diagnostics);
488+
receiverOpt = ReplaceTypeOrValueReceiver(receiverOpt, !conversion.Method.RequiresInstanceReceiver && !conversion.IsExtensionMethod, diagnostics);
489489
return group.Update(
490490
group.TypeArgumentsOpt,
491491
group.Name,
@@ -599,7 +599,7 @@ private bool MemberGroupFinalValidationAccessibilityChecks(BoundExpression recei
599599
// None of the checks below apply if the receiver can't be classified as a type or value.
600600
Debug.Assert(!invokedAsExtensionMethod);
601601
}
602-
else if (memberSymbol.IsStatic)
602+
else if (!memberSymbol.RequiresInstanceReceiver())
603603
{
604604
Debug.Assert(!invokedAsExtensionMethod || (receiverOpt != null));
605605

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ private BoundExpression SynthesizeReceiver(SyntaxNode node, Symbol member, Diagn
16721672
// accessor, the result is the same as a member access of the form this.I. This can only
16731673
// happen when K is zero.
16741674

1675-
if (member.IsStatic)
1675+
if (!member.RequiresInstanceReceiver())
16761676
{
16771677
return null;
16781678
}
@@ -1737,7 +1737,7 @@ internal Symbol ContainingMember()
17371737

17381738
private BoundExpression TryBindInteractiveReceiver(SyntaxNode syntax, Symbol currentMember, NamedTypeSymbol currentType, NamedTypeSymbol memberDeclaringType)
17391739
{
1740-
if (currentType.TypeKind == TypeKind.Submission && !currentMember.IsStatic)
1740+
if (currentType.TypeKind == TypeKind.Submission && currentMember.RequiresInstanceReceiver())
17411741
{
17421742
if (memberDeclaringType.TypeKind == TypeKind.Submission)
17431743
{
@@ -6650,7 +6650,7 @@ private bool CheckInstanceOrStatic(
66506650
{
66516651
bool? instanceReceiver = IsInstanceReceiver(receiver);
66526652

6653-
if (symbol.IsStatic)
6653+
if (!symbol.RequiresInstanceReceiver())
66546654
{
66556655
if (instanceReceiver == true)
66566656
{

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ private BoundCall BindInvocationExpressionContinued(
10021002
// instance methods. Therefore we must detect this scenario here, rather than in
10031003
// overload resolution.
10041004

1005-
var receiver = ReplaceTypeOrValueReceiver(methodGroup.Receiver, method.IsStatic && !invokedAsExtensionMethod, diagnostics);
1005+
var receiver = ReplaceTypeOrValueReceiver(methodGroup.Receiver, !method.RequiresInstanceReceiver && !invokedAsExtensionMethod, diagnostics);
10061006

10071007
// Note: we specifically want to do final validation (7.6.5.1) without checking delegate compatibility (15.2),
10081008
// so we're calling MethodGroupFinalValidation directly, rather than via MethodGroupConversionHasErrors.
@@ -1056,7 +1056,7 @@ private BoundCall BindInvocationExpressionContinued(
10561056
// For extension methods, there is no receiver because the receiver in source was actually the first argument.
10571057
// For instance methods, we may have synthesized an implicit this node. We'll keep it for the emitter.
10581058
// For static methods, we may have synthesized a type expression. It serves no purpose, so we'll drop it.
1059-
if (invokedAsExtensionMethod || (method.IsStatic && receiver != null && receiver.WasCompilerGenerated))
1059+
if (invokedAsExtensionMethod || (!method.RequiresInstanceReceiver && receiver != null && receiver.WasCompilerGenerated))
10601060
{
10611061
receiver = null;
10621062
}
@@ -1065,7 +1065,7 @@ private BoundCall BindInvocationExpressionContinued(
10651065
var argRefKinds = analyzedArguments.RefKinds.ToImmutableOrNull();
10661066
var args = analyzedArguments.Arguments.ToImmutable();
10671067

1068-
if (!gotError && !method.IsStatic && receiver != null && receiver.Kind == BoundKind.ThisReference && receiver.WasCompilerGenerated)
1068+
if (!gotError && method.RequiresInstanceReceiver && receiver != null && receiver.Kind == BoundKind.ThisReference && receiver.WasCompilerGenerated)
10691069
{
10701070
gotError = IsRefOrOutThisParameterCaptured(node, diagnostics);
10711071
}
@@ -1116,7 +1116,7 @@ private BoundCall BindInvocationExpressionContinued(
11161116
bool isDelegateCall = (object)delegateTypeOpt != null;
11171117
if (!isDelegateCall)
11181118
{
1119-
if (!method.IsStatic)
1119+
if (method.RequiresInstanceReceiver)
11201120
{
11211121
WarnOnAccessOfOffDefault(node.Kind() == SyntaxKind.InvocationExpression ?
11221122
((InvocationExpressionSyntax)node).Expression :
@@ -1145,7 +1145,7 @@ ContainingMemberOrLambda is MethodSymbol containingMethod &&
11451145
// Ignore calls to base members.
11461146
TypeSymbol.Equals(containingMethod.ContainingType, method.ContainingType, TypeCompareKind.ConsiderEverything) &&
11471147
!method.IsEffectivelyReadOnly &&
1148-
!method.IsStatic)
1148+
method.RequiresInstanceReceiver)
11491149
{
11501150
Error(diagnostics, ErrorCode.WRN_ImplicitCopyInReadOnlyMember, receiver.Syntax, method, ThisParameterSymbol.SymbolName);
11511151
return false;

src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private static bool IsSymbolAccessibleCore(
179179
case SymbolKind.Property:
180180
case SymbolKind.Event:
181181
case SymbolKind.Field:
182-
if (symbol.IsStatic)
182+
if (!symbol.RequiresInstanceReceiver())
183183
{
184184
// static members aren't accessed "through" an "instance" of any type. So we
185185
// null out the "through" instance here. This ensures that we'll understand

src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private static Conversion ToConversion(OverloadResolutionResult<MethodSymbol> re
276276
}
277277

278278
//cannot capture stack-only types.
279-
if (!method.IsStatic && methodGroup.Receiver?.Type?.IsRestrictedType() == true)
279+
if (method.RequiresInstanceReceiver && methodGroup.Receiver?.Type?.IsRestrictedType() == true)
280280
{
281281
return Conversion.NoConversion;
282282
}

src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private void RemoveStaticInstanceMismatches<TMember>(
337337
{
338338
var result = results[f];
339339
TMember member = result.Member;
340-
if (result.Result.IsValid && member.IsStatic != keepStatic)
340+
if (result.Result.IsValid && member.RequiresInstanceReceiver() == keepStatic)
341341
{
342342
results[f] = new MemberResolutionResult<TMember>(member, result.LeastOverriddenMember, MemberAnalysisResult.StaticInstanceMismatch());
343343
}

src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,11 @@ private bool HadStaticInstanceMismatch(
608608
else
609609
{
610610
ErrorCode errorCode =
611-
symbol.IsStatic ? ErrorCode.ERR_ObjectProhibited :
612-
Binder.WasImplicitReceiver(receiverOpt) && binder.InFieldInitializer && !binder.BindingTopLevelScriptCode ? ErrorCode.ERR_FieldInitRefNonstatic :
613-
ErrorCode.ERR_ObjectRequired;
611+
symbol.RequiresInstanceReceiver()
612+
? Binder.WasImplicitReceiver(receiverOpt) && binder.InFieldInitializer && !binder.BindingTopLevelScriptCode
613+
? ErrorCode.ERR_FieldInitRefNonstatic
614+
: ErrorCode.ERR_ObjectRequired
615+
: ErrorCode.ERR_ObjectProhibited;
614616
// error CS0176: Member 'Program.M(B)' cannot be accessed with an instance reference; qualify it with a type name instead
615617
// -or-
616618
// error CS0120: An object reference is required for the non-static field, method, or property 'Program.M(B)'

0 commit comments

Comments
 (0)