Make default value for -Xjsr305 flag to be WARN
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
|||||||
|
@javax.annotation.ParametersAreNonnullByDefault
|
||||||
|
public class A {
|
||||||
|
public void foo(String x) {}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package javax.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
import javax.annotation.meta.TypeQualifierDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation can be applied to a package, class or method to indicate that
|
||||||
|
* the method parameters in that element are nonnull by default unless there is:
|
||||||
|
* <ul>
|
||||||
|
* <li>An explicit nullness annotation
|
||||||
|
* <li>The method overrides a method in a superclass (in which case the
|
||||||
|
* annotation of the corresponding parameter in the superclass applies)
|
||||||
|
* <li>There is a default parameter annotation (like {@link ParametersAreNullableByDefault})
|
||||||
|
* applied to a more tightly nested element.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @see Nonnull
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Nonnull
|
||||||
|
@TypeQualifierDefault(ElementType.PARAMETER)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface ParametersAreNonnullByDefault {
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/jsr305Usage.kt
|
||||||
|
$TESTDATA_DIR$/jsr305
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||||
|
a.foo(null)
|
||||||
|
^
|
||||||
|
OK
|
||||||
@@ -218,6 +218,12 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305NoFlag.args")
|
||||||
|
public void testJsr305NoFlag() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305NoFlag.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jvm8Target.args")
|
@TestMetadata("jvm8Target.args")
|
||||||
public void testJvm8Target() throws Exception {
|
public void testJvm8Target() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class AnalysisFlag<out T> internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Jsr305StateWarnByDefault {
|
object Jsr305StateWarnByDefault {
|
||||||
operator fun provideDelegate(instance: Any?, property: KProperty<*>) = Flag(property.name, Jsr305State.WARN)
|
operator fun provideDelegate(instance: Any?, property: KProperty<*>) = Flag(property.name, Jsr305State.DEFAULT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,4 +54,4 @@ class AnalysisFlag<out T> internal constructor(
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
val jsr305 by Flag.Jsr305StateWarnByDefault
|
val jsr305 by Flag.Jsr305StateWarnByDefault
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ enum class Jsr305State(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmField
|
@JvmField
|
||||||
val DEFAULT: Jsr305State = IGNORE
|
val DEFAULT: Jsr305State = WARN
|
||||||
|
|
||||||
fun findByDescription(description: String?) = values().firstOrNull { it.description == description }
|
fun findByDescription(description: String?) = values().firstOrNull { it.description == description }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isIgnored(): Boolean = this == IGNORE
|
fun isIgnored(): Boolean = this == IGNORE
|
||||||
fun isWarning(): Boolean = this == WARN
|
fun isWarning(): Boolean = this == WARN
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user