Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
ccf0c363
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,发现更多精彩内容 >>
提交
ccf0c363
编写于
10月 13, 2015
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Volatile is no more allowed on values #KT-7670 Fixed
上级
8473be35
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
51 addition
and
1 deletion
+51
-1
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt
...brains/kotlin/resolve/jvm/checkers/declarationCheckers.kt
+14
-0
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java
...tlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java
+1
-0
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java
...g/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java
+4
-0
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt
...ns/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt
+3
-1
compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt
...tData/diagnostics/testsWithStdLib/annotations/Volatile.kt
+7
-0
compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.txt
...Data/diagnostics/testsWithStdLib/annotations/Volatile.txt
+10
-0
compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java
...otlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java
+6
-0
core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java
...ors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java
+6
-0
未找到文件。
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt
浏览文件 @
ccf0c363
...
...
@@ -128,6 +128,20 @@ public class JvmNameAnnotationChecker : DeclarationChecker {
}
}
public
class
VolatileAnnotationChecker
:
DeclarationChecker
{
override
fun
check
(
declaration
:
JetDeclaration
,
descriptor
:
DeclarationDescriptor
,
diagnosticHolder
:
DiagnosticSink
,
bindingContext
:
BindingContext
)
{
val
volatileAnnotation
=
DescriptorUtils
.
getVolatileAnnotation
(
descriptor
)
if
(
volatileAnnotation
!=
null
&&
descriptor
is
PropertyDescriptor
&&
!
descriptor
.
isVar
)
{
val
annotationEntry
=
DescriptorToSourceUtils
.
getSourceFromAnnotation
(
volatileAnnotation
)
?:
return
diagnosticHolder
.
report
(
ErrorsJvm
.
VOLATILE_ON_VALUE
.
on
(
annotationEntry
))
}
}
}
public
class
OverloadsAnnotationChecker
:
DeclarationChecker
{
override
fun
check
(
...
...
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java
浏览文件 @
ccf0c363
...
...
@@ -53,6 +53,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP
.
put
(
ErrorsJvm
.
OVERLOADS_PRIVATE
,
"''JvmOverloads'' annotation has no effect on private and local declarations"
);
MAP
.
put
(
ErrorsJvm
.
INAPPLICABLE_JVM_NAME
,
"''JvmName'' annotation is not applicable to this declaration"
);
MAP
.
put
(
ErrorsJvm
.
ILLEGAL_JVM_NAME
,
"Illegal JVM name"
);
MAP
.
put
(
ErrorsJvm
.
VOLATILE_ON_VALUE
,
"''Volatile'' annotation cannot be used on immutable properties"
);
MAP
.
put
(
ErrorsJvm
.
EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT
,
"External declaration can not be abstract"
);
MAP
.
put
(
ErrorsJvm
.
EXTERNAL_DECLARATION_CANNOT_HAVE_BODY
,
"External declaration can not have a body"
);
MAP
.
put
(
ErrorsJvm
.
EXTERNAL_DECLARATION_IN_INTERFACE
,
"Members of interfaces can not be external"
);
...
...
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java
浏览文件 @
ccf0c363
...
...
@@ -50,6 +50,8 @@ public interface ErrorsJvm {
DiagnosticFactory1
<
JetAnnotationEntry
,
String
>
INAPPLICABLE_JVM_FIELD
=
DiagnosticFactory1
.
create
(
ERROR
);
DiagnosticFactory0
<
JetAnnotationEntry
>
VOLATILE_ON_VALUE
=
DiagnosticFactory0
.
create
(
ERROR
);
DiagnosticFactory0
<
JetDeclaration
>
OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS
=
DiagnosticFactory0
.
create
(
WARNING
,
DECLARATION_SIGNATURE
);
DiagnosticFactory0
<
JetDeclaration
>
OVERLOADS_ABSTRACT
=
DiagnosticFactory0
.
create
(
ERROR
,
DECLARATION_SIGNATURE
);
DiagnosticFactory0
<
JetDeclaration
>
OVERLOADS_PRIVATE
=
DiagnosticFactory0
.
create
(
WARNING
,
DECLARATION_SIGNATURE
);
...
...
@@ -67,6 +69,8 @@ public interface ErrorsJvm {
DiagnosticFactory0
<
JetElement
>
INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER
=
DiagnosticFactory0
.
create
(
ERROR
);
DiagnosticFactory0
<
JetElement
>
INAPPLICABLE_PUBLIC_FIELD
=
DiagnosticFactory0
.
create
(
ERROR
);
DiagnosticFactory0
<
JetElement
>
NO_REFLECTION_IN_CLASS_PATH
=
DiagnosticFactory0
.
create
(
WARNING
);
DiagnosticFactory2
<
JetElement
,
JetType
,
JetType
>
JAVA_CLASS_ON_COMPANION
=
DiagnosticFactory2
.
create
(
WARNING
);
...
...
compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt
浏览文件 @
ccf0c363
...
...
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.jvm.RuntimeAssertionsTypeChecker
import
org.jetbrains.kotlin.load.kotlin.JavaAnnotationCallChecker
import
org.jetbrains.kotlin.load.kotlin.JavaAnnotationMethodCallChecker
import
org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeFunChecker
import
org.jetbrains.kotlin.resolve.
PlatformConfigurator
import
org.jetbrains.kotlin.resolve.
*
import
org.jetbrains.kotlin.resolve.jvm.checkers.*
import
org.jetbrains.kotlin.types.DynamicTypesSettings
...
...
@@ -31,6 +31,7 @@ public object JvmPlatformConfigurator : PlatformConfigurator(
additionalDeclarationCheckers
=
listOf
(
PlatformStaticAnnotationChecker
(),
JvmNameAnnotationChecker
(),
VolatileAnnotationChecker
(),
LocalFunInlineChecker
(),
ReifiedTypeParameterAnnotationChecker
(),
NativeFunChecker
(),
...
...
@@ -67,3 +68,4 @@ public object JvmPlatformConfigurator : PlatformConfigurator(
container
.
useImpl
<
ReflectionAPICallChecker
>()
}
}
compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt
0 → 100644
浏览文件 @
ccf0c363
import
kotlin.jvm.Volatile
class
My
{
<!
VOLATILE_ON_VALUE
!>
@Volatile
<!>
val
x
=
0
// ok
@Volatile
var
y
=
1
}
\ No newline at end of file
compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.txt
0 → 100644
浏览文件 @
ccf0c363
package
public final class My {
public constructor My()
@kotlin.jvm.Volatile() public final val x: kotlin.Int = 0
@kotlin.jvm.Volatile() public final var y: kotlin.Int
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
}
compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java
浏览文件 @
ccf0c363
...
...
@@ -109,6 +109,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
doTest
(
fileName
);
}
@TestMetadata
(
"Volatile.kt"
)
public
void
testVolatile
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"compiler/testData/diagnostics/testsWithStdLib/annotations/Volatile.kt"
);
doTest
(
fileName
);
}
@TestMetadata
(
"compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability"
)
@TestDataPath
(
"$PROJECT_ROOT"
)
@RunWith
(
JUnit3RunnerWithInners
.
class
)
...
...
core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java
浏览文件 @
ccf0c363
...
...
@@ -54,6 +54,7 @@ public class DescriptorUtils {
public
static
final
Name
ENUM_VALUE_OF
=
Name
.
identifier
(
"valueOf"
);
public
static
final
FqName
JVM_NAME
=
new
FqName
(
"kotlin.jvm.JvmName"
);
public
static
final
FqName
PLATFORM_NAME
=
new
FqName
(
"kotlin.platform.platformName"
);
public
static
final
FqName
VOLATILE
=
new
FqName
(
"kotlin.jvm.Volatile"
);
private
DescriptorUtils
()
{
}
...
...
@@ -605,6 +606,11 @@ public class DescriptorUtils {
return
getJvmNameAnnotation
(
annotated
.
getAnnotations
());
}
@Nullable
public
static
AnnotationDescriptor
getVolatileAnnotation
(
@NotNull
Annotated
annotated
)
{
return
annotated
.
getAnnotations
().
findAnnotation
(
VOLATILE
);
}
@NotNull
public
static
SourceFile
getContainingSourceFile
(
@NotNull
DeclarationDescriptor
descriptor
)
{
if
(
descriptor
instanceof
PropertySetterDescriptor
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录