Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1f91b316
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,发现更多精彩内容 >>
提交
1f91b316
编写于
7月 09, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master' into testCleanup
上级
8719cfbc
3565c818
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
275 addition
and
4 deletion
+275
-4
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
...Binder/Semantics/OverloadResolution/OverloadResolution.cs
+2
-2
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+143
-0
src/Compilers/VisualBasic/Portable/Semantics/OverloadResolution.vb
...lers/VisualBasic/Portable/Semantics/OverloadResolution.vb
+2
-2
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
+128
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
浏览文件 @
1f91b316
...
...
@@ -1782,8 +1782,8 @@ private static BetterResult MoreSpecificType(TypeSymbol t1, TypeSymbol t2, ref H
// argument is more specific and no type argument is less specific than the
// corresponding type argument in the other.
var
n1
=
t1
as
NamedTypeSymbol
;
var
n2
=
t2
as
NamedTypeSymbol
;
var
n1
=
t1
.
TupleUnderlyingTypeOrSelf
()
as
NamedTypeSymbol
;
var
n2
=
t2
.
TupleUnderlyingTypeOrSelf
()
as
NamedTypeSymbol
;
Debug
.
Assert
(((
object
)
n1
==
null
)
==
((
object
)
n2
==
null
));
if
((
object
)
n1
==
null
)
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
1f91b316
...
...
@@ -23412,5 +23412,148 @@ void M()
Assert.Equal("(System.Int32, System.String, System.Int32)", model.GetTypeInfo(tuple).ConvertedType.ToTestDisplayString());
Assert.Equal(ConversionKind.NoConversion, model.GetConversion(tuple).Kind);
}
[Fact]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
public void MoreGenericTieBreaker_01()
{
var source =
@"using System;
public class C
{
public static void Main()
{
A<A<int>> a = null;
M1(a); // ok, selects M1<T>(A<A<T>> a)
var b = default(ValueTuple<ValueTuple<int, int>, int>);
M2(b); // ok, should select M2<T>(ValueTuple<ValueTuple<T, int>, int> a)
}
public static void M1<T>(A<T> a) { Console.Write(1); }
public static void M1<T>(A<A<T>> a) { Console.Write(2); }
public static void M2<T>(ValueTuple<T, int> a) { Console.Write(3); }
public static void M2<T>(ValueTuple<ValueTuple<T, int>, int> a) { Console.Write(4); }
}
public class A<T> {}";
var comp = CompileAndVerify(source, additionalRefs: s_valueTupleRefs, expectedOutput: "24");
}
[Fact]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
public void MoreGenericTieBreaker_01b()
{
var source =
@"using System;
public class C
{
public static void Main()
{
var b = ((0, 0), 0);
M2(b); // ok, should select M2<T>(((T, int), int) a)
}
public static void M2<T>((T, int) a) { Console.Write(3); }
public static void M2<T>(((T, int), int) a) { Console.Write(4); }
}";
var comp = CompileAndVerify(source, additionalRefs: s_valueTupleRefs, expectedOutput: "4");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/20583")]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
[WorkItem(20583, "https://github.com/dotnet/roslyn/issues/20583")]
public void MoreGenericTieBreaker_02()
{
var source =
@"using System;
public class C
{
public static void Main()
{
// var b = (1, 2, 3, 4, 5, 6, 7, 8);
var b = new ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>(1, 2, 3, 4, 5, 6, 7, new ValueTuple<int>(8));
M1(b);
M2(b); // ok, should select M2<T1, T2, T3, T4, T5, T6, T7, T8>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>> a)
}
public static void M1<T1, T2, T3, T4, T5, T6, T7, TRest>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> a) where TRest : struct { Console.Write(1); }
public static void M2<T1, T2, T3, T4, T5, T6, T7, T8>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>> a) { Console.Write(2); }
public static void M2<T1, T2, T3, T4, T5, T6, T7, TRest>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> a) where TRest : struct { Console.Write(3); }
}
";
var comp = CompileAndVerify(source,
additionalRefs: s_valueTupleRefs,
expectedOutput: @"12");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/20583")]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
[WorkItem(20583, "https://github.com/dotnet/roslyn/issues/20583")]
public void MoreGenericTieBreaker_02b()
{
var source =
@"using System;
public class C
{
public static void Main()
{
var b = (1, 2, 3, 4, 5, 6, 7, 8);
M1(b);
M2(b); // ok, should select M2<T1, T2, T3, T4, T5, T6, T7, T8>((T1, T2, T3, T4, T5, T6, T7, T8) a)
}
public static void M1<T1, T2, T3, T4, T5, T6, T7, TRest>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> a) where TRest : struct { Console.Write(1); }
public static void M2<T1, T2, T3, T4, T5, T6, T7, T8>((T1, T2, T3, T4, T5, T6, T7, T8) a) { Console.Write(2); }
public static void M2<T1, T2, T3, T4, T5, T6, T7, TRest>(ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> a) where TRest : struct { Console.Write(3); }
}
";
var comp = CompileAndVerify(source,
additionalRefs: s_valueTupleRefs,
expectedOutput: @"12");
}
[Fact]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
public void MoreGenericTieBreaker_03()
{
var source =
@"using System;
public class C
{
public static void Main()
{
var b = ((1, 1), 2, 3, 4, 5, 6, 7, 8, 9, (10, 10), (11, 11));
M1(b); // ok, should select M2<T, U, V>(((T, int), int, int, int, int, int, int, int, int, (U, int), V) a)
}
public static void M1<T, U, V>(((T, int), int, int, int, int, int, int, int, int, (U, int), V) a)
{ Console.Write(3); }
public static void M1<T, U, V>((T, int, int, int, int, int, int, int, int, U, (V, int)) a)
{ Console.Write(4); }
}";
var comp = CompileAndVerify(source, additionalRefs: s_valueTupleRefs, expectedOutput: "3");
}
[Fact]
[WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")]
public void MoreGenericTieBreaker_04()
{
var source =
@"using System;
public class C
{
public static void Main()
{
var b = ((1, 1), 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, (20, 20));
M1(b); // error: ambiguous
}
public static void M1<T, U>((T, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, (U, int)) a)
{ Console.Write(3); }
public static void M1<T, U>(((T, int), int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, U) a)
{ Console.Write(4); }
}";
CreateStandardCompilation(source, references: s_valueTupleRefs).VerifyDiagnostics(
// (7,9): error CS0121: The call is ambiguous between the following methods or properties: 'C.M1<T, U>((T, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, (U, int)))' and 'C.M1<T, U>(((T, int), int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, U))'
// M1(b); // error: ambiguous
Diagnostic(ErrorCode.ERR_AmbigCall, "M1").WithArguments("C.M1<T, U>((T, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, (U, int)))", "C.M1<T, U>(((T, int), int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, U))").WithLocation(7, 9)
);
}
}
}
src/Compilers/VisualBasic/Portable/Semantics/OverloadResolution.vb
浏览文件 @
1f91b316
...
...
@@ -4532,8 +4532,8 @@ ContinueCandidatesLoop:
' Both are generics
If
leftType
.
Kind
=
SymbolKind
.
NamedType
AndAlso
rightType
.
Kind
=
SymbolKind
.
NamedType
Then
Dim
leftNamedType
=
DirectCast
(
leftType
,
NamedTypeSymbol
)
Dim
rightNamedType
=
DirectCast
(
rightType
,
NamedTypeSymbol
)
Dim
leftNamedType
=
DirectCast
(
leftType
.
GetTupleUnderlyingTypeOrSelf
()
,
NamedTypeSymbol
)
Dim
rightNamedType
=
DirectCast
(
rightType
.
GetTupleUnderlyingTypeOrSelf
()
,
NamedTypeSymbol
)
' If their arities are equal
If
leftNamedType
.
Arity
=
rightNamedType
.
Arity
Then
...
...
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb
浏览文件 @
1f91b316
...
...
@@ -20396,6 +20396,134 @@ BC30311: Value of type '(e As Integer?, String)' cannot be converted to '(Intege
Assert.Equal(ConversionKind.DelegateRelaxationLevelNone, model.GetConversion(node).Kind)
End Sub
<Fact>
<WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")>
Public Sub MoreGenericTieBreaker_01()
Dim verifier = CompileAndVerify(
<compilation>
<file name="a.vb">
Option Strict On
Imports System
Module Module1
Public Sub Main()
Dim a As A(Of A(Of Integer)) = Nothing
M1(a) ' ok, selects M1(Of T)(A(Of A(Of T)) a)
Dim b = New ValueTuple(Of ValueTuple(Of Integer, Integer), Integer)()
M2(b) ' ok, should select M2(Of T)(ValueTuple(Of ValueTuple(Of T, Integer), Integer) a)
End Sub
Public Sub M1(Of T)(a As A(Of T))
Console.Write(1)
End Sub
Public Sub M1(Of T)(a As A(Of A(Of T)))
Console.Write(2)
End Sub
Public Sub M2(Of T)(a As ValueTuple(Of T, Integer))
Console.Write(3)
End Sub
Public Sub M2(Of T)(a As ValueTuple(Of ValueTuple(Of T, Integer), Integer))
Console.Write(4)
End Sub
End Module
Public Class A(Of T)
End Class
</file>
</compilation>, additionalRefs:=s_valueTupleRefs, expectedOutput:=<![CDATA[
24
]]>)
End Sub
<Fact>
<WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")>
Public Sub MoreGenericTieBreaker_01b()
Dim verifier = CompileAndVerify(
<compilation>
<file name="a.vb">
Option Strict On
Imports System
Module Module1
Public Sub Main()
Dim b = ((0, 0), 0)
M2(b) ' ok, should select M2(Of T)(ValueTuple(Of ValueTuple(Of T, Integer), Integer) a)
End Sub
Public Sub M2(Of T)(a As (T, Integer))
Console.Write(3)
End Sub
Public Sub M2(Of T)(a As ((T, Integer), Integer))
Console.Write(4)
End Sub
End Module
</file>
</compilation>, additionalRefs:=s_valueTupleRefs, expectedOutput:=<![CDATA[
4
]]>)
End Sub
<Fact>
<WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")>
Public Sub MoreGenericTieBreaker_03()
Dim verifier = CompileAndVerify(
<compilation>
<file name="a.vb">
Option Strict On
Imports System
Module Module1
Public Sub Main()
Dim b = ((1, 1), 2, 3, 4, 5, 6, 7, 8, 9, (10, 10), (11, 11))
M1(b) ' ok, should select M1(Of T, U, V)(a As ((T, Integer), Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, (U, Integer), V))
End Sub
Sub M1(Of T, U, V)(a As ((T, Integer), Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, (U, Integer), V))
Console.Write(3)
End Sub
Sub M1(Of T, U, V)(a As (T, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, U, (V, Integer)))
Console.Write(4)
End Sub
End Module
</file>
</compilation>, additionalRefs:=s_valueTupleRefs, expectedOutput:=<![CDATA[
3
]]>)
End Sub
<Fact>
<WorkItem(20494, "https://github.com/dotnet/roslyn/issues/20494")>
Public Sub MoreGenericTieBreaker_04()
Dim source =
<compilation>
<file name="a.vb">
Option Strict On
Imports System
Module Module1
Public Sub Main()
Dim b = ((1, 1), 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, (20, 20))
M1(b) ' error: ambiguous
End Sub
Sub M1(Of T, U)(a As (T, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, (U, Integer)))
Console.Write(3)
End Sub
Sub M1(Of T, U)(a As ((T, Integer), Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, U))
Console.Write(4)
End Sub
End Module
</file>
</compilation>
Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntimeAndReferences(source, additionalRefs:=s_valueTupleRefs)
comp.VerifyDiagnostics(
Diagnostic(ERRID.ERR_NoMostSpecificOverload2, "M1").WithArguments("M1", "
'Public Sub M1(Of (Integer, Integer), Integer)(a As ((Integer, Integer), Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer)))': Not most specific.
'Public Sub M1(Of Integer, (Integer, Integer))(a As ((Integer, Integer), Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer, Integer)))': Not most specific.").WithLocation(7, 9)
)
End Sub
End Class
End Namespace
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录