Enable DefinitelyNotNullTypeParameters since 1.7

^KT-26245 In Progress
This commit is contained in:
Denis.Zharkov
2021-08-09 13:12:22 +03:00
committed by teamcityserver
parent c1b5d5551f
commit 9e6af52e1f
14 changed files with 41 additions and 40 deletions
@@ -1,4 +1,4 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
// !LANGUAGE: +StrictJavaNullabilityAssertions +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +DefinitelyNotNullTypeParameters
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
@@ -116,8 +116,8 @@ public final class Main</*0*/ L> {
public constructor Main</*0*/ L>(/*0*/ x: L?, /*1*/ y: L)
public final val vx01: Foo<Bar<L>>
public final val vx02: Foo<Bar<L>>
public final val vx11: OutBar<Bar<out OutBar<L!!>>>
public final val vx12: OutBar<Bar<out OutBar<L!!>>>
public final val vx11: OutBar<Bar<out OutBar<L>>>
public final val vx12: OutBar<Bar<out OutBar<L>>>
public final val vx21: OutBar<Bar<in OutBar<L>>>
public final val vx22: OutBar<Bar<in OutBar<L>>>
public final val x00: Bar<L>
@@ -128,12 +128,12 @@ public final class Main</*0*/ L> {
public final val x11: Foo<Bar<L>>
public final val x110: Bar<L>
public final val x111: Bar<L>
public final val x12: Foo<Bar<L!!>>
public final val x120: Bar<L!!>
public final val x121: Bar<L!!>
public final val x12: Foo<out Bar<out L>>
public final val x120: Bar<out L>
public final val x121: Bar<out L>
public final val x122: Bar<L>
public final val x123: Bar<L>
public final val x13: Foo<Bar<L!!>>
public final val x13: Foo<out Bar<out L>>
public final val x133: Bar<L?>
public final val x135: Bar<L>
public final val x137: Bar<L>
@@ -146,8 +146,8 @@ public final class Main</*0*/ L> {
public final val x154: Bar<L?>
public final val x161: Bar<L>
public final val x162: Bar<L>
public final val x163: Bar<L!!>
public final val x164: Bar<L!!>
public final val x163: Bar<out L>
public final val x164: Bar<out L>
public final val x170: Bar<L>
public final val x171: Bar<L>
public final val x180: [ERROR : <ERROR FUNCTION RETURN TYPE>]
@@ -164,24 +164,24 @@ public final class Main</*0*/ L> {
public final val x231: Foo<Foo<Bar<out L>>>
public final val x240: Foo<Foo<Bar<in L>>>
public final val x241: Foo<Foo<Bar<in L>>>
public final val x250: Bar<out L!!>
public final val x251: Bar<out L!!>
public final val x260: Foo<out Foo<out Bar<out L!!>>>
public final val x261: Foo<out Foo<out Bar<out L!!>>>
public final val x250: Bar<out L>
public final val x251: Bar<out L>
public final val x260: Foo<out Foo<out Bar<out L>>>
public final val x261: Foo<out Foo<out Bar<out L>>>
public final val x270: Foo<out Foo<Bar<out L>>>
public final val x271: Foo<out Foo<Bar<out L>>>
public final val x280: OutBar<OutBar<OutBar<L!!>>>
public final val x281: OutBar<OutBar<OutBar<L!!>>>
public final val x280: OutBar<OutBar<OutBar<L>>>
public final val x281: OutBar<OutBar<OutBar<L>>>
public final val x290: OutBar<Bar<OutBar<L>>>
public final val x291: OutBar<Bar<OutBar<L>>>
public final val x30: Foo<Bar<L>>
public final val x300: OutBar<Bar<out OutBar<L!!>>>
public final val x301: OutBar<Bar<out OutBar<L!!>>>
public final val x300: OutBar<Bar<out OutBar<L>>>
public final val x301: OutBar<Bar<out OutBar<L>>>
public final val x31: Foo<Bar<L>>
public final val x310: OutBarAliasUseSite<L!!> /* = Bar<out L!!> */
public final val x311: OutBarAliasUseSite<L!!> /* = Bar<out L!!> */
public final val x320: OutBarAliasDecSite<L!!> /* = OutBar<L!!> */
public final val x321: OutBarAliasDecSite<L!!> /* = OutBar<L!!> */
public final val x310: Bar<out L>
public final val x311: Bar<out L>
public final val x320: OutBar<L>
public final val x321: OutBar<L>
public final val x330: OutBar<InBar<OutBar<L>>>
public final val x331: OutBar<InBar<OutBar<L>>>
public final val x340: OutBar<Bar<in OutBar<L>>>
@@ -212,15 +212,15 @@ public final class Main</*0*/ L> {
public final val x451: OutBar<OutBar<Bar<L>>>
public final val x460: Bar<OutBar<OutBar<L>>>
public final val x461: Bar<OutBar<OutBar<L>>>
public final val x470: OutBar<OutBar<OutBar<L!!>>>
public final val x471: OutBar<OutBar<OutBar<L!!>>>
public final val x470: OutBar<OutBar<OutBar<L>>>
public final val x471: OutBar<OutBar<OutBar<L>>>
public final val x480: Bar<L>
public final val x481: Bar<L>
public final val x482: Bar<kotlin.Nothing>
public final val x50: Bar<in L>
public final val x51: Bar<in L>
public final val x60: OutBar<L!!>
public final val x61: OutBar<L!!>
public final val x60: OutBar<L>
public final val x61: OutBar<L>
public final val x70: InBar<L>
public final val x71: InBar<L>
public final val x80: Foo<Bar<L>>
@@ -3,9 +3,9 @@ Buildfile: [TestData]/build.xml
build:
[kotlinc] Compiling [[TestData]/main.kt] => [[Temp]/hello.jar]
[kotlinc] [TestData]/main.kt:1:18: error: the feature "definitely not null type parameters" is only available since language version 1.6
[kotlinc] fun <T> f(t: T): T!! = t!!
[kotlinc] ^
[kotlinc] [TestData]/main.kt:1:15: error: suspend function type is not allowed as supertypes
[kotlinc] interface A : suspend () -> Unit
[kotlinc] ^
ERR:
@@ -1 +1 @@
fun <T> f(t: T): T!! = t!!
interface A : suspend () -> Unit
@@ -12,7 +12,7 @@ fun <S : Any?> select(x: S, y: S): S {
}
fun <T : Any?> foo(a: Array<In<T>>, b: Array<In<String>>): Boolean {
return select<Array<out In<Nothing>>>(x = a, y = b).get(index = 0).ofType<Any>(y = true)
return select<Array<out In<Nothing>>>(x = a, y = b).get(index = 0).ofType<Any?>(y = true)
}
inline fun <reified K : Any?> In<K>.ofType(y: Any?): Boolean {
@@ -33,7 +33,7 @@ FILE fqName:<root> fileName:/intersectionType1_NI.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo <T> (a: kotlin.Array<<root>.In<T of <root>.foo>>, b: kotlin.Array<<root>.In<kotlin.String>>): kotlin.Boolean declared in <root>'
CALL 'public final fun ofType <K> (y: kotlin.Any?): kotlin.Boolean [inline] declared in <root>' type=kotlin.Boolean origin=null
<K>: kotlin.Any
<K>: kotlin.Any?
$receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=<root>.In<kotlin.Nothing> origin=null
$this: CALL 'public final fun select <S> (x: S of <root>.select, y: S of <root>.select): S of <root>.select declared in <root>' type=kotlin.Array<out <root>.In<kotlin.Nothing>> origin=null
<S>: kotlin.Array<out <root>.In<kotlin.Nothing>>
@@ -12,7 +12,7 @@ fun <S : Any?> select(x: S, y: S): S {
}
fun <T : Any?> foo(a: Array<In<T>>, b: Array<In<String>>): Boolean {
return select<Array<out In<Nothing>>>(x = a, y = b).get(index = 0).ofType<Any>(y = true)
return select<Array<out In<Nothing>>>(x = a, y = b).get(index = 0).ofType<Any?>(y = true)
}
inline fun <reified K : Any?> In<K>.ofType(y: Any?): Boolean {
@@ -24,3 +24,4 @@ fun test() {
val a2: Array<In<String>> = arrayOf<In<String>>(elements = [In<String>()])
foo<Int>(a = a1, b = a2) /*~> Unit */
}
@@ -33,7 +33,7 @@ FILE fqName:<root> fileName:/intersectionType1_OI.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo <T> (a: kotlin.Array<<root>.In<T of <root>.foo>>, b: kotlin.Array<<root>.In<kotlin.String>>): kotlin.Boolean declared in <root>'
CALL 'public final fun ofType <K> (y: kotlin.Any?): kotlin.Boolean [inline] declared in <root>' type=kotlin.Boolean origin=null
<K>: kotlin.Any
<K>: kotlin.Any?
$receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=<root>.In<kotlin.Nothing> origin=null
$this: CALL 'public final fun select <S> (x: S of <root>.select, y: S of <root>.select): S of <root>.select declared in <root>' type=kotlin.Array<out <root>.In<kotlin.Nothing>> origin=null
<S>: kotlin.Array<out <root>.In<kotlin.Nothing>>
@@ -140,8 +140,8 @@ abstract class AbstractVersionRequirementTest : TestCaseWithTmpdir() {
fun testDefinitelyNotNull() {
doTest(
VersionRequirement.Version(1, 6), DeprecationLevel.ERROR, null, ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION, null,
customLanguageVersion = LanguageVersion.KOTLIN_1_6,
VersionRequirement.Version(1, 7), DeprecationLevel.ERROR, null, ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION, null,
customLanguageVersion = LanguageVersion.KOTLIN_1_7,
fqNamesWithRequirements = listOf(
"test.A.foo",
"test.A.w",
@@ -203,7 +203,6 @@ enum class LanguageFeature(
ProhibitSelfCallsInNestedObjects(KOTLIN_1_6, kind = BUG_FIX),
ApproximateIntegerLiteralTypesInReceiverPosition(KOTLIN_1_6),
ProperCheckAnnotationsTargetInTypeUsePositions(KOTLIN_1_6, kind = BUG_FIX),
DefinitelyNotNullTypeParameters(KOTLIN_1_6),
ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated(KOTLIN_1_6, kind = BUG_FIX),
AbstractClassMemberNotImplementedWithIntermediateAbstractClass(KOTLIN_1_6, kind = BUG_FIX),
@@ -229,6 +228,7 @@ enum class LanguageFeature(
UseBuilderInferenceWithoutAnnotation(KOTLIN_1_7),
ProhibitSmartcastsOnPropertyFromAlienBaseClass(KOTLIN_1_7, kind = BUG_FIX),
ProhibitInvalidCharsInNativeIdentifiers(KOTLIN_1_7, kind = BUG_FIX),
DefinitelyNotNullTypeParameters(KOTLIN_1_7),
// Temporarily disabled, see KT-27084/KT-22379
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
@@ -67,7 +67,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
fun testLanguageVersion(gradleVersion: GradleVersion) {
project("languageVersion", gradleVersion) {
buildAndFail("build") {
assertOutputContains("The feature \"definitely not null type parameters\" is only available since language version 1.6")
assertOutputContains("Suspend function type is not allowed as supertypes")
}
}
}
@@ -1 +1 @@
fun <T> f(t: T): T!! = t!!
interface A : suspend () -> Unit
@@ -1 +1 @@
fun <T> f(t: T): T!! = t!!
interface A : suspend () -> Unit
@@ -1,4 +1,4 @@
source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
assertBuildLogHasLine("[INFO] BUILD FAILURE");
assertBuildLogHasLineThatContains("The feature \"definitely not null type parameters\" is only available since language version 1.6");
assertBuildLogHasLineThatContains("Suspend function type is not allowed as supertypes");