Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cd6a3e3c
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,发现更多精彩内容 >>
提交
cd6a3e3c
编写于
1月 11, 2017
作者:
A
AlekseyTs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve method type argument inference around nullable tuples.
Fixes #14152.
上级
db716fad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
6 deletion
+60
-6
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+40
-1
src/Compilers/VisualBasic/Portable/Semantics/TypeInference/TypeArgumentInference.vb
...Portable/Semantics/TypeInference/TypeArgumentInference.vb
+6
-4
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
+14
-1
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
cd6a3e3c
...
...
@@ -8453,10 +8453,16 @@ static void Main()
{
// nested tuple literals set lower bounds
Test1((a: 1, b: (a: 1, b: 2)), (a: 1, b: (object)1));
Test1(Nullable((a: 1, b: (a: 1, b: 2))), (a: 1, b: (object)1));
Test1((a: 1, b: (a: 1, b: 2)), (a: 1, b: (c: 1, d: 2)));
Test1((a: 1, b: (a: 1, b: 2)), (a: 1, b: (1, 2)));
Test1((a: 1, b: (a: 1, b: 2)), (a: 1, b: (a: 1, b: 2)));
}
}
static T? Nullable<T>(T x) where T : struct
{
return x;
}
static void Test1<T, U>((T, U)? x, (T, U) y)
{
...
...
@@ -8469,12 +8475,45 @@ static void Main()
additionalRefs: s_valueTupleRefs,
parseOptions: TestOptions.Regular, expectedOutput: @"
System.Object
System.Object
System.ValueTuple`2[System.Int32,System.Int32]
System.ValueTuple`2[System.Int32,System.Int32]
System.ValueTuple`2[System.Int32,System.Int32]
");
}
[Fact]
public void Inference13_Err()
{
var source = @"
class C
{
static void Main()
{
Test1(Nullable((a: 1, b: (a: 1, b: 2))), (a: 1, b: (object)1));
}
static T? Nullable<T>(T x) where T : struct
{
return x;
}
static void Test1<T, U>((T, U) x, (T, U) y)
{
System.Console.WriteLine(typeof(U));
}
}
";
var comp = CreateCompilationWithMscorlib(source,
references: s_valueTupleRefs);
comp.VerifyDiagnostics(
// (6,15): error CS1503: Argument 1: cannot convert from '(int a, (int a, int b) b)?' to '(int, object)'
// Test1(Nullable((a: 1, b: (a: 1, b: 2))), (a: 1, b: (object)1));
Diagnostic(ErrorCode.ERR_BadArgType, "Nullable((a: 1, b: (a: 1, b: 2)))").WithArguments("1", "(int a, (int a, int b) b)?", "(int, object)").WithLocation(6, 15)
);
}
[Fact]
public void Inference14()
{
...
...
src/Compilers/VisualBasic/Portable/Semantics/TypeInference/TypeArgumentInference.vb
浏览文件 @
cd6a3e3c
...
...
@@ -1408,11 +1408,13 @@ HandleAsAGeneralExpression:
Dim
parameterElementTypes
As
ImmutableArray
(
Of
TypeSymbol
)
=
Nothing
If
parameterType
.
TryGetElementTypesIfTupleOrCompatible
(
parameterElementTypes
)
Then
Dim
argumentElementTypes
As
ImmutableArray
(
Of
TypeSymbol
)
=
Nothing
Dim
argumentElementTypes
As
ImmutableArray
(
Of
TypeSymbol
)
=
Nothing
If
Not
argumentType
.
TryGetElementTypesIfTupleOrCompatible
(
argumentElementTypes
)
OrElse
parameterElementTypes
.
Length
<>
argumentElementTypes
.
Length
Then
If
parameterType
.
GetNullableUnderlyingTypeOrSelf
().
TryGetElementTypesIfTupleOrCompatible
(
parameterElementTypes
)
AndAlso
If
(
parameterType
.
IsNullableType
(),
argumentType
.
GetNullableUnderlyingTypeOrSelf
(),
argumentType
).
TryGetElementTypesIfTupleOrCompatible
(
argumentElementTypes
)
Then
If
parameterElementTypes
.
Length
<>
argumentElementTypes
.
Length
Then
Return
False
End
If
...
...
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
浏览文件 @
cd6a3e3c
...
...
@@ -12966,7 +12966,8 @@ System.ValueTuple`2[System.Int32,System.Int32]
End Sub
<Fact(Skip:="https://github.com/dotnet/roslyn/issues/14152")>
<Fact>
<WorkItem(14152, "https://github.com/dotnet/roslyn/issues/14152")>
Public Sub Inference13()
Dim comp = CreateCompilationWithMscorlibAndVBRuntime(
...
...
@@ -12976,14 +12977,24 @@ Imports System
Public Class C
Shared Sub Main()
Test1((a:=1, b:=(a:=1, b:=2)), (a:=1, b:=DirectCast(1, Object)))
Test1(Nullable((a:=1, b:=(a:=1, b:=2))), (a:=1, b:=DirectCast(1, Object)))
Test2(Nullable((a:=1, b:=(a:=1, b:=2))), (a:=1, b:=DirectCast(1, Object)))
Test1((a:=1, b:=(a:=1, b:=2)), (a:=1, b:=(c:=1, d:=2)))
Test1((a:=1, b:=(a:=1, b:=2)), (a:=1, b:=(1, 2)))
Test1((a:=1, b:=(a:=1, b:=2)), (a:=1, b:=(a:=1, b:=2)))
End Sub
Shared Function Nullable(Of T as structure)(x as T) as T?
return x
End Function
Shared Sub Test1(Of T, U)(x As (T, U)?, y As (T, U))
Console.WriteLine(GetType(U))
End Sub
Shared Sub Test2(Of T, U)(x As (T, U), y As (T, U))
Console.WriteLine(GetType(U))
End Sub
End Class
</file>
</compilation>,
...
...
@@ -12991,6 +13002,8 @@ options:=TestOptions.ReleaseExe, additionalRefs:=s_valueTupleRefs)
CompileAndVerify(comp, expectedOutput:="
System.Object
System.Object
System.Object
System.ValueTuple`2[System.Int32,System.Int32]
System.ValueTuple`2[System.Int32,System.Int32]
System.ValueTuple`2[System.Int32,System.Int32]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录