Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
84eb1010
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,发现更多精彩内容 >>
提交
84eb1010
编写于
1月 14, 2016
作者:
L
Llewellyn Pritchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #7878
上级
bb0ff321
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
2 deletion
+63
-2
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
...rp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
+6
-2
src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
...ilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
+57
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs
浏览文件 @
84eb1010
...
...
@@ -225,6 +225,7 @@ internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList
var
baseInterfaces
=
ArrayBuilder
<
NamedTypeSymbol
>.
GetInstance
();
NamedTypeSymbol
baseType
=
null
;
SourceLocation
baseTypeLocation
=
null
;
foreach
(
var
decl
in
this
.
declaration
.
Declarations
)
{
...
...
@@ -238,18 +239,21 @@ internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList
if
((
object
)
baseType
==
null
)
{
baseType
=
partBase
;
baseTypeLocation
=
decl
.
NameLocation
;
}
else
if
(
baseType
.
TypeKind
==
TypeKind
.
Error
&&
(
object
)
partBase
!=
null
)
{
// if the old base was an error symbol, copy it to the interfaces list so it doesn't get lost
partInterfaces
=
partInterfaces
.
Add
(
baseType
);
baseType
=
partBase
;
baseTypeLocation
=
decl
.
NameLocation
;
}
else
if
((
object
)
partBase
!=
null
&&
partBase
!=
baseType
&&
partBase
.
TypeKind
!=
TypeKind
.
Error
)
{
// the parts do not agree
var
info
=
diagnostics
.
Add
(
ErrorCode
.
ERR_PartialMultipleBases
,
Locations
[
0
],
this
);
baseType
=
new
ExtendedErrorTypeSymbol
(
baseType
,
LookupResultKind
.
Ambiguous
,
info
);
baseTypeLocation
=
decl
.
NameLocation
;
reportedPartialConflict
=
true
;
}
}
...
...
@@ -273,7 +277,7 @@ internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList
if
((
object
)
baseType
!=
null
&&
baseType
.
IsStatic
)
{
// '{1}': cannot derive from static class '{0}'
diagnostics
.
Add
(
ErrorCode
.
ERR_StaticBaseClass
,
Locations
[
0
],
baseType
,
this
);
diagnostics
.
Add
(
ErrorCode
.
ERR_StaticBaseClass
,
baseTypeLocation
??
Locations
[
0
],
baseType
,
this
);
}
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
=
null
;
...
...
@@ -281,7 +285,7 @@ internal override ImmutableArray<NamedTypeSymbol> GetDeclaredInterfaces(ConsList
if
((
object
)
baseType
!=
null
&&
!
this
.
IsNoMoreVisibleThan
(
baseType
,
ref
useSiteDiagnostics
))
{
// Inconsistent accessibility: base class '{1}' is less accessible than class '{0}'
diagnostics
.
Add
(
ErrorCode
.
ERR_BadVisBaseClass
,
Locations
[
0
],
this
,
baseType
);
diagnostics
.
Add
(
ErrorCode
.
ERR_BadVisBaseClass
,
baseTypeLocation
??
Locations
[
0
],
this
,
baseType
);
}
var
baseInterfacesRO
=
baseInterfaces
.
ToImmutableAndFree
();
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/Source/BaseClassTests.cs
浏览文件 @
84eb1010
...
...
@@ -338,6 +338,63 @@ public class E : C.X { }
);
}
[
Fact
,
WorkItem
(
7878
,
"https://github.com/dotnet/roslyn/issues/7878"
)]
public
void
BadVisibilityPartial
()
{
var
text
=
@"
internal class NV
{
}
public partial class C1
{
}
partial class C1 : NV
{
}
public partial class C1
{
}
"
;
var
comp
=
CreateCompilationWithMscorlib
(
text
);
comp
.
VerifyDiagnostics
(
// (10,15): error CS0060: Inconsistent accessibility: base class 'NV' is less accessible than class 'C1'
// partial class C1 : NV
Diagnostic
(
ErrorCode
.
ERR_BadVisBaseClass
,
"C1"
).
WithArguments
(
"C1"
,
"NV"
).
WithLocation
(
10
,
15
));
}
[
Fact
,
WorkItem
(
7878
,
"https://github.com/dotnet/roslyn/issues/7878"
)]
public
void
StaticBasePartial
()
{
var
text
=
@"
static class NV
{
}
public partial class C1
{
}
partial class C1 : NV
{
}
public partial class C1
{
}
"
;
var
comp
=
CreateCompilationWithMscorlib
(
text
);
comp
.
VerifyDiagnostics
(
// (10,15): error CS0709: 'C1': cannot derive from static class 'NV'
// partial class C1 : NV
Diagnostic
(
ErrorCode
.
ERR_StaticBaseClass
,
"C1"
).
WithArguments
(
"NV"
,
"C1"
).
WithLocation
(
10
,
15
),
// (10,15): error CS0060: Inconsistent accessibility: base class 'NV' is less accessible than class 'C1'
// partial class C1 : NV
Diagnostic
(
ErrorCode
.
ERR_BadVisBaseClass
,
"C1"
).
WithArguments
(
"C1"
,
"NV"
).
WithLocation
(
10
,
15
));
}
[
Fact
]
public
void
EricLiCase1
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录