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

Remove syntax of "in" parameters #22182

Merged
merged 1 commit into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ internal partial class Binder

case SyntaxKind.ReadOnlyKeyword:
Debug.Assert(refKind == RefKind.Ref || syntax.HasErrors);
goto case SyntaxKind.InKeyword;

case SyntaxKind.InKeyword:
refKind = RefKind.RefReadOnly;
allValue = false;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

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

2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -5199,7 +5199,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>Field-like events are not allowed in readonly structs.</value>
</data>
<data name="IDS_FeatureRefExtensionMethods" xml:space="preserve">
<value>ref or in extension methods</value>
<value>ref extension methods</value>
</data>
<data name="ERR_StackAllocConversionNotPossible" xml:space="preserve">
<value>Conversion of a stackalloc expression of type '{0}' to type '{1}' is not possible.</value>
Expand Down
17 changes: 0 additions & 17 deletions src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3751,7 +3751,6 @@ private bool IsPossibleParameter()
case SyntaxKind.OpenBracketToken: // attribute
case SyntaxKind.RefKeyword:
case SyntaxKind.OutKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.ParamsKeyword:
case SyntaxKind.ArgListKeyword:
case SyntaxKind.OpenParenToken: // tuple
Expand Down Expand Up @@ -3875,7 +3874,6 @@ private static bool IsParameterModifier(SyntaxKind kind)
case SyntaxKind.RefKeyword:
case SyntaxKind.OutKeyword:
case SyntaxKind.ParamsKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.ReadOnlyKeyword:
return true;
}
Expand All @@ -3895,19 +3893,6 @@ private void ParseParameterModifiers(SyntaxListBuilder modifiers)
modifier = CheckFeatureAvailability(modifier, MessageID.IDS_FeatureExtensionMethod);
break;

case SyntaxKind.InKeyword:
{
var nextKind = this.CurrentToken.Kind;

// "in this"
if (nextKind == SyntaxKind.ThisKeyword)
{
modifier = CheckFeatureAvailability(modifier, MessageID.IDS_FeatureRefExtensionMethods);
}

modifier = CheckFeatureAvailability(modifier, MessageID.IDS_FeatureReadonlyReferences);
break;
}
case SyntaxKind.RefKeyword:
{
var nextKind = this.CurrentToken.Kind;
Expand Down Expand Up @@ -9866,7 +9851,6 @@ private bool ScanExplicitlyTypedLambda(Precedence precedence)
}
break;
case SyntaxKind.OutKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.ParamsKeyword:
this.EatToken();
foundParameterModifier = true;
Expand Down Expand Up @@ -10865,7 +10849,6 @@ private bool IsPossibleLambdaParameter()
// recovery purposes and then give an error during semantic analysis.
case SyntaxKind.RefKeyword:
case SyntaxKind.OutKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.OpenParenToken: // tuple
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ private void AddParameterRefKindIfRequired(RefKind refKind)
AddSpace();
break;
case RefKind.RefReadOnly:
AddKeyword(SyntaxKind.InKeyword);
AddKeyword(SyntaxKind.RefKeyword);
AddSpace();
AddKeyword(SyntaxKind.ReadOnlyKeyword);
AddSpace();
break;
}
Expand Down
51 changes: 0 additions & 51 deletions src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
var seenOut = false;
var seenParams = false;
var seenRefReadOnly = false;
var seenIn = false;

foreach (var modifier in parameter.Modifiers)
{
Expand Down Expand Up @@ -182,10 +181,6 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.RefKeyword), SyntaxFacts.GetText(SyntaxKind.OutKeyword));
}
else if (seenIn)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.RefKeyword), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else
{
seenRef = true;
Expand All @@ -209,10 +204,6 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.OutKeyword), SyntaxFacts.GetText(SyntaxKind.RefKeyword));
}
else if (seenIn)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.OutKeyword), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else
{
seenOut = true;
Expand All @@ -236,43 +227,12 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.ParamsKeyword), SyntaxFacts.GetText(SyntaxKind.OutKeyword));
}
else if (seenIn)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.ParamsKeyword), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else
{
seenParams = true;
}
break;

case SyntaxKind.InKeyword:
if (seenIn)
{
diagnostics.Add(ErrorCode.ERR_DupParamMod, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else if (seenOut)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.InKeyword), SyntaxFacts.GetText(SyntaxKind.OutKeyword));
}
else if (seenThis)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiersOrder, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.InKeyword), SyntaxFacts.GetText(SyntaxKind.ThisKeyword));
}
else if (seenRef || seenRefReadOnly)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.InKeyword), SyntaxFacts.GetText(SyntaxKind.RefKeyword));
}
else if (seenParams)
{
diagnostics.Add(ErrorCode.ERR_ParamsCantBeWithModifier, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else
{
seenIn = true;
}
break;

case SyntaxKind.ReadOnlyKeyword:
if(seenRefReadOnly)
{
Expand All @@ -286,10 +246,6 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiersOrder, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.ReadOnlyKeyword), SyntaxFacts.GetText(SyntaxKind.ThisKeyword));
}
else if (seenIn)
{
diagnostics.Add(ErrorCode.ERR_BadParameterModifiers, modifier.GetLocation(), SyntaxFacts.GetText(SyntaxKind.ReadOnlyKeyword), SyntaxFacts.GetText(SyntaxKind.InKeyword));
}
else if(seenRef)
{
seenRef = false;
Expand Down Expand Up @@ -575,13 +531,6 @@ private static RefKind GetModifiers(SyntaxTokenList modifiers, out SyntaxToken r
refKind = RefKind.Ref;
}
break;
case SyntaxKind.InKeyword:
if (refKind == RefKind.None)
{
refnessKeyword = modifier;
refKind = RefKind.RefReadOnly;
}
break;
case SyntaxKind.ReadOnlyKeyword:
if (refKind == RefKind.Ref)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static void Main()
{
Test(default(S1));
}
static void Test(in S1 arg)
static void Test(ref readonly S1 arg)
{
System.Console.Write(arg.M1());
System.Console.Write(arg.ToString());
Expand Down Expand Up @@ -1208,4 +1208,4 @@ public static void Main()
CompileAndVerify(comp, expectedOutput: "SpanOpCalled", verify: false);
}
}
}
}
Loading