提交 cdb3a9c7 编写于 作者: O Omar Tawfik

Reverse readonly ref to ref readonly in declarations

上级 b007ef97
......@@ -786,7 +786,7 @@ private TypeSymbol BindVariableType(CSharpSyntaxNode declarationNode, Diagnostic
// might own nested scope.
bool hasErrors = localSymbol.ScopeBinder.ValidateDeclarationNameConflictsInScope(localSymbol, diagnostics);
if (localSymbol.RefKind == RefKind.In)
if (localSymbol.RefKind == RefKind.RefReadOnly)
{
var refKeyword = typeSyntax.GetFirstToken();
diagnostics.Add(ErrorCode.ERR_UnexpectedToken, refKeyword.GetLocation(), refKeyword.ToString());
......
......@@ -1355,16 +1355,6 @@ private void ParseModifiers(SyntaxListBuilder tokens)
}
return;
}
case SyntaxModifier.ReadOnly:
{
if (PeekToken(1).Kind == SyntaxKind.RefKeyword)
{
// readonly is not a modifier in "readonly ref", since "ref" is not a modifier.
return;
}
goto default;
}
default:
{
modTok = this.EatToken();
......@@ -6308,16 +6298,14 @@ private ScanTypeFlags ScanNonArrayType(ParseTypeMode mode, out SyntaxToken lastT
{
ScanTypeFlags result;
// in a ref local or ref return, we treat "ref" and "readonly ref" as part of the type
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword &&
this.PeekToken(1).Kind == SyntaxKind.RefKeyword)
{
this.EatToken();
this.EatToken();
}
else if (this.CurrentToken.Kind == SyntaxKind.RefKeyword)
// in a ref local or ref return, we treat "ref" and "ref readonly" as part of the type
if (this.CurrentToken.Kind == SyntaxKind.RefKeyword)
{
this.EatToken();
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword)
{
this.EatToken();
}
}
if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken)
......@@ -6529,21 +6517,20 @@ private enum ParseTypeMode
ParseTypeMode mode = ParseTypeMode.Normal,
bool expectSizes = false)
{
if (mode == ParseTypeMode.Normal && !expectSizes)
if (mode == ParseTypeMode.Normal && !expectSizes && this.CurrentToken.Kind == SyntaxKind.RefKeyword)
{
var refKeyword = this.EatToken();
refKeyword = this.CheckFeatureAvailability(refKeyword, MessageID.IDS_FeatureRefLocalsReturns);
SyntaxToken readonlyKeyword = null;
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword && this.PeekToken(1).Kind == SyntaxKind.RefKeyword)
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword)
{
readonlyKeyword = this.EatToken();
readonlyKeyword = this.CheckFeatureAvailability(readonlyKeyword, MessageID.IDS_FeatureReadonlyReferences);
}
if (this.CurrentToken.Kind == SyntaxKind.RefKeyword)
{
var refKeyword = this.EatToken();
var type = ParseTypeCore(mode, expectSizes);
return this.CheckFeatureAvailability(_syntaxFactory.RefType(readonlyKeyword, refKeyword, type), MessageID.IDS_FeatureRefLocalsReturns);
}
var type = ParseTypeCore(mode, expectSizes);
return _syntaxFactory.RefType(refKeyword, readonlyKeyword, type);
}
return ParseTypeCore(mode, expectSizes);
......
......@@ -115,7 +115,7 @@ Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.ReadOnlyKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.RefKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithReadOnlyKeyword(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithRefKeyword(Microsoft.CodeAnalysis.SyntaxToken refKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
......@@ -298,7 +298,7 @@ static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParenthesizedVariableDesignat
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefExpression(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SingleVariableDesignation(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax
static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax
......
......@@ -181,14 +181,14 @@ public bool ReturnsByRef
}
/// <summary>
/// Indicates whether or not the method returns by readonly reference
/// Indicates whether or not the method returns by ref readonly
/// </summary>
public bool ReturnsByReadonlyRef
public bool ReturnsByRefReadonly
{
get
{
Debug.Assert(this.RefKind != RefKind.Out);
return this.RefKind == RefKind.In;
return this.RefKind == RefKind.RefReadOnly;
}
}
......
......@@ -11,7 +11,7 @@ public partial class RefTypeSyntax
{
public RefTypeSyntax Update(SyntaxToken refKeyword, TypeSyntax type)
{
return Update(default(SyntaxToken), refKeyword, type);
return Update(refKeyword, default(SyntaxToken), type);
}
}
}
......@@ -23,7 +23,7 @@ public partial class SyntaxFactory
/// <summary>Creates a new RefTypeSyntax instance.</summary>
public static RefTypeSyntax RefType(SyntaxToken refKeyword, TypeSyntax type)
{
return RefType(default(SyntaxToken), refKeyword, type);
return RefType(refKeyword, default(SyntaxToken), type);
}
}
}
......@@ -298,15 +298,15 @@
<summary>The ref modifier of a method's return value or a local.</summary>
</TypeComment>
<Kind Name="RefType"/>
<Field Name="RefKeyword" Type="SyntaxToken">
<Kind Name="RefKeyword"/>
</Field>
<Field Name="ReadOnlyKeyword" Type="SyntaxToken" Optional="true">
<Kind Name="ReadOnlyKeyword"/>
<PropertyComment>
<summary>Gets the optional "readonly" keyword.</summary>
</PropertyComment>
</Field>
<Field Name="RefKeyword" Type="SyntaxToken">
<Kind Name="RefKeyword"/>
</Field>
<Field Name="Type" Type="TypeSyntax"/>
</Node>
<!-- Expressions -->
......
......@@ -21,7 +21,7 @@ public void RefReturnArrayAccess()
var text = @"
class Program
{
static readonly ref int M()
static ref readonly int M()
{
return ref (new int[1])[0];
}
......
......@@ -1981,7 +1981,7 @@ public void TestDelegateWithRefReturnType()
[Fact]
public void TestDelegateWithReadonlyRefReturnType()
{
var text = "delegate readonly ref a b();";
var text = "delegate ref readonly a b();";
var file = this.ParseFile(text, TestOptions.Regular);
Assert.NotNull(file);
......@@ -1993,7 +1993,7 @@ public void TestDelegateWithReadonlyRefReturnType()
var ds = (DelegateDeclarationSyntax)file.Members[0];
Assert.NotNull(ds.DelegateKeyword);
Assert.NotNull(ds.ReturnType);
Assert.Equal("readonly ref a", ds.ReturnType.ToString());
Assert.Equal("ref readonly a", ds.ReturnType.ToString());
Assert.NotNull(ds.Identifier);
Assert.Equal("b", ds.Identifier.ToString());
Assert.NotNull(ds.ParameterList.OpenParenToken);
......@@ -2498,7 +2498,7 @@ public void TestClassMethodWithRefReturn()
[Fact]
public void TestClassMethodWithReadonlyRefReturn()
{
var text = "class a { readonly ref b X() { } }";
var text = "class a { ref readonly b X() { } }";
var file = this.ParseFile(text, TestOptions.Regular);
Assert.NotNull(file);
......@@ -2525,7 +2525,7 @@ public void TestClassMethodWithReadonlyRefReturn()
var ms = (MethodDeclarationSyntax)cs.Members[0];
Assert.Equal(0, ms.AttributeLists.Count);
Assert.NotNull(ms.ReturnType);
Assert.Equal("readonly ref b", ms.ReturnType.ToString());
Assert.Equal("ref readonly b", ms.ReturnType.ToString());
Assert.NotNull(ms.Identifier);
Assert.Equal("X", ms.Identifier.ToString());
Assert.NotNull(ms.ParameterList.OpenParenToken);
......@@ -2572,7 +2572,7 @@ public void TestClassMethodWithRef()
[Fact]
public void TestClassMethodWithReadonlyRef()
{
var text = "class a { readonly ref }";
var text = "class a { ref readonly }";
var file = this.ParseFile(text, parseOptions: TestOptions.Regular);
Assert.NotNull(file);
......@@ -3946,7 +3946,7 @@ public void TestClassPropertyWithRefReturn()
[Fact]
public void TestClassPropertyWithReadonlyRefReturn()
{
var text = "class a { readonly ref b c { get; set; } }";
var text = "class a { ref readonly b c { get; set; } }";
var file = this.ParseFile(text, TestOptions.Regular);
Assert.NotNull(file);
......@@ -3974,7 +3974,7 @@ public void TestClassPropertyWithReadonlyRefReturn()
Assert.Equal(0, ps.AttributeLists.Count);
Assert.Equal(0, ps.Modifiers.Count);
Assert.NotNull(ps.Type);
Assert.Equal("readonly ref b", ps.Type.ToString());
Assert.Equal("ref readonly b", ps.Type.ToString());
Assert.NotNull(ps.Identifier);
Assert.Equal("c", ps.Identifier.ToString());
......@@ -4889,7 +4889,7 @@ public void TestClassIndexerWithRefReturn()
[Fact]
public void TestClassIndexerWithReadonlyRefReturn()
{
var text = "class a { readonly ref b this[c d] { get; set; } }";
var text = "class a { ref readonly b this[c d] { get; set; } }";
var file = this.ParseFile(text, TestOptions.Regular);
Assert.NotNull(file);
......@@ -4917,7 +4917,7 @@ public void TestClassIndexerWithReadonlyRefReturn()
Assert.Equal(0, ps.AttributeLists.Count);
Assert.Equal(0, ps.Modifiers.Count);
Assert.NotNull(ps.Type);
Assert.Equal("readonly ref b", ps.Type.ToString());
Assert.Equal("ref readonly b", ps.Type.ToString());
Assert.NotNull(ps.ThisKeyword);
Assert.Equal("this", ps.ThisKeyword.ToString());
......
......@@ -25,35 +25,33 @@ public void ReadonlyRefReturn_CSharp7()
var text = @"
unsafe class Program
{
delegate readonly ref int D1();
delegate ref readonly int D1();
static readonly ref T M<T>()
static ref readonly T M<T>()
{
return ref (new T[1])[0];
}
public virtual readonly ref int* P1 => throw null;
public virtual ref readonly int* P1 => throw null;
public readonly ref int[][] this[int i] => throw null;
public ref readonly int[][] this[int i] => throw null;
}
";
var comp = CreateCompilationWithMscorlib45(text, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp7), options: TestOptions.UnsafeDebugDll);
comp.VerifyDiagnostics(
// (4,14): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// delegate readonly ref int D1();
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(4, 14),
// (6,12): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// static readonly ref T M<T>()
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(6, 12),
// (11,20): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public virtual readonly ref int* P1 => throw null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(11, 20),
// (13,12): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public readonly ref int[][] this[int i] => throw null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(13, 12)
);
// (4,18): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// delegate ref readonly int D1();
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(4, 18),
// (6,16): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// static ref readonly T M<T>()
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(6, 16),
// (11,24): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public virtual ref readonly int* P1 => throw null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(11, 24),
// (13,16): error CS8107: Feature 'readonly references' is not available in C# 7. Please use language version 71 or greater.
// public ref readonly int[][] this[int i] => throw null;
Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "readonly").WithArguments("readonly references", "71").WithLocation(13, 16));
}
[Fact]
......@@ -67,36 +65,36 @@ static void Main()
{
}
readonly ref int Field;
ref readonly int Field;
public static readonly ref Program operator +(Program x, Program y)
public static ref readonly Program operator +(Program x, Program y)
{
throw null;
}
// this parses fine
static async readonly ref Task M<T>()
static async ref readonly Task M<T>()
{
throw null;
}
public readonly ref virtual int* P1 => throw null;
public ref readonly virtual int* P1 => throw null;
}
";
ParseAndValidate(text, TestOptions.Regular,
// (9,27): error CS1003: Syntax error, '(' expected
// readonly ref int Field;
// ref readonly int Field;
Diagnostic(ErrorCode.ERR_SyntaxError, ";").WithArguments("(", ";").WithLocation(9, 27),
// (9,27): error CS1026: ) expected
// readonly ref int Field;
// ref readonly int Field;
Diagnostic(ErrorCode.ERR_CloseParenExpected, ";").WithLocation(9, 27),
// (11,41): error CS1519: Invalid token 'operator' in class, struct, or interface member declaration
// public static readonly ref Program operator +(Program x, Program y)
// public static ref readonly Program operator +(Program x, Program y)
Diagnostic(ErrorCode.ERR_InvalidMemberDecl, "operator").WithArguments("operator").WithLocation(11, 41),
// (11,41): error CS1519: Invalid token 'operator' in class, struct, or interface member declaration
// public static readonly ref Program operator +(Program x, Program y)
// public static ref readonly Program operator +(Program x, Program y)
Diagnostic(ErrorCode.ERR_InvalidMemberDecl, "operator").WithArguments("operator").WithLocation(11, 41),
// (12,5): error CS1519: Invalid token '{' in class, struct, or interface member declaration
// {
......@@ -105,12 +103,11 @@ static void Main()
// {
Diagnostic(ErrorCode.ERR_InvalidMemberDecl, "{").WithArguments("{").WithLocation(12, 5),
// (22,25): error CS1031: Type expected
// public readonly ref virtual int* P1 => throw null;
// public ref readonly virtual int* P1 => throw null;
Diagnostic(ErrorCode.ERR_TypeExpected, "virtual").WithLocation(22, 25),
// (24,1): error CS1022: Type or namespace definition, or end-of-file expected
// }
Diagnostic(ErrorCode.ERR_EOFExpected, "}").WithLocation(24, 1)
);
Diagnostic(ErrorCode.ERR_EOFExpected, "}").WithLocation(24, 1));
}
[Fact]
......@@ -122,11 +119,11 @@ class Program
{
static void Main()
{
readonly ref int local = ref (new int[1])[0];
ref readonly int local = ref (new int[1])[0];
(readonly ref int, readonly ref int Alice)? t = null;
(ref readonly int, ref readonly int Alice)? t = null;
System.Collections.Generic.List<readonly ref int> x = null;
System.Collections.Generic.List<ref readonly int> x = null;
Use(local);
Use(t);
......@@ -142,17 +139,15 @@ static void Use<T>(T dummy)
var comp = CreateCompilationWithMscorlib45(text, new[] { ValueTupleRef, SystemRuntimeFacadeRef });
comp.VerifyDiagnostics(
// (9,19): error CS1073: Unexpected token 'ref'
// (readonly ref int, readonly ref int Alice)? t = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(9, 19),
// (9,37): error CS1073: Unexpected token 'ref'
// (readonly ref int, readonly ref int Alice)? t = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(9, 37),
// (11,50): error CS1073: Unexpected token 'ref'
// System.Collections.Generic.List<readonly ref int> x = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(11, 50)
);
// (9,10): error CS1073: Unexpected token 'ref'
// (ref readonly int, ref readonly int Alice)? t = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(9, 10),
// (9,28): error CS1073: Unexpected token 'ref'
// (ref readonly int, ref readonly int Alice)? t = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(9, 28),
// (11,41): error CS1073: Unexpected token 'ref'
// System.Collections.Generic.List<ref readonly int> x = null;
Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(11, 41));
}
}
}
......@@ -93,7 +93,7 @@ Microsoft.CodeAnalysis.IDiscardSymbol.Type.get -> Microsoft.CodeAnalysis.ITypeSy
Microsoft.CodeAnalysis.IFieldSymbol.CorrespondingTupleField.get -> Microsoft.CodeAnalysis.IFieldSymbol
Microsoft.CodeAnalysis.ILocalSymbol.IsRef.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CustomModifier>
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByReadonlyRef.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRefReadonly.get -> bool
Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRef.get -> bool
Microsoft.CodeAnalysis.INamedTypeSymbol.GetTypeArgumentCustomModifiers(int ordinal) -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CustomModifier>
Microsoft.CodeAnalysis.INamedTypeSymbol.IsComImport.get -> bool
......@@ -190,7 +190,7 @@ Microsoft.CodeAnalysis.OperationKind.WithStatement = 82 -> Microsoft.CodeAnalysi
Microsoft.CodeAnalysis.OperationKind.YieldBreakStatement = 12 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.YieldReturnStatement = 16 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.PortableExecutableReference.GetMetadataId() -> Microsoft.CodeAnalysis.MetadataId
Microsoft.CodeAnalysis.RefKind.In = 3 -> Microsoft.CodeAnalysis.RefKind
Microsoft.CodeAnalysis.RefKind.RefReadOnly = 3 -> Microsoft.CodeAnalysis.RefKind
Microsoft.CodeAnalysis.SemanticModel.GetOperation(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.ArgumentKind
Microsoft.CodeAnalysis.Semantics.ArgumentKind.DefaultValue = 4 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind
......
......@@ -75,11 +75,11 @@ public interface IMethodSymbol : ISymbol
/// </summary>
bool ReturnsByRef { get; }
// PROTOTYPE(readonlyRef): this is very preliminary. We need to have _some_ API for now.
// PROTOTYPE(refreadonly): this is very preliminary. We need to have _some_ API for now.
/// <summary>
/// Returns true if this method returns by readonly reference.
/// Returns true if this method returns by ref readonly.
/// </summary>
bool ReturnsByReadonlyRef { get; }
bool ReturnsByRefReadonly { get; }
/// <summary>
/// Gets the return type of the method.
......
......@@ -25,9 +25,9 @@ public enum RefKind : byte
Out = 2,
/// <summary>
/// Indicates an "in" parameter.
/// Indicates a "ref readonly" or an "in" parameter.
/// </summary>
In = 3,
RefReadOnly = 3,
}
internal static class RefKindExtensions
......@@ -38,7 +38,7 @@ internal static string ToDisplayString(this RefKind kind)
{
case RefKind.Out: return "out";
case RefKind.Ref: return "ref";
case RefKind.In: return "in";
case RefKind.RefReadOnly: return "ref readonly";
default: return null;
}
}
......@@ -49,7 +49,7 @@ internal static string ToPrefix(this RefKind kind)
{
case RefKind.Out: return "out ";
case RefKind.Ref: return "ref ";
case RefKind.In: return "in ";
case RefKind.RefReadOnly: return "ref readonly ";
default: return string.Empty;
}
}
......
......@@ -949,9 +949,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get
End Property
Private ReadOnly Property IMethodSymbol_ReturnsByReadonlyRef As Boolean Implements IMethodSymbol.ReturnsByReadonlyRef
Private ReadOnly Property IMethodSymbol_ReturnsByRefReadonly As Boolean Implements IMethodSymbol.ReturnsByRefReadonly
Get
' PROTOTYPE(readonlyRef): NYI
' PROTOTYPE(refreadonly): NYI
Return False
End Get
End Property
......
......@@ -178,11 +178,11 @@ public bool ReturnsByRef
}
}
public bool ReturnsByReadonlyRef
public bool ReturnsByRefReadonly
{
get
{
return _symbol.ReturnsByReadonlyRef;
return _symbol.ReturnsByRefReadonly;
}
}
......
......@@ -32,7 +32,7 @@ public virtual ImmutableArray<AttributeData> GetReturnTypeAttributes()
public abstract int Arity { get; }
public abstract bool ReturnsVoid { get; }
public abstract bool ReturnsByRef { get; }
public abstract bool ReturnsByReadonlyRef { get; }
public abstract bool ReturnsByRefReadonly { get; }
public abstract ITypeSymbol ReturnType { get; }
public abstract ImmutableArray<ITypeSymbol> TypeArguments { get; }
public abstract ImmutableArray<ITypeParameterSymbol> TypeParameters { get; }
......
......@@ -48,11 +48,11 @@ public override bool ReturnsByRef
}
}
public override bool ReturnsByReadonlyRef
public override bool ReturnsByRefReadonly
{
get
{
return _constructedFrom.ReturnsByReadonlyRef;
return _constructedFrom.ReturnsByRefReadonly;
}
}
......
......@@ -33,7 +33,7 @@ internal partial class CodeGenerationMethodSymbol : CodeGenerationAbstractMethod
: base(containingType, attributes, declaredAccessibility, modifiers, name, returnTypeAttributes)
{
_returnType = returnType;
// PROTOTYPE(readonlyRef): NYI
// PROTOTYPE(refreadonly): NYI
_refKind = returnsByRef ? RefKind.Ref: RefKind.None;
_typeParameters = typeParameters.AsImmutableOrEmpty();
_parameters = parameters.AsImmutableOrEmpty();
......@@ -119,11 +119,11 @@ public override bool ReturnsByRef
}
}
public override bool ReturnsByReadonlyRef
public override bool ReturnsByRefReadonly
{
get
{
return _refKind == RefKind.In;
return _refKind == RefKind.RefReadOnly;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册