Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
23ab0bbe
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
23ab0bbe
编写于
9月 28, 2016
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes: #14166
上级
b43b81e5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
95 addition
and
0 deletion
+95
-0
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+8
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+87
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
浏览文件 @
23ab0bbe
...
...
@@ -2377,6 +2377,10 @@ internal BoundExpression GenerateConversionForAssignment(TypeSymbol targetType,
{
Error
(
diagnostics
,
ErrorCode
.
ERR_RefAssignmentMustHaveIdentityConversion
,
expression
.
Syntax
,
targetType
);
}
else
{
return
expression
;
}
}
else
if
(!
conversion
.
IsImplicit
||
!
conversion
.
IsValid
)
{
...
...
@@ -3323,6 +3327,10 @@ private BoundStatement BindReturn(ReturnStatementSyntax syntax, DiagnosticBag di
{
Error
(
diagnostics
,
ErrorCode
.
ERR_RefReturnMustHaveIdentityConversion
,
argument
.
Syntax
,
returnType
);
}
else
{
return
argument
;
}
}
else
if
(!
conversion
.
IsImplicit
||
!
conversion
.
IsValid
)
{
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
23ab0bbe
...
...
@@ -18790,5 +18790,92 @@ static void Main()
});
// no assert hit
}
[Fact]
[WorkItem(14166, "https://github.com/dotnet/roslyn/issues/14166")]
public void RefTuple001()
{
var source = @"
class Program
{
static (int Alice, int Bob)[] arr = new(int Alice, int Bob)[1];
static void Main(string[] args)
{
RefParam(ref arr[0]);
System.Console.WriteLine(arr[0]);
RefReturn().Item2 = 42;
System.Console.WriteLine(arr[0]);
ref (int, int) x = ref arr[0];
x.Item1 = 33;
System.Console.WriteLine(arr[0]);
}
static void RefParam(ref (int, int) p)
{
p.Item1 = 42;
}
static ref (int, int) RefReturn()
{
return ref arr[0];
}
}";
var comp = CompileAndVerify(source,
additionalRefs: s_valueTupleRefs,
parseOptions: TestOptions.Regular, expectedOutput: @"(42, 0)
(42, 42)
(33, 42)");
comp.VerifyIL("Program.Main", @"
{
// Code size 110 (0x6e)
.maxstack 2
IL_0000: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_0005: ldc.i4.0
IL_0006: ldelema ""System.ValueTuple<int, int>""
IL_000b: call ""void Program.RefParam(ref (int, int))""
IL_0010: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_0015: ldc.i4.0
IL_0016: ldelem ""System.ValueTuple<int, int>""
IL_001b: box ""System.ValueTuple<int, int>""
IL_0020: call ""void System.Console.WriteLine(object)""
IL_0025: call ""ref (int, int) Program.RefReturn()""
IL_002a: ldc.i4.s 42
IL_002c: stfld ""int System.ValueTuple<int, int>.Item2""
IL_0031: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_0036: ldc.i4.0
IL_0037: ldelem ""System.ValueTuple<int, int>""
IL_003c: box ""System.ValueTuple<int, int>""
IL_0041: call ""void System.Console.WriteLine(object)""
IL_0046: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_004b: ldc.i4.0
IL_004c: ldelema ""System.ValueTuple<int, int>""
IL_0051: ldc.i4.s 33
IL_0053: stfld ""int System.ValueTuple<int, int>.Item1""
IL_0058: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_005d: ldc.i4.0
IL_005e: ldelem ""System.ValueTuple<int, int>""
IL_0063: box ""System.ValueTuple<int, int>""
IL_0068: call ""void System.Console.WriteLine(object)""
IL_006d: ret
}
");
comp.VerifyIL("Program.RefReturn", @"
{
// Code size 12 (0xc)
.maxstack 2
IL_0000: ldsfld ""(int Alice, int Bob)[] Program.arr""
IL_0005: ldc.i4.0
IL_0006: ldelema ""System.ValueTuple<int, int>""
IL_000b: ret
}
");
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录