Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
4b8ecaaf
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
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,发现更多精彩内容 >>
提交
4b8ecaaf
编写于
3月 27, 2018
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a regression test for
https://github.com/dotnet/roslyn/issues/25024
上级
0b35308e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
0 deletion
+90
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs
...mpilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs
+90
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenRefReturnTests.cs
浏览文件 @
4b8ecaaf
...
...
@@ -3590,5 +3590,95 @@ static void Main()
Program+RefFunc1`2[Derived1,Base]"
,
verify
:
Verification
.
Passes
);
}
[
WorkItem
(
25024
,
"https://github.com/dotnet/roslyn/issues/25024"
)]
[
Fact
]
public
void
RefReturnDiscardLifetime
()
{
var
text
=
@"
class Program
{
static bool flag = true;
public static void Main()
{
if (flag)
{
ref var local1 = ref M1(out var _);
ref var local2 = ref M1(out var _);
local1 = 1;
local2 = 2;
System.Console.Write(local1 + local2);
}
if (flag)
{
ref var local1 = ref M1(out var _);
ref var local2 = ref M1(out var _);
local1 = 3;
local2 = 4;
System.Console.Write(local1 + local2);
}
}
public static ref int M1(out int arg)
{
arg = 123;
return ref arg;
}
}
"
;
CompileAndVerifyRef
(
text
,
expectedOutput
:
"37"
,
verify
:
Verification
.
Fails
).
VerifyIL
(
"Program.Main()"
,
@"
{
// Code size 75 (0x4b)
.maxstack 3
.locals init (int& V_0, //local2
int V_1,
int V_2,
int& V_3, //local2
int V_4,
int V_5)
IL_0000: ldsfld ""bool Program.flag""
IL_0005: brfalse.s IL_0025
IL_0007: ldloca.s V_1
IL_0009: call ""ref int Program.M1(out int)""
IL_000e: ldloca.s V_2
IL_0010: call ""ref int Program.M1(out int)""
IL_0015: stloc.0
IL_0016: dup
IL_0017: ldc.i4.1
IL_0018: stind.i4
IL_0019: ldloc.0
IL_001a: ldc.i4.2
IL_001b: stind.i4
IL_001c: ldind.i4
IL_001d: ldloc.0
IL_001e: ldind.i4
IL_001f: add
IL_0020: call ""void System.Console.Write(int)""
IL_0025: ldsfld ""bool Program.flag""
IL_002a: brfalse.s IL_004a
IL_002c: ldloca.s V_4
IL_002e: call ""ref int Program.M1(out int)""
IL_0033: ldloca.s V_5
IL_0035: call ""ref int Program.M1(out int)""
IL_003a: stloc.3
IL_003b: dup
IL_003c: ldc.i4.3
IL_003d: stind.i4
IL_003e: ldloc.3
IL_003f: ldc.i4.4
IL_0040: stind.i4
IL_0041: ldind.i4
IL_0042: ldloc.3
IL_0043: ldind.i4
IL_0044: add
IL_0045: call ""void System.Console.Write(int)""
IL_004a: ret
}"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录