Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7280be7f
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,发现更多精彩内容 >>
提交
7280be7f
编写于
11月 28, 2016
作者:
T
Ty Overby
提交者:
GitHub
11月 28, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15466 from TyOverby/9703-vb-bad-emit
avoid double-pop in an ignored conversion expression
上级
5085afa5
55a2caad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
8 deletion
+75
-8
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
+31
-0
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
+4
-8
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTests.vb
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTests.vb
+40
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
浏览文件 @
7280be7f
...
...
@@ -15488,5 +15488,36 @@ public static void Main(string[] args)
expectedOutput
:
"0"
);
}
[
Fact
,
WorkItem
(
9703
,
"https://github.com/dotnet/roslyn/issues/9703"
)]
public
void
IgnoredConversion
()
{
string
source
=
@"
using System;
public class Form1 {
public class BadCompiler {
public DateTime? Value {get; set;}
}
private BadCompiler TestObj = new BadCompiler();
public void IPE() {
object o;
o = TestObj.Value;
}
}"
;
var
compilation
=
CompileAndVerify
(
source
);
compilation
.
VerifyIL
(
"Form1.IPE"
,
@"
{
// Code size 13 (0xd)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldfld ""Form1.BadCompiler Form1.TestObj""
IL_0006: callvirt ""System.DateTime? Form1.BadCompiler.Value.get""
IL_000b: pop
IL_000c: ret
}"
);
}
}
}
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
浏览文件 @
7280be7f
...
...
@@ -160,19 +160,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGen
ElseIf
typeFrom
.
IsNullableType
Then
Debug
.
Assert
(
typeTo
.
IsReferenceType
)
EmitExpression
(
conversion
.
Operand
,
used
:
=
True
)
If
(
conversion
.
ConversionKind
And
ConversionKind
.
Narrowing
)
<>
0
Then
EmitExpression
(
conversion
.
Operand
,
True
)
EmitBox
(
typeFrom
,
conversion
.
Operand
.
Syntax
)
_builder
.
EmitOpCode
(
ILOpCode
.
Castclass
)
EmitSymbolToken
(
typeTo
,
conversion
.
Syntax
)
Else
ElseIf
used
Then
' boxing itself is CLR-widening, so no need to emit unused boxing
EmitExpression
(
conversion
.
Operand
,
used
)
If
used
Then
EmitBox
(
typeFrom
,
conversion
.
Operand
.
Syntax
)
End
If
EmitBox
(
typeFrom
,
conversion
.
Operand
.
Syntax
)
End
If
ElseIf
typeTo
.
IsNullableType
Then
...
...
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTests.vb
浏览文件 @
7280be7f
...
...
@@ -13580,5 +13580,45 @@ End Class
]]>)
End Sub
<Fact, WorkItem(9703, "
https
:
//
github
.
com
/
dotnet
/
roslyn
/
issues
/
9703
")>
Public Sub IgnoredConversion()
CompileAndVerify(
<compilation>
<file name="
ignoreNullableValue
.
vb
">
Module MainModule
Public Class Form1
Public Class BadCompiler
Public Property Value As Date?
End Class
Private TestObj As BadCompiler = New BadCompiler()
Public Sub IPE()
Dim o as Object
o = TestObj.Value
End Sub
End Class
Public Sub Main()
Dim f = new Form1
f.IPE()
End Sub
End Module
</file>
</compilation>).
VerifyIL("
MainModule
.
Form1
.
IPE
",
<![CDATA[
{
// Code size 13 (0xd)
.maxstack 1
IL_0000: ldarg.0
IL_0001: ldfld "
MainModule
.
Form1
.
TestObj
As
MainModule
.
Form1
.
BadCompiler
"
IL_0006: callvirt "
Function
MainModule
.
Form1
.
BadCompiler
.
get_Value
()
As
Date
?
"
IL_000b: pop
IL_000c: ret
}
]]>)
End Sub
End Class
End Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录