Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3eec1c45
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,发现更多精彩内容 >>
提交
3eec1c45
编写于
5月 17, 2016
作者:
A
AlekseyTs
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11328 from AlekseyTs/TupleTests02
Fix some issues around tuples and add unit-tests for others.
上级
602156e9
c46512aa
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
2553 addition
and
870 deletion
+2553
-870
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
...Binder/Semantics/OverloadResolution/OverloadResolution.cs
+5
-11
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
...ble/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
+8
-8
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
...mpilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
...Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
+5
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+2534
-850
未找到文件。
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
浏览文件 @
3eec1c45
...
...
@@ -1832,15 +1832,11 @@ private bool ExpressionMatchExactly(BoundExpression node, TypeSymbol t, ref Hash
if
(
node
.
Kind
==
BoundKind
.
TupleLiteral
)
{
if
((
object
)
node
.
Type
!=
null
)
{
// expression has a natural type and
// did not have identity conversion to the target (since we are here),
// no point trying element-wise match - we know that will fail.
return
false
;
}
// recurse into tuple constituent arguments
// Recurse into tuple constituent arguments.
// Even if the tuple literal has a natural type and conversion
// from that type is not identity, we still have to do this
// because we might be converting to a tuple type backed by
// different definition of ValueTuple type.
return
ExpressionMatchExactly
((
BoundTupleLiteral
)
node
,
t
,
ref
useSiteDiagnostics
);
}
...
...
@@ -1949,8 +1945,6 @@ private bool ExpressionMatchExactly(BoundTupleLiteral tupleSource, TypeSymbol ta
}
var
destination
=
(
NamedTypeSymbol
)
targetType
;
Debug
.
Assert
((
object
)
tupleSource
.
Type
==
null
,
"should not need to dig into elements if tuple has natural type"
);
var
sourceArguments
=
tupleSource
.
Arguments
;
// check if the type is actually compatible type for a tuple of given cardinality
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
浏览文件 @
3eec1c45
...
...
@@ -287,7 +287,8 @@ private void CheckUserDefinedConversionSignature(DiagnosticBag diagnostics)
if
(
source0
!=
this
.
ContainingType
&&
target0
!=
this
.
ContainingType
&&
// allow conversion between T and Nullable<T> in declaration of Nullable<T>
source
!=
this
.
ContainingType
&&
target
!=
this
.
ContainingType
)
source
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
&&
target
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
)
{
// CS0556: User-defined conversion must convert to or from the enclosing type
diagnostics
.
Add
(
ErrorCode
.
ERR_ConversionNotInvolvingContainedType
,
this
.
Locations
[
0
]);
...
...
@@ -416,7 +417,7 @@ private void CheckUnarySignature(DiagnosticBag diagnostics)
// SPEC: A unary + - ! ~ operator must take a single parameter of type
// SPEC: T or T? and can return any type.
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
!=
this
.
ContainingType
)
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
)
{
// The parameter of a unary operator must be the containing type
diagnostics
.
Add
(
ErrorCode
.
ERR_BadUnaryOperatorSignature
,
this
.
Locations
[
0
]);
...
...
@@ -441,7 +442,7 @@ private void CheckTrueFalseSignature(DiagnosticBag diagnostics)
diagnostics
.
Add
(
ErrorCode
.
ERR_OpTFRetType
,
this
.
Locations
[
0
]);
}
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
!=
this
.
ContainingType
)
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
)
{
// The parameter of a unary operator must be the containing type
diagnostics
.
Add
(
ErrorCode
.
ERR_BadUnaryOperatorSignature
,
this
.
Locations
[
0
]);
...
...
@@ -491,7 +492,7 @@ private void CheckIncrementDecrementSignature(DiagnosticBag diagnostics)
var
parameterType
=
this
.
ParameterTypes
[
0
];
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
=
null
;
if
(
parameterType
.
StrippedType
()
!=
this
.
ContainingType
)
if
(
parameterType
.
StrippedType
()
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
)
{
// CS0559: The parameter type for ++ or -- operator must be the containing type
diagnostics
.
Add
(
ErrorCode
.
ERR_BadIncDecSignature
,
this
.
Locations
[
0
]);
...
...
@@ -512,7 +513,7 @@ private void CheckShiftSignature(DiagnosticBag diagnostics)
// SPEC: of which must have type T or T? and the second of which must
// SPEC: have type int or int?, and can return any type.
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
!=
this
.
ContainingType
||
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
.
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
||
this
.
ParameterTypes
[
1
].
StrippedType
().
SpecialType
!=
SpecialType
.
System_Int32
)
{
// CS0546: The first operand of an overloaded shift operator must have the
...
...
@@ -533,9 +534,8 @@ private void CheckBinarySignature(DiagnosticBag diagnostics)
{
// SPEC: A binary nonshift operator must take two parameters, at least
// SPEC: one of which must have the type T or T?, and can return any type.
if
(
this
.
ParameterTypes
[
0
].
StrippedType
()
!=
this
.
ContainingType
&&
this
.
ParameterTypes
[
1
].
StrippedType
()
!=
this
.
ContainingType
)
if
(
this
.
ParameterTypes
[
0
].
StrippedType
().
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
&&
this
.
ParameterTypes
[
1
].
StrippedType
().
TupleUnderlyingTypeOrSelf
()
!=
this
.
ContainingType
)
{
// CS0563: One of the parameters of a binary operator must be the containing type
diagnostics
.
Add
(
ErrorCode
.
ERR_BadBinaryOperatorSignature
,
this
.
Locations
[
0
]);
...
...
src/Compilers/CSharp/Portable/Symbols/Tuples/TupleTypeSymbol.cs
浏览文件 @
3eec1c45
...
...
@@ -352,7 +352,7 @@ private static NamedTypeSymbol GetTupleUnderlyingType(ImmutableArray<TypeSymbol>
if
((
object
)
diagnostics
!=
null
&&
(
object
)
syntax
!=
null
)
{
Binder
.
ReportUseSiteDiagnostics
(
first
TupleType
,
diagnostics
,
syntax
);
Binder
.
ReportUseSiteDiagnostics
(
chained
TupleType
,
diagnostics
,
syntax
);
}
do
...
...
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
浏览文件 @
3eec1c45
...
...
@@ -82,6 +82,11 @@ public static TypeSymbol StrippedType(this TypeSymbol type)
return
type
.
IsNullableType
()
?
type
.
GetNullableUnderlyingType
()
:
type
;
}
public
static
TypeSymbol
TupleUnderlyingTypeOrSelf
(
this
TypeSymbol
type
)
{
return
type
.
TupleUnderlyingType
??
type
;
}
public
static
TypeSymbol
EnumUnderlyingType
(
this
TypeSymbol
type
)
{
return
type
.
IsEnumType
()
?
type
.
GetEnumUnderlyingType
()
:
type
;
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
3eec1c45
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录