Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
bingbingbingbing
mono
提交
08287378
M
mono
项目概览
bingbingbingbing
/
mono
与 Fork 源项目一致
从无法访问的项目Fork
通知
35
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mono
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
08287378
编写于
12月 13, 2010
作者:
M
Marek Safar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[659038] Check interface hierarchy before reporting ambiguous errors
上级
d80ea6c3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
12 deletion
+117
-12
mcs/mcs/ecore.cs
mcs/mcs/ecore.cs
+60
-2
mcs/tests/ver-il-gmcs.xml
mcs/tests/ver-il-gmcs.xml
+57
-10
未找到文件。
mcs/mcs/ecore.cs
浏览文件 @
08287378
...
...
@@ -4175,8 +4175,39 @@ namespace Mono.CSharp {
continue
;
}
// Is the new candidate better
if
(
BetterFunction
(
rc
,
candidate_args
,
member
,
pm
.
Parameters
,
params_expanded_form
,
best_candidate
,
best_parameter_member
.
Parameters
,
best_candidate_params
))
{
bool
is_better
;
if
(
best_candidate
.
DeclaringType
.
IsInterface
&&
member
.
DeclaringType
.
ImplementsInterface
(
best_candidate
.
DeclaringType
,
false
))
{
//
// We pack all interface members into top level type which makes the overload resolution
// more complicated for interfaces. We accomodate for this by removing methods with same
// signature when building the cache hence this path should not really be hit often
//
// Example:
// interface IA { void Foo (int arg); }
// interface IB : IA { void Foo (params int[] args); }
//
// IB::Foo is the best overload when calling IB.Foo (1)
//
is_better
=
true
;
if
(
ambiguous_candidates
!=
null
)
{
foreach
(
var
amb_cand
in
ambiguous_candidates
)
{
if
(
member
.
DeclaringType
.
ImplementsInterface
(
best_candidate
.
DeclaringType
,
false
))
{
continue
;
}
is_better
=
false
;
break
;
}
if
(
is_better
)
ambiguous_candidates
=
null
;
}
}
else
{
// Is the new candidate better
is_better
=
BetterFunction
(
rc
,
candidate_args
,
member
,
pm
.
Parameters
,
params_expanded_form
,
best_candidate
,
best_parameter_member
.
Parameters
,
best_candidate_params
);
}
if
(
is_better
)
{
best_candidate
=
member
;
best_candidate_args
=
candidate_args
;
best_candidate_params
=
params_expanded_form
;
...
...
@@ -4253,6 +4284,33 @@ namespace Mono.CSharp {
}
if
(
ambiguous_candidates
!=
null
)
{
if
(
best_candidate
.
DeclaringType
.
IsInterface
)
{
ambiguous_candidates
.
Add
(
new
AmbiguousCandidate
(
best_candidate
,
best_parameter_member
.
Parameters
,
best_candidate_params
));
for
(
int
cix
=
0
;
cix
<
ambiguous_candidates
.
Count
;
++
cix
)
{
var
tested_type
=
ambiguous_candidates
[
cix
].
Member
.
DeclaringType
;
int
ix
=
0
;
for
(;
ix
<
ambiguous_candidates
.
Count
;
++
ix
)
{
var
amb_cand_type
=
ambiguous_candidates
[
ix
].
Member
.
DeclaringType
;
if
(
amb_cand_type
==
tested_type
)
continue
;
if
(
tested_type
.
ImplementsInterface
(
amb_cand_type
,
false
))
continue
;
break
;
}
if
(
ix
!=
ambiguous_candidates
.
Count
)
continue
;
best_candidate
=
ambiguous_candidates
[
cix
].
Member
;
//best_parameter_member = ambiguous_candidates
throw
new
NotImplementedException
();
}
}
//
// Now check that there are no ambiguities i.e the selected method
// should be better than all the others
...
...
mcs/tests/ver-il-gmcs.xml
浏览文件 @
08287378
...
...
@@ -8986,6 +8986,13 @@
</method>
</type>
</test>
<test name="gtest-333.cs">
<type name="Program">
<method name="Void Main()">
<size>13</size>
</method>
</type>
</test>
<test name="gtest-334.cs">
<type name="Test">
<method name="Void .ctor()">
...
...
@@ -9521,6 +9528,56 @@
</method>
</type>
</test>
<test name="gtest-353.cs">
<type name="A`3[D1,D2,D3]">
<method name="Void Foo[T]()">
<size>1</size>
</method>
<method name="Void .ctor()">
<size>7</size>
</method>
</type>
<type name="B`1[DD2]">
<method name="Void .ctor()">
<size>7</size>
</method>
</type>
<type name="C">
<method name="Void Foo[T]()">
<size>1</size>
</method>
<method name="Void .ctor()">
<size>7</size>
</method>
</type>
<type name="Program">
<method name="Void Main()">
<size>11</size>
</method>
<method name="Void .ctor()">
<size>7</size>
</method>
</type>
</test>
<test name="gtest-354.cs">
<type name="M">
<method name="Void IC.Method(System.Int32[])">
<size>1</size>
</method>
<method name="System.String IA<string>.Method(Int32)">
<size>6</size>
</method>
<method name="Void IB.Method(Int32)">
<size>6</size>
</method>
<method name="Void Main()">
<size>23</size>
</method>
<method name="Void .ctor()">
<size>7</size>
</method>
</type>
</test>
<test name="gtest-355.cs">
<type name="A">
<method name="Void .ctor()">
...
...
@@ -39774,16 +39831,6 @@
</method>
</type>
</test>
<test name="test-679.cs">
<type name="Program">
<method name="Void .ctor()">
<size>7</size>
</method>
<method name="Int32 Main()">
<size>12</size>
</method>
</type>
</test>
<test name="test-68.cs">
<type name="Y">
<method name="Void .ctor()">
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录