Introduce a compiler X flag to enable enhancing not null annotated type parameter's types to definitely not null types
This commit is contained in:
+10
@@ -505,6 +505,12 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise""
|
||||
)
|
||||
var validateBytecode: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xenhance-type-parameter-types-to-def-not-null",
|
||||
description = "Enhance not null annotated type parameter's types to definitely not null types (@NotNull T => T & Any)"
|
||||
)
|
||||
var enhanceTypeParameterTypesToDefNotNull: Boolean by FreezableVar(false)
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
|
||||
val result = super.configureAnalysisFlags(collector, languageVersion)
|
||||
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
|
||||
@@ -533,6 +539,10 @@ default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise""
|
||||
if (typeEnhancementImprovementsInStrictMode) {
|
||||
result[LanguageFeature.TypeEnhancementImprovementsInStrictMode] = LanguageFeature.State.ENABLED
|
||||
}
|
||||
if (enhanceTypeParameterTypesToDefNotNull) {
|
||||
result[LanguageFeature.ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated] = LanguageFeature.State.ENABLED
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -27,6 +27,8 @@ where advanced options include:
|
||||
-Xemit-jvm-type-annotations Emit JVM type annotations in bytecode
|
||||
-Xjvm-enable-preview Allow using features from Java language that are in preview phase.
|
||||
Works as `--enable-preview` in Java. All class files are marked as preview-generated thus it won't be possible to use them in release environment
|
||||
-Xenhance-type-parameter-types-to-def-not-null
|
||||
Enhance not null annotated type parameter's types to definitely not null types (@NotNull T => T & Any)
|
||||
-Xfriend-paths=<path> Paths to output directories for friend modules (whose internals should be visible)
|
||||
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
|
||||
-Xmodule-path=<path> Paths where to find Java 9+ modules
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
-Xenhance-type-parameter-types-to-def-not-null
|
||||
$TESTDATA_DIR$/kt49209.kt
|
||||
$TESTDATA_DIR$/kt49209
|
||||
$FOREIGN_JAVA8_ANNOTATIONS_DIR$
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
fun usingMethod(java : Java<String?>) : String = java.getFoo()
|
||||
fun usingProperty(java : Java<String?>) : String = java.foo
|
||||
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface Java<T extends @Nullable Object> {
|
||||
@NonNull T getFoo();
|
||||
}
|
||||
@@ -263,6 +263,10 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
||||
.replace(
|
||||
"$FOREIGN_ANNOTATIONS_DIR$",
|
||||
new File(ThirdPartyAnnotationPathsKt.FOREIGN_ANNOTATIONS_SOURCES_PATH).getPath()
|
||||
)
|
||||
.replace(
|
||||
"$FOREIGN_JAVA8_ANNOTATIONS_DIR$",
|
||||
new File(ThirdPartyAnnotationPathsKt.FOREIGN_JDK8_ANNOTATIONS_SOURCES_PATH).getPath()
|
||||
).replace(
|
||||
"$JDK_17$",
|
||||
KtTestUtil.getJdk17Home().getPath()
|
||||
|
||||
@@ -631,6 +631,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/kt22304.args");
|
||||
}
|
||||
|
||||
@TestMetadata("kt49209.args")
|
||||
public void testKt49209() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/kt49209.args");
|
||||
}
|
||||
|
||||
@TestMetadata("languageVersion.args")
|
||||
public void testLanguageVersion() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/languageVersion.args");
|
||||
|
||||
Reference in New Issue
Block a user