提交 740c2294 编写于 作者: V vsadov

PR feedback

上级 dd55afd6
......@@ -10606,9 +10606,9 @@ internal static string ERR_RefReturnParameter
/// <summary>
/// Looks up a localized string similar to readonly references.
/// </summary>
internal static string IDS_FeatureReadonlyReferences {
internal static string IDS_FeatureReadOnlyReferences {
get {
return ResourceManager.GetString("IDS_FeatureReadonlyReferences", resourceCulture);
return ResourceManager.GetString("IDS_FeatureReadOnlyReferences", resourceCulture);
}
}
......
......@@ -4245,7 +4245,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="IDS_FeatureRefLocalsReturns" xml:space="preserve">
<value>byref locals and returns</value>
</data>
<data name="IDS_FeatureReadonlyReferences" xml:space="preserve">
<data name="IDS_FeatureReadOnlyReferences" xml:space="preserve">
<value>readonly references</value>
</data>
<data name="IDS_FeatureRefStructs" xml:space="preserve">
......
......@@ -1501,7 +1501,7 @@ internal enum ErrorCode
ERR_NamedArgumentSpecificationBeforeFixedArgumentInDynamicInvocation = 8324,
#endregion diagnostics introduced for C# 7.2
#region diagnostics introduced for `ref readonly`, `ref ternary` and`ref-like` features in C# 7.2
#region diagnostics introduced for `ref readonly`, `ref ternary` and `ref-like` features in C# 7.2
ERR_RefConditionalAndAwait = 8325,
ERR_RefConditionalNeedsTwoRefs = 8326,
ERR_RefConditionalDifferentTypes = 8327,
......@@ -1536,6 +1536,6 @@ internal enum ErrorCode
ERR_EscapeLocal = 8352,
ERR_EscapeStackAlloc = 8353,
ERR_RefReturnThis = 8354,
#endregion diagnostics introduced for `ref readonly`, `ref ternary` and`ref-like` features in C# 7.2
#endregion diagnostics introduced for `ref readonly`, `ref ternary` and `ref-like` features in C# 7.2
}
}
......@@ -139,7 +139,7 @@ internal enum MessageID
IDS_FeatureLeadingDigitSeparator = MessageBase + 12723,
IDS_FeatureNonTrailingNamedArguments = MessageBase + 12724,
IDS_FeatureReadonlyReferences = MessageBase + 12725,
IDS_FeatureReadOnlyReferences = MessageBase + 12725,
IDS_FeatureRefStructs = MessageBase + 12726,
IDS_FeatureReadOnlyStructs = MessageBase + 12727,
IDS_FeatureRefExtensionMethods = MessageBase + 12728,
......@@ -203,7 +203,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
// C# 7.2 features.
case MessageID.IDS_FeatureNonTrailingNamedArguments: // semantic check
case MessageID.IDS_FeatureLeadingDigitSeparator:
case MessageID.IDS_FeatureReadonlyReferences:
case MessageID.IDS_FeatureReadOnlyReferences:
case MessageID.IDS_FeatureRefStructs:
case MessageID.IDS_FeatureReadOnlyStructs:
case MessageID.IDS_FeatureRefExtensionMethods:
......
......@@ -3900,7 +3900,7 @@ private void ParseParameterModifiers(SyntaxListBuilder modifiers)
// "ref readonly"
if (nextKind == SyntaxKind.ReadOnlyKeyword)
{
modifier = CheckFeatureAvailability(modifier, MessageID.IDS_FeatureReadonlyReferences);
modifier = CheckFeatureAvailability(modifier, MessageID.IDS_FeatureReadOnlyReferences);
nextKind = PeekToken(1).Kind;
}
......@@ -6156,7 +6156,7 @@ private enum ParseTypeMode
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword)
{
readonlyKeyword = this.EatToken();
readonlyKeyword = this.CheckFeatureAvailability(readonlyKeyword, MessageID.IDS_FeatureReadonlyReferences);
readonlyKeyword = this.CheckFeatureAvailability(readonlyKeyword, MessageID.IDS_FeatureReadOnlyReferences);
}
var type = ParseTypeCore(mode, expectSizes);
......
......@@ -929,8 +929,11 @@ static void Main(string[] args)
var o1 = new C1();
(args != null ? ref o.field : ref o1.field).ToString();
System.Console.Write(o.field.value);
System.Console.WriteLine(o.field.value);
// no copying expected
(args != null ? ref o.field : ref o1.field).RoExtension();
System.Console.Write(o.field.value);
}
}
......@@ -939,7 +942,7 @@ class C1
public readonly S1 field;
}
struct S1
public struct S1
{
public int value;
......@@ -949,14 +952,22 @@ public override string ToString()
return base.ToString();
}
}
public static class S1Ext
{
public static void RoExtension(ref readonly this S1 self)
{
// do nothing
}
}
";
var comp = CompileAndVerify(source, additionalRefs: new[] { SystemRuntimeFacadeRef, ValueTupleRef }, expectedOutput: "0", verify: false);
var comp = CompileAndVerify(source, additionalRefs: new[] { SystemRuntimeFacadeRef, ValueTupleRef, SystemCoreRef }, expectedOutput: "00", verify: false);
comp.VerifyDiagnostics();
comp.VerifyIL("Program.Main", @"
{
// Code size 61 (0x3d)
// Code size 99 (0x63)
.maxstack 1
.locals init (C1 V_0, //o
C1 V_1, //o1
......@@ -980,8 +991,20 @@ .maxstack 1
IL_002c: ldloc.0
IL_002d: ldflda ""S1 C1.field""
IL_0032: ldfld ""int S1.value""
IL_0037: call ""void System.Console.WriteLine(int)""
IL_003c: ret
IL_0037: call ""void System.Console.Write(int)""
IL_003c: ldarg.0
IL_003d: brtrue.s IL_0047
IL_003f: ldloc.1
IL_0040: ldflda ""S1 C1.field""
IL_0045: br.s IL_004d
IL_0047: ldloc.0
IL_0048: ldflda ""S1 C1.field""
IL_004d: call ""void S1Ext.RoExtension(in S1)""
IL_0052: ldloc.0
IL_0053: ldflda ""S1 C1.field""
IL_0058: ldfld ""int S1.value""
IL_005d: call ""void System.Console.Write(int)""
IL_0062: ret
}
");
}
......
......@@ -2831,7 +2831,28 @@ static void Main()
// warning CS1685: The predefined type 'ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Diagnostic(ErrorCode.WRN_MultiplePredefTypes).WithArguments("System.Runtime.CompilerServices.ExtensionAttribute", "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").WithLocation(1, 1));
CompileAndVerify(comp, expectedOutput: "dynamic42", verify: false);
var compiled = CompileAndVerify(comp, expectedOutput: "dynamic42", verify: false);
compiled.VerifyIL("MyAwaiter.OnCompleted(System.Action)", @"
{
// Code size 43 (0x2b)
.maxstack 3
.locals init (MyAwaiter.<>c__DisplayClass5_0 V_0) //CS$<>8__locals0
IL_0000: newobj ""MyAwaiter.<>c__DisplayClass5_0..ctor()""
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.1
IL_0008: stfld ""System.Action MyAwaiter.<>c__DisplayClass5_0.continuation""
IL_000d: ldarg.0
IL_000e: ldflda ""MyTask MyAwaiter.task""
IL_0013: ldfld ""System.Threading.Tasks.Task MyTask.task""
IL_0018: ldloc.0
IL_0019: ldftn ""void MyAwaiter.<>c__DisplayClass5_0.<OnCompleted>b__0(System.Threading.Tasks.Task)""
IL_001f: newobj ""System.Action<System.Threading.Tasks.Task>..ctor(object, System.IntPtr)""
IL_0024: callvirt ""System.Threading.Tasks.Task System.Threading.Tasks.Task.ContinueWith(System.Action<System.Threading.Tasks.Task>)""
IL_0029: pop
IL_002a: ret
}");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册