Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
d8be99a3
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,发现更多精彩内容 >>
提交
d8be99a3
编写于
10月 12, 2015
作者:
P
Pavel V. Talanov
提交者:
Michael Bogdanov
10月 13, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prohibit @JvmField for private properties
上级
f7164c5b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
1 deletion
+12
-1
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmFieldApplicabilityChecker.kt
...tlin/resolve/jvm/checkers/JvmFieldApplicabilityChecker.kt
+3
-0
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.kt
...sWithStdLib/annotations/jvmField/jvmFieldApplicability.kt
+7
-1
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.txt
...WithStdLib/annotations/jvmField/jvmFieldApplicability.txt
+2
-0
未找到文件。
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JvmFieldApplicabilityChecker.kt
浏览文件 @
d8be99a3
...
...
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.jvm.checkers
import
org.jetbrains.kotlin.descriptors.ClassDescriptor
import
org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import
org.jetbrains.kotlin.descriptors.PropertyDescriptor
import
org.jetbrains.kotlin.descriptors.Visibilities
import
org.jetbrains.kotlin.diagnostics.DiagnosticSink
import
org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import
org.jetbrains.kotlin.psi.JetDeclaration
...
...
@@ -36,6 +37,7 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
enum
class
Problem
(
val
errorMessage
:
String
)
{
NOT_A_PROPERTY
(
"JvmField can only be applied to a property"
),
NOT_FINAL
(
"JvmField can only be applied to final property"
),
PRIVATE
(
"JvmField has no effect on a private property"
),
CUSTOM_ACCESSOR
(
"JvmField cannot be applied to a property with a custom accessor"
),
NO_BACKING_FIELD
(
"JvmField can only be applied to a property with backing field"
),
OVERRIDES
(
"JvmField cannot be applied to a property that overrides some other property"
),
...
...
@@ -56,6 +58,7 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
val
problem
=
when
{
descriptor
!
is
PropertyDescriptor
->
NOT_A_PROPERTY
descriptor
.
modality
.
isOverridable
->
NOT_FINAL
Visibilities
.
isPrivate
(
descriptor
.
visibility
)
->
PRIVATE
!
descriptor
.
hasBackingField
(
bindingContext
)
->
NO_BACKING_FIELD
descriptor
.
hasCustomAccessor
()
->
CUSTOM_ACCESSOR
descriptor
.
overriddenDescriptors
.
isNotEmpty
()
->
OVERRIDES
...
...
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.kt
浏览文件 @
d8be99a3
...
...
@@ -35,6 +35,9 @@ abstract class C : I{
<!
INAPPLICABLE_JVM_FIELD
!>
@JvmField
<!>
final
override
val
ai
=
3
<!
INAPPLICABLE_JVM_FIELD
!>
@JvmField
<!>
private
val
private
=
3
}
interface
I
{
...
...
@@ -71,4 +74,7 @@ interface K {
object
O
{
@JvmField
val
c
=
3
}
\ No newline at end of file
}
<!
INAPPLICABLE_JVM_FIELD
!>
@JvmField
<!>
private
val
private
=
3
\ No newline at end of file
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability.txt
浏览文件 @
d8be99a3
...
...
@@ -2,6 +2,7 @@ package
@kotlin.jvm.JvmField() public const val Const: kotlin.Int = 4
@kotlin.jvm.JvmField() public var i: kotlin.Int
@kotlin.jvm.JvmField() private val private: kotlin.Int = 3
@kotlin.jvm.JvmField() public fun foo(): kotlin.Unit
@kotlin.jvm.JvmField() public abstract class C : I {
...
...
@@ -14,6 +15,7 @@ package
@kotlin.jvm.JvmField() public final val customGetter: kotlin.String = ""
@kotlin.jvm.JvmField() public final var customSetter: kotlin.String
@kotlin.jvm.JvmField() public final val noBackingField: kotlin.String
@kotlin.jvm.JvmField() private final val private: kotlin.Int = 3
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@kotlin.jvm.JvmField() private final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录