提交 3be2584b 编写于 作者: O Omar Tawfik

Checked uses of RefKind.RefReadOnly

上级 b79d701b
......@@ -518,7 +518,7 @@ private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter,
// all parameters can be passed by ref/out or assigned to
// except "in" parameters, which are readonly
if (parameterSymbol.RefKind == RefKind.RefReadOnly && RequiresAssignableVariable(valueKind))
if (parameterSymbol.RefKind == RefKind.In && RequiresAssignableVariable(valueKind))
{
ReportReadOnlyError(parameterSymbol, node, valueKind, checkingReceiver, diagnostics);
return false;
......@@ -1291,9 +1291,9 @@ bool isRefEscape
{
var paramIndex = argsToParamsOpt.IsDefault ? argIndex : argsToParamsOpt[argIndex];
if (parameters[paramIndex].RefKind == RefKind.RefReadOnly)
if (parameters[paramIndex].RefKind == RefKind.In)
{
effectiveRefKind = RefKind.RefReadOnly;
effectiveRefKind = RefKind.In;
refReadOnlyParametersMatchedWithArgs = refReadOnlyParametersMatchedWithArgs ?? ArrayBuilder<bool>.GetInstance(parameters.Length, fillWithValue: false);
refReadOnlyParametersMatchedWithArgs[paramIndex] = true;
}
......@@ -1321,7 +1321,7 @@ private static ParameterSymbol TryGetUnmatchedRefReadOnlyParameterAndFreeMatched
break;
}
if (parameter.RefKind == RefKind.RefReadOnly &&
if (parameter.RefKind == RefKind.In &&
refReadOnlyParametersMatchedWithArgs?[i] != true &&
parameter.Type.IsByRefLikeType == false)
{
......
......@@ -980,7 +980,7 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
CheckFeatureAvailability(receiverArgument.Syntax, MessageID.IDS_FeatureRefExtensionMethods, diagnostics);
}
else if (receiverParameter.RefKind == RefKind.RefReadOnly)
else if (receiverParameter.RefKind == RefKind.In)
{
CheckFeatureAvailability(receiverArgument.Syntax, MessageID.IDS_FeatureRefExtensionMethods, diagnostics);
}
......
......@@ -141,7 +141,7 @@ internal partial class Binder
case SyntaxKind.ReadOnlyKeyword:
Debug.Assert(refKind == RefKind.Ref || syntax.HasErrors);
refKind = RefKind.RefReadOnly;
refKind = RefKind.In;
allValue = false;
break;
......
......@@ -2575,7 +2575,7 @@ private RefKind GetEffectiveParameterRefKind(ParameterSymbol parameter, RefKind
{
var paramRefKind = parameter.RefKind;
if (paramRefKind == RefKind.RefReadOnly)
if (paramRefKind == RefKind.In)
{
// "in" parameters are effectively None for the purpose of overload resolution.
paramRefKind = RefKind.None;
......
......@@ -950,17 +950,17 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
ParameterSymbol parameter = method.GetParameters()[parm];
bool isLastParameter = method.GetParameterCount() == parm + 1; // This is used to later decide if we need to try to unwrap a params array
RefKind refArg = arguments.RefKind(arg);
RefKind refParm = parameter.RefKind;
RefKind refParameter = parameter.RefKind;
if (arguments.IsExtensionMethodThisArgument(arg))
{
Debug.Assert(refArg == RefKind.None);
if (refParm == RefKind.Ref || refParm == RefKind.RefReadOnly)
if (refParameter == RefKind.Ref || refParameter == RefKind.In)
{
// For ref and ref-readonly extension methods, we omit the "ref" modifier on receiver arguments.
// Setting the correct RefKind for finding the correct diagnostics message.
// For other ref kinds, keeping it as it is to find mismatch errors.
refArg = refParm;
refArg = refParameter;
}
}
......@@ -974,7 +974,7 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
{
// If the problem is that a lambda isn't convertible to the given type, also report why.
// The argument and parameter type might match, but may not have same in/out modifiers
if (argument.Kind == BoundKind.UnboundLambda && refArg == refParm)
if (argument.Kind == BoundKind.UnboundLambda && refArg == refParameter)
{
((UnboundLambda)argument).GenerateAnonymousFunctionConversionError(diagnostics, parameter.Type);
}
......@@ -992,9 +992,9 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
UnwrapIfParamsArray(parameter, isLastParameter));
}
}
else if (refArg != refParm && !(refArg == RefKind.None && refParm == RefKind.RefReadOnly))
else if (refArg != refParameter && !(refArg == RefKind.None && refParameter == RefKind.In))
{
if (refParm == RefKind.None || refParm == RefKind.RefReadOnly)
if (refParameter == RefKind.None || refParameter == RefKind.In)
{
// Argument {0} should not be passed with the {1} keyword
diagnostics.Add(
......@@ -1012,7 +1012,7 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
sourceLocation,
symbols,
arg + 1,
refParm.ToParameterDisplayString());
refParameter.ToParameterDisplayString());
}
}
else
......
......@@ -364,7 +364,7 @@ private bool HasHome(BoundExpression expression, bool needWriteable)
case BoundKind.Parameter:
return !needWriteable ||
((BoundParameter)expression).ParameterSymbol.RefKind != RefKind.RefReadOnly;
((BoundParameter)expression).ParameterSymbol.RefKind != RefKind.In;
case BoundKind.Local:
// locals have home unless they are byval stack locals or ref-readonly
......
......@@ -599,7 +599,7 @@ private void EmitArgument(BoundExpression argument, RefKind refKind)
EmitExpression(argument, true);
break;
case RefKind.RefReadOnly:
case RefKind.In:
var temp = EmitAddress(argument, AddressKind.ReadOnly);
AddExpressionTemp(temp);
break;
......
......@@ -378,7 +378,7 @@ private BoundStatement UpdateStatement(BoundSpillSequenceBuilder builder, BoundS
case BoundKind.Call:
var call = (BoundCall)expression;
if (refKind != RefKind.None && refKind != RefKind.RefReadOnly)
if (refKind != RefKind.None && refKind != RefKind.In)
{
Debug.Assert(call.Method.RefKind != RefKind.None);
_F.Diagnostics.Add(ErrorCode.ERR_RefReturningCallAndAwait, _F.Syntax.Location, call.Method);
......@@ -794,7 +794,7 @@ public override BoundNode VisitCall(BoundCall node)
receiver = node.ReceiverOpt;
var refKind = node.Method.ContainingType.IsReadOnly?
RefKind.RefReadOnly:
RefKind.In:
ReceiverSpillRefKind(receiver);
receiver = Spill(receiverBuilder, VisitExpression(ref receiverBuilder, receiver), refKind: refKind);
......
......@@ -597,7 +597,7 @@ private void CheckRefReadOnlySymbols(MethodSymbol symbol)
{
foreach (var parameter in symbol.Parameters)
{
if (parameter.RefKind == RefKind.RefReadOnly)
if (parameter.RefKind == RefKind.In)
{
foundRefReadOnly = true;
break;
......
......@@ -503,7 +503,7 @@ private static ImmutableArray<RefKind> GetEffectiveArgumentRefKinds(ImmutableArr
for (int i = 0; i < parameters.Length; i++)
{
var paramRefKind = parameters[i].RefKind;
if (paramRefKind == RefKind.RefReadOnly)
if (paramRefKind == RefKind.In)
{
if (refKindsBuilder == null)
{
......@@ -661,9 +661,9 @@ private static ImmutableArray<RefKind> GetRefKindsOrNull(ArrayBuilder<RefKind> r
BoundExpression argument = rewrittenArguments[a];
int p = (!argsToParamsOpt.IsDefault) ? argsToParamsOpt[a] : a;
RefKind refKind = argumentRefKinds.RefKinds(a);
if (refKind == RefKind.None && parameters[p].RefKind == RefKind.RefReadOnly)
if (refKind == RefKind.None && parameters[p].RefKind == RefKind.In)
{
refKind = RefKind.RefReadOnly;
refKind = RefKind.In;
}
Debug.Assert(arguments[p] == null);
......
......@@ -1269,7 +1269,7 @@ internal static BoundExpression NullOrDefault(TypeSymbol typeSymbol, SyntaxNode
#endif
)
{
if (refKind == RefKind.Out || refKind == RefKind.RefReadOnly)
if (refKind == RefKind.Out || refKind == RefKind.In)
{
refKind = RefKind.Ref;
}
......
......@@ -742,10 +742,8 @@ private void AddParameterRefKindIfRequired(RefKind refKind)
AddKeyword(SyntaxKind.RefKeyword);
AddSpace();
break;
case RefKind.RefReadOnly:
AddKeyword(SyntaxKind.RefKeyword);
AddSpace();
AddKeyword(SyntaxKind.ReadOnlyKeyword);
case RefKind.In:
AddKeyword(SyntaxKind.InKeyword);
AddSpace();
break;
}
......
......@@ -796,7 +796,7 @@ private bool IsValidExtensionMethodSignature()
{
case RefKind.None:
case RefKind.Ref:
case RefKind.RefReadOnly:
case RefKind.In:
return !parameter.IsParams;
default:
return false;
......
......@@ -304,7 +304,7 @@ private sealed class PEParameterSymbolWithCustomModifiers : PEParameterSymbol
_customModifiers = CSharpCustomModifier.Convert(customModifiers);
_refCustomModifiers = CSharpCustomModifier.Convert(refCustomModifiers);
if (this.RefKind != RefKind.RefReadOnly && _refCustomModifiers.Any(modifier => !modifier.IsOptional && modifier.Modifier.IsWellKnownTypeInAttribute()))
if (this.RefKind != RefKind.In && _refCustomModifiers.Any(modifier => !modifier.IsOptional && modifier.Modifier.IsWellKnownTypeInAttribute()))
{
// The modreq is only accepted on RefReadOnly symbols
isBad = true;
......
......@@ -378,7 +378,7 @@ internal void DoGetExtensionMethods(ArrayBuilder<MethodSymbol> methods, string n
var thisParam = method.Parameters.First();
if ((thisParam.RefKind == RefKind.Ref && !thisParam.Type.IsValueType) ||
(thisParam.RefKind == RefKind.RefReadOnly && thisParam.Type.TypeKind != TypeKind.Struct))
(thisParam.RefKind == RefKind.In && thisParam.Type.TypeKind != TypeKind.Struct))
{
// For ref and ref-readonly extension methods, receivers need to be of the correct types to be considered in lookup
continue;
......
......@@ -145,7 +145,7 @@ public bool IsOptional
RefKind refKind;
return !IsParams && IsMetadataOptional &&
((refKind = RefKind) == RefKind.None ||
(refKind == RefKind.RefReadOnly) ||
(refKind == RefKind.In) ||
(refKind == RefKind.Ref && ContainingSymbol.ContainingType.IsComImport));
}
}
......
......@@ -125,7 +125,7 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
foreach (var parameter in parameters)
{
if (parameter.RefKind == RefKind.RefReadOnly)
if (parameter.RefKind == RefKind.In)
{
// These parameters might not come from a compilation (example: lambdas evaluated in EE).
// During rewriting, lowering will take care of flagging the appropriate PEModuleBuilder instead.
......@@ -533,11 +533,11 @@ private static RefKind GetModifiers(SyntaxTokenList modifiers, out SyntaxToken r
refKind = RefKind.Ref;
}
break;
case SyntaxKind.ReadOnlyKeyword:
if (refKind == RefKind.Ref)
case SyntaxKind.InKeyword:
if (refKind == RefKind.None)
{
refnessKeyword = modifier;
refKind = RefKind.RefReadOnly;
refKind = RefKind.In;
}
break;
case SyntaxKind.ParamsKeyword:
......
......@@ -226,7 +226,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
{
diagnostics.Add(ErrorCode.ERR_RefExtensionMustBeValueTypeOrConstrainedToOne, location, Name);
}
else if (parameter0RefKind == RefKind.RefReadOnly && parameter0Type.TypeKind != TypeKind.Struct)
else if (parameter0RefKind == RefKind.In && parameter0Type.TypeKind != TypeKind.Struct)
{
diagnostics.Add(ErrorCode.ERR_RefReadOnlyExtensionMustBeValueType, location, Name);
}
......
......@@ -50,7 +50,7 @@ internal abstract class SourceParameterSymbol : SourceParameterSymbolBase
identifier.Parent.GetLocation());
}
if (addRefReadOnlyModifier && refKind == RefKind.RefReadOnly)
if (addRefReadOnlyModifier && refKind == RefKind.In)
{
var modifierType = context.GetWellKnownType(WellKnownType.System_Runtime_InteropServices_InAttribute, declarationDiagnostics, syntax);
......@@ -257,7 +257,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
{
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
if (this.RefKind == RefKind.RefReadOnly)
if (this.RefKind == RefKind.In)
{
AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeIsReadOnlyAttribute(this));
}
......
......@@ -178,7 +178,7 @@ private void CheckValueParameters(DiagnosticBag diagnostics)
// SPEC: The parameters of an operator must be value parameters.
foreach (var p in this.Parameters)
{
if (p.RefKind != RefKind.None && p.RefKind != RefKind.RefReadOnly)
if (p.RefKind != RefKind.None && p.RefKind != RefKind.In)
{
diagnostics.Add(ErrorCode.ERR_IllegalRefParam, this.Locations[0]);
break;
......
......@@ -52,7 +52,7 @@ public override RefKind RefKind
if (ContainingType.IsReadOnly)
{
return RefKind.RefReadOnly;
return RefKind.In;
}
return RefKind.Ref;
......
......@@ -36,7 +36,7 @@ class Test
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), module.ContainingAssembly.Name);
......@@ -56,7 +56,7 @@ class Test
CompileAndVerify(text, symbolValidator: module =>
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetMethod("M").GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Internal, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
......@@ -108,7 +108,7 @@ class Test
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), referenceA.Compilation.AssemblyName);
......@@ -138,7 +138,7 @@ struct Test
foreach (var parameter in method.Parameters)
{
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
}
});
......@@ -190,7 +190,7 @@ struct Test
Assert.Equal(2, method.ParameterCount);
foreach (var parameter in method.Parameters)
{
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
}
......@@ -217,7 +217,7 @@ class Test
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetMethod(".ctor").Parameters.Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
}
......@@ -261,7 +261,7 @@ class Test
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetMethod(".ctor").Parameters.Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertNoIsReadOnlyAttributeExists(module.ContainingAssembly);
......@@ -391,7 +391,7 @@ class Test
Assert.True(indexer.ReturnsByRefReadonly);
var parameter = indexer.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, indexer.GetAttributes(), module.ContainingAssembly.Name);
......@@ -411,7 +411,7 @@ class Test
CompileAndVerify(text, symbolValidator: module =>
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetProperty("this[]").GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Internal, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
......@@ -463,7 +463,7 @@ class Test
Assert.True(indexer.ReturnsByRefReadonly);
var parameter = indexer.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, indexer.GetAttributes(), referenceA.Compilation.AssemblyName);
......@@ -490,7 +490,7 @@ public class IsReadOnlyAttribute : System.Attribute { }
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), module.ContainingAssembly.Name);
......@@ -507,7 +507,7 @@ public void RefReadOnlyIsWrittenToMetadata_NeedsToBeGenerated_Delegate_Parameter
CompileAndVerify(text, symbolValidator: module =>
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("D").DelegateInvokeMethod.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Internal, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
......@@ -552,7 +552,7 @@ public class IsReadOnlyAttribute : System.Attribute { }
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), referenceA.Compilation.AssemblyName);
......@@ -589,7 +589,7 @@ public void M()
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), module.ContainingAssembly.Name);
......@@ -613,7 +613,7 @@ public void M()
CompileAndVerify(text, options: options, symbolValidator: module =>
{
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetMethod("<M>g__Inner|0_0").GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Internal, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
......@@ -678,7 +678,7 @@ public void M()
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), referenceA.Compilation.AssemblyName);
......@@ -717,7 +717,7 @@ public void M1()
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), module.ContainingAssembly.Name);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), module.ContainingAssembly.Name);
......@@ -745,7 +745,7 @@ public void M1()
CompileAndVerify(text, options: options, symbolValidator: module =>
{
var parameter = module.GlobalNamespace.GetMember<MethodSymbol>("Test.<>c.<M1>b__0_0").GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Internal, parameter.GetAttributes(), module.ContainingAssembly.Name);
});
......@@ -813,7 +813,7 @@ public void M1()
Assert.True(method.ReturnsByRefReadonly);
var parameter = method.GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), referenceA.Compilation.AssemblyName);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, method.GetReturnTypeAttributes(), referenceA.Compilation.AssemblyName);
......@@ -1151,7 +1151,7 @@ public class Test
AssertNoIsReadOnlyAttributeExists(module.ContainingAssembly);
var parameter = module.ContainingAssembly.GetTypeByMetadataName("Test").GetMethod("M").GetParameters().Single();
Assert.Equal(RefKind.RefReadOnly, parameter.RefKind);
Assert.Equal(RefKind.In, parameter.RefKind);
AssertReferencedIsReadOnlyAttribute(Accessibility.Public, parameter.GetAttributes(), reference.Display);
});
}
......
......@@ -814,29 +814,29 @@ public override string ToString()
NamedTypeSymbol namedType = comp.GetTypeByMetadataName("Program+S1");
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S1<T>
namedType = comp.GetTypeByMetadataName("Program+S1`1");
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// T
TypeSymbol type = namedType.TypeParameters[0];
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S1<object>
namedType = namedType.Construct(comp.ObjectType);
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S2
namedType = comp.GetTypeByMetadataName("Program+S2");
......@@ -970,29 +970,29 @@ public override string ToString()
NamedTypeSymbol namedType = comp.GetTypeByMetadataName("Program+S1");
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S1<T>
namedType = comp.GetTypeByMetadataName("Program+S1`1");
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// T
TypeSymbol type = namedType.TypeParameters[0];
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S1<object>
namedType = namedType.Construct(comp.ObjectType);
Assert.True(namedType.IsReadOnly);
Assert.Equal(RefKind.Out, namedType.Constructors[0].ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.RefReadOnly, namedType.GetMethod("ToString").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("M1").ThisParameter.RefKind);
Assert.Equal(RefKind.In, namedType.GetMethod("ToString").ThisParameter.RefKind);
// S2
namedType = comp.GetTypeByMetadataName("Program+S2");
......
......@@ -1962,7 +1962,7 @@ public static class Ext
var model = comp.GetSemanticModel(tree);
var symbol = (ParameterSymbol)model.GetDeclaredSymbolForNode(parameter.AsNode());
Assert.Equal(RefKind.RefReadOnly, symbol.RefKind);
Assert.Equal(RefKind.In, symbol.RefKind);
}
[Fact]
......
......@@ -750,7 +750,7 @@ public void RefReadonlyReturningDelegate()
Assert.Equal(RefKind.RefReadOnly, d.DelegateInvokeMethod.RefKind);
Assert.Equal(RefKind.RefReadOnly, ((MethodSymbol)d.GetMembers("EndInvoke").Single()).RefKind);
Assert.Equal(RefKind.RefReadOnly, d.DelegateInvokeMethod.Parameters[0].RefKind);
Assert.Equal(RefKind.In, d.DelegateInvokeMethod.Parameters[0].RefKind);
}
[Fact]
......@@ -779,14 +779,14 @@ public static void Main()
Assert.False(lambda.ReturnsByRef);
Assert.True(lambda.ReturnsByRefReadonly);
Assert.Equal(lambda.Parameters[0].RefKind, RefKind.RefReadOnly);
Assert.Equal(lambda.Parameters[0].RefKind, RefKind.In);
lambdaSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<AnonymousMethodExpressionSyntax>().Single();
lambda = (LambdaSymbol)model.GetSymbolInfo(lambdaSyntax).Symbol;
Assert.False(lambda.ReturnsByRef);
Assert.True(lambda.ReturnsByRefReadonly);
Assert.Equal(lambda.Parameters[0].RefKind, RefKind.RefReadOnly);
Assert.Equal(lambda.Parameters[0].RefKind, RefKind.In);
}
}
}
......@@ -554,7 +554,7 @@ class C
Assert.False(p.GetMethod.IsImplicitlyDeclared);
Assert.True(p.IsExpressionBodied);
Assert.Equal(RefKind.RefReadOnly, p.GetMethod.RefKind);
Assert.Equal(RefKind.RefReadOnly, p.GetMethod.Parameters[0].RefKind);
Assert.Equal(RefKind.In, p.GetMethod.Parameters[0].RefKind);
Assert.False(p.ReturnsByRef);
Assert.False(p.GetMethod.ReturnsByRef);
Assert.True(p.ReturnsByRefReadonly);
......@@ -582,7 +582,7 @@ class C
Assert.False(p.GetMethod.IsImplicitlyDeclared);
Assert.True(p.IsExpressionBodied);
Assert.Equal(RefKind.RefReadOnly, p.GetMethod.RefKind);
Assert.Equal(RefKind.RefReadOnly, p.GetMethod.Parameters[0].RefKind);
Assert.Equal(RefKind.In, p.GetMethod.Parameters[0].RefKind);
Assert.False(p.ReturnsByRef);
Assert.False(p.GetMethod.ReturnsByRef);
Assert.True(p.ReturnsByRefReadonly);
......
......@@ -359,7 +359,7 @@ class MyClass
<Fact, Trait(Traits.Feature, Traits.Features.ChangeSignature)>
Public Async Function TestRefKindsDisplayedCorrectly() As Tasks.Task
Dim includedInTest = {RefKind.None, RefKind.Ref, RefKind.Out, RefKind.RefReadOnly}
Dim includedInTest = {RefKind.None, RefKind.Ref, RefKind.Out, RefKind.In, RefKind.RefReadOnly}
Assert.Equal(includedInTest, EnumUtilities.GetValues(Of RefKind)())
Dim markup = <Text><![CDATA[
......
......@@ -130,8 +130,8 @@ internal static SyntaxTokenList GetParameterModifiers(RefKind refKind)
return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.OutKeyword));
case RefKind.Ref:
return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.RefKeyword));
case RefKind.RefReadOnly:
return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.RefKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
case RefKind.In:
return SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InKeyword));
default:
throw ExceptionUtilities.UnexpectedValue(refKind);
}
......@@ -142,7 +142,7 @@ internal static SyntaxToken GetArgumentModifiers(RefKind refKind)
switch (refKind)
{
case RefKind.None:
case RefKind.RefReadOnly:
case RefKind.In:
return default;
case RefKind.Out:
return SyntaxFactory.Token(SyntaxKind.OutKeyword);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册