Support compiler flag -Xcodeanalysis-annotations

This commit is contained in:
Denis Zharkov
2019-08-15 12:17:29 +03:00
committed by Victor Petukhov
parent c734bac676
commit f3a490ee16
45 changed files with 1031 additions and 35 deletions
+7
View File
@@ -0,0 +1,7 @@
@codeanalysis.experimental.annotations.DefaultNotNull
public class A {
public void foo(String x) {}
@codeanalysis.experimental.annotations.Nullable
public String bar() { return null; }
}
+5
View File
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/jspecifyUsage.kt
$TESTDATA_DIR$/jspecify
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+7
View File
@@ -0,0 +1,7 @@
compiler/testData/cli/jvm/codeanalysisUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
compiler/testData/cli/jvm/codeanalysisUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
a.bar().hashCode()
^
OK
+6
View File
@@ -0,0 +1,6 @@
-Xcodeanalysis-annotations=ignore
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+1
View File
@@ -0,0 +1 @@
OK
+6
View File
@@ -0,0 +1,6 @@
-Xcodeanalysis-annotations=strict
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+4
View File
@@ -0,0 +1,4 @@
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: error: null can not be a value of a non-null type String
a.foo(null)
^
COMPILATION_ERROR
+4
View File
@@ -0,0 +1,4 @@
fun bar(a: A) {
a.foo(null)
a.bar().hashCode()
}
+6
View File
@@ -0,0 +1,6 @@
-Xjspecify-annotations=warn
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+7
View File
@@ -0,0 +1,7 @@
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
a.bar().hashCode()
^
OK
+3
View File
@@ -12,6 +12,9 @@ where advanced options include:
-Xassertions=legacy: calculate condition on each call, check depends on jvm assertion settings in the kotlin package;
default: legacy
-Xbuild-file=<path> Path to the .xml build file to compile
-Xcodeanalysis-annotations=ignore|strict|warn
Specify behavior for Codeanalysis annotations.
Default value is 'warn'
-Xcompile-java Reuse javac analysis and compile Java source files
-Xnormalize-constructor-calls={disable|enable}
Normalize constructor calls (disable: don't normalize; enable: normalize),