Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
8473be35
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8473be35
编写于
10月 13, 2015
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Effective visibility: separate InternalProtected and InternalProtectedBound, messages, test change
上级
4dbd7e7f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
66 deletion
+84
-66
compiler/testData/diagnostics/tests/exposed/protectedInProtected.kt
...estData/diagnostics/tests/exposed/protectedInProtected.kt
+2
-7
compiler/testData/diagnostics/tests/exposed/protectedInProtected.txt
...stData/diagnostics/tests/exposed/protectedInProtected.txt
+4
-24
core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt
...c/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt
+78
-35
未找到文件。
compiler/testData/diagnostics/tests/exposed/protectedInProtected.kt
浏览文件 @
8473be35
// See KT-9540
// all protected should have lower bound that is more permissive than private
// protected and internal should have lower bound that is more permissive than private
open
class
A
{
private
interface
B
protected
open
class
C
{
protected
interface
D
:
<!
EXPOSED_SUPER_INTERFACE
!>
B
<
!
>
internal
interface
E
:
<!
EXPOSED_SUPER_INTERFACE
!>
B
<
!
>,
<!
EXPOSED_SUPER_INTERFACE
!>
D
<
!
>
}
}
// protected and internal should have lower bound that is more permissive than private
open
class
AA
{
private
interface
BB
protected
open
class
CC
{
internal
interface
DD
:
<!
EXPOSED_SUPER_INTERFACE
!>
BB
<
!
>
}
}
compiler/testData/diagnostics/tests/exposed/protectedInProtected.txt
浏览文件 @
8473be35
...
...
@@ -23,31 +23,11 @@ public open class A {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
}
public open class AA {
public constructor AA()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
private interface BB {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
protected open class CC {
public constructor CC()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal interface DD : AA.BB {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
internal interface E : A.B, A.C.D {
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
}
}
core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt
浏览文件 @
8473be35
...
...
@@ -28,10 +28,11 @@ sealed class EffectiveVisibility(val name: String) {
// /--/ | \-------------\
// Protected(Base) | \
// | Protected(Other) Internal
// Protected(Derived) | /
// | | /
// ProtectedBound /
// \InternalProtected
// Protected(Derived) | / \
// | | / InternalProtected(Base)
// ProtectedBound / \
// \ / /InternalProtected(Derived)
// \InternalProtectedBound/
// |
// Private
...
...
@@ -48,15 +49,16 @@ sealed class EffectiveVisibility(val name: String) {
object
Internal
:
EffectiveVisibility
(
"internal"
)
{
override
fun
relation
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
->
Permissiveness
.
LESS
Private
,
InternalProtected
->
Permissiveness
.
MORE
Private
,
InternalProtected
Bound
,
is
InternalProtected
->
Permissiveness
.
MORE
Internal
->
Permissiveness
.
SAME
ProtectedBound
,
is
Protected
->
Permissiveness
.
UNKNOWN
}
override
fun
lowerBound
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
->
this
Private
,
InternalProtected
,
Internal
->
other
ProtectedBound
,
is
Protected
->
InternalProtected
Private
,
InternalProtectedBound
,
Internal
,
is
InternalProtected
->
other
is
Protected
->
InternalProtected
(
other
.
container
)
ProtectedBound
->
InternalProtectedBound
}
}
...
...
@@ -70,61 +72,85 @@ sealed class EffectiveVisibility(val name: String) {
override
fun
relation
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
->
Permissiveness
.
LESS
Private
,
ProtectedBound
,
InternalProtected
->
Permissiveness
.
MORE
is
Protected
->
{
if
(
container
==
null
||
other
.
container
==
null
)
{
Permissiveness
.
UNKNOWN
}
else
if
(
container
==
other
.
container
)
{
Permissiveness
.
SAME
}
else
if
(
DescriptorUtils
.
isSubclass
(
container
,
other
.
container
))
{
Permissiveness
.
LESS
}
else
if
(
DescriptorUtils
.
isSubclass
(
other
.
container
,
container
))
{
Permissiveness
.
MORE
}
else
{
Permissiveness
.
UNKNOWN
}
Private
,
ProtectedBound
,
InternalProtectedBound
->
Permissiveness
.
MORE
is
Protected
->
containerRelation
(
container
,
other
.
container
)
is
InternalProtected
->
when
(
containerRelation
(
container
,
other
.
container
))
{
Permissiveness
.
SAME
,
Permissiveness
.
LESS
->
Permissiveness
.
LESS
Permissiveness
.
UNKNOWN
,
Permissiveness
.
MORE
->
Permissiveness
.
UNKNOWN
}
Internal
->
Permissiveness
.
UNKNOWN
}
override
fun
lowerBound
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
->
this
Private
,
ProtectedBound
,
InternalProtected
->
other
Private
,
ProtectedBound
,
InternalProtected
Bound
->
other
is
Protected
->
when
(
relation
(
other
))
{
Permissiveness
.
SAME
,
Permissiveness
.
MORE
->
this
Permissiveness
.
LESS
->
other
Permissiveness
.
UNKNOWN
->
ProtectedBound
}
Internal
->
InternalProtected
is
InternalProtected
->
when
(
relation
(
other
))
{
Permissiveness
.
LESS
->
other
else
->
InternalProtectedBound
}
Internal
->
InternalProtected
(
container
)
}
}
// Lower bound for all protected visibilities
object
ProtectedBound
:
EffectiveVisibility
(
"
protected(_)
"
)
{
object
ProtectedBound
:
EffectiveVisibility
(
"
most protected
"
)
{
override
fun
relation
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
,
is
Protected
->
Permissiveness
.
LESS
Private
,
InternalProtected
->
Permissiveness
.
MORE
Private
,
InternalProtected
Bound
->
Permissiveness
.
MORE
ProtectedBound
->
Permissiveness
.
SAME
Internal
->
Permissiveness
.
UNKNOWN
Internal
,
is
InternalProtected
->
Permissiveness
.
UNKNOWN
}
override
fun
lowerBound
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
,
is
Protected
->
this
Private
,
ProtectedBound
,
InternalProtected
->
other
Internal
->
InternalProtecte
d
Private
,
ProtectedBound
,
InternalProtected
Bound
->
other
Internal
,
is
InternalProtected
->
InternalProtectedBoun
d
}
}
// Lower bound for Internal and Protected
object
InternalProtected
:
EffectiveVisibility
(
"internal/protected"
)
{
// Lower bound for internal and protected(C)
class
InternalProtected
(
val
container
:
ClassDescriptor
?):
EffectiveVisibility
(
"protected & internal"
)
{
override
fun
equals
(
other
:
Any
?)
=
(
other
is
InternalProtected
&&
container
==
other
.
container
)
override
fun
hashCode
()
=
container
?.
hashCode
()
?:
0
override
fun
toString
()
=
"${super.toString()}(${container?.name ?: '?'})"
override
fun
relation
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
,
is
Protected
,
ProtectedBound
,
Internal
->
Permissiveness
.
LESS
Public
,
Internal
->
Permissiveness
.
LESS
Private
,
InternalProtectedBound
->
Permissiveness
.
MORE
is
InternalProtected
->
containerRelation
(
container
,
other
.
container
)
is
Protected
->
when
(
containerRelation
(
container
,
other
.
container
))
{
Permissiveness
.
SAME
,
Permissiveness
.
MORE
->
Permissiveness
.
MORE
Permissiveness
.
UNKNOWN
,
Permissiveness
.
LESS
->
Permissiveness
.
UNKNOWN
}
ProtectedBound
->
Permissiveness
.
UNKNOWN
}
override
fun
lowerBound
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
,
Internal
->
this
Private
,
InternalProtectedBound
->
other
is
Protected
,
is
InternalProtected
->
when
(
relation
(
other
))
{
Permissiveness
.
SAME
,
Permissiveness
.
MORE
->
this
Permissiveness
.
LESS
->
other
Permissiveness
.
UNKNOWN
->
InternalProtectedBound
}
ProtectedBound
->
InternalProtectedBound
}
}
// Lower bound for internal and protected lower bound
object
InternalProtectedBound
:
EffectiveVisibility
(
"most protected & internal"
)
{
override
fun
relation
(
other
:
EffectiveVisibility
)
=
when
(
other
)
{
Public
,
is
Protected
,
is
InternalProtected
,
ProtectedBound
,
Internal
->
Permissiveness
.
LESS
Private
->
Permissiveness
.
MORE
InternalProtected
->
Permissiveness
.
SAME
InternalProtected
Bound
->
Permissiveness
.
SAME
}
}
...
...
@@ -150,6 +176,23 @@ sealed class EffectiveVisibility(val name: String) {
companion
object
{
internal
fun
containerRelation
(
first
:
ClassDescriptor
?,
second
:
ClassDescriptor
?):
Permissiveness
=
if
(
first
==
null
||
second
==
null
)
{
Permissiveness
.
UNKNOWN
}
else
if
(
first
==
second
)
{
Permissiveness
.
SAME
}
else
if
(
DescriptorUtils
.
isSubclass
(
first
,
second
))
{
Permissiveness
.
LESS
}
else
if
(
DescriptorUtils
.
isSubclass
(
second
,
first
))
{
Permissiveness
.
MORE
}
else
{
Permissiveness
.
UNKNOWN
}
private
fun
lowerBound
(
first
:
EffectiveVisibility
,
second
:
EffectiveVisibility
)
=
first
.
lowerBound
(
second
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录