Switch kotlin version to 1.7

* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
This commit is contained in:
Mikhail Glukhikh
2021-12-23 17:55:36 +03:00
committed by Space
parent d741aaf82f
commit 53d6ac24e5
269 changed files with 624 additions and 1132 deletions
@@ -16,5 +16,5 @@ fun test1(a: A) {
fun test2() {
val a: A? = null;
assert((a as B).bool())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>bool()<!>
a<!UNNECESSARY_SAFE_CALL!>?.<!>bool()
}
@@ -16,5 +16,5 @@ fun test1(a: A) {
fun test2() {
val a: A? = null;
assert((a as B).bool())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!><!DEBUG_INFO_SMARTCAST!>a<!><!UNNECESSARY_SAFE_CALL!>?.<!>bool()<!>
<!DEBUG_INFO_SMARTCAST!>a<!><!UNNECESSARY_SAFE_CALL!>?.<!>bool()
}
@@ -4,7 +4,7 @@
fun test1(s: String?) {
assert(s!!.isEmpty())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>s<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
s<!UNNECESSARY_SAFE_CALL!>?.<!>length
}
fun test2(s: String?) {
@@ -20,7 +20,7 @@ fun test3(s: String?) {
fun test4() {
val s: String? = null;
assert(s!!.isEmpty())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>s<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
s<!UNNECESSARY_SAFE_CALL!>?.<!>length
}
fun test5() {
@@ -4,7 +4,7 @@
fun test1(s: String?) {
assert(s!!.isEmpty())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>s<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
s<!UNNECESSARY_SAFE_CALL!>?.<!>length
}
fun test2(s: String?) {
@@ -20,7 +20,7 @@ fun test3(s: String?) {
fun test4() {
val s: String? = null;
assert(s!!.isEmpty())
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>s<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
s<!UNNECESSARY_SAFE_CALL!>?.<!>length
}
fun test5() {
@@ -1,29 +0,0 @@
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Builder<T> {
suspend fun add(t: T) {}
}
fun <S> build(g: suspend Builder<S>.() -> Unit): List<S> = TODO()
fun <S> wrongBuild(g: Builder<S>.() -> Unit): List<S> = TODO()
fun <S> Builder<S>.extensionAdd(s: S) {}
suspend fun <S> Builder<S>.safeExtensionAdd(s: S) {}
val member = build {
add(42)
}
val memberWithoutAnn = wrongBuild {
<!ILLEGAL_SUSPEND_FUNCTION_CALL!>add<!>(42)
}
val extension = build {
extensionAdd("foo")
}
val safeExtension = build {
safeExtensionAdd("foo")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -12,18 +13,18 @@ fun <S> Builder<S>.extensionAdd(s: S) {}
suspend fun <S> Builder<S>.safeExtensionAdd(s: S) {}
val member = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val member = build {
add(42)
}
val memberWithoutAnn = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>wrongBuild<!> {
val memberWithoutAnn = wrongBuild {
<!ILLEGAL_SUSPEND_FUNCTION_CALL!>add<!>(42)
}
val extension = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val extension = build {
extensionAdd("foo")
}
val safeExtension = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>build<!> {
val safeExtension = build {
safeExtensionAdd("foo")
}
@@ -1,17 +1,9 @@
package
public val extension: [ERROR : Type for build {
extensionAdd("foo")
}]
public val member: [ERROR : Type for build {
add(42)
}]
public val memberWithoutAnn: [ERROR : Type for wrongBuild {
add(42)
}]
public val safeExtension: [ERROR : Type for build {
safeExtensionAdd("foo")
}]
public val extension: kotlin.collections.List<kotlin.String>
public val member: kotlin.collections.List<kotlin.Int>
public val memberWithoutAnn: kotlin.collections.List<kotlin.Int>
public val safeExtension: kotlin.collections.List<kotlin.String>
public fun </*0*/ S> build(/*0*/ g: suspend Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> wrongBuild(/*0*/ g: Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> Builder<S>.extensionAdd(/*0*/ s: S): kotlin.Unit
@@ -1,38 +0,0 @@
// ALLOW_KOTLIN_PACKAGE
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: annotation.kt
package kotlin
annotation class BuilderInference
// FILE: test.kt
class Builder<T> {
fun add(t: T) {}
}
fun <S> build(@BuilderInference g: Builder<S>.() -> Unit): List<S> = TODO()
fun <S> wrongBuild(g: Builder<S>.() -> Unit): List<S> = TODO()
fun <S> Builder<S>.extensionAdd(s: S) {}
@BuilderInference
fun <S> Builder<S>.safeExtensionAdd(s: S) {}
val member = build {
add(42)
}
val memberWithoutAnn = wrongBuild {
add(42)
}
val extension = build {
extensionAdd("foo")
}
val safeExtension = build {
safeExtensionAdd("foo")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ALLOW_KOTLIN_PACKAGE
// !LANGUAGE: +UnrestrictedBuilderInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -25,7 +26,7 @@ val member = build {
add(42)
}
val memberWithoutAnn = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>wrongBuild<!> {
val memberWithoutAnn = wrongBuild {
add(42)
}
@@ -2,9 +2,7 @@ package
public val extension: kotlin.collections.List<kotlin.String>
public val member: kotlin.collections.List<kotlin.Int>
public val memberWithoutAnn: [ERROR : Type for wrongBuild {
add(42)
}]
public val memberWithoutAnn: kotlin.collections.List<kotlin.Int>
public val safeExtension: kotlin.collections.List<kotlin.String>
public fun </*0*/ S> build(/*0*/ @kotlin.BuilderInference g: Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> wrongBuild(/*0*/ g: Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
@@ -25,7 +25,7 @@ val member = build {
add(42)
}
val memberWithoutAnn = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>wrongBuild<!> {
val memberWithoutAnn = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER{OI}!>wrongBuild<!> {
add(42)
}
@@ -2,9 +2,7 @@ package
public val extension: kotlin.collections.List<kotlin.String>
public val member: kotlin.collections.List<kotlin.Int>
public val memberWithoutAnn: [ERROR : Type for wrongBuild {
add(42)
}]
public val memberWithoutAnn: kotlin.collections.List<kotlin.Int>
public val safeExtension: kotlin.collections.List<kotlin.String>
public fun </*0*/ S> build(/*0*/ @kotlin.BuilderInference g: Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
public fun </*0*/ S> wrongBuild(/*0*/ g: Builder<S>.() -> kotlin.Unit): kotlin.collections.List<S>
@@ -1,35 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
class Controller<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
val test1 = generate {
apply {
yield(4)
}
}
val test2 = generate {
yield(B)
apply {
yield(C)
}
}
val test3 = generate {
this.let {
yield(B)
}
apply {
yield(C)
}
}
interface A
object B : A
object C : A
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
@@ -7,26 +8,26 @@ class Controller<T> {
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
val test1 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>apply<!> {
<!DEBUG_INFO_MISSING_UNRESOLVED!>yield<!>(4)
val test1 = generate {
apply {
yield(4)
}
}
val test2 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
val test2 = generate {
yield(B)
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>apply<!> {
<!DEBUG_INFO_MISSING_UNRESOLVED!>yield<!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>C<!>)
apply {
yield(C)
}
}
val test3 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
this.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>let<!> {
val test3 = generate {
this.let {
yield(B)
}
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>apply<!> {
<!DEBUG_INFO_MISSING_UNRESOLVED!>yield<!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>C<!>)
apply {
yield(C)
}
}
@@ -1,25 +1,8 @@
package
public val test1: [ERROR : Type for generate {
apply {
yield(4)
}
}]
public val test2: [ERROR : Type for generate {
yield(B)
apply {
yield(C)
}
}]
public val test3: [ERROR : Type for generate {
this.let {
yield(B)
}
apply {
yield(C)
}
}]
public val test1: kotlin.Int
public val test2: A
public val test3: A
public fun </*0*/ S> generate(/*0*/ g: suspend Controller<S>.() -> kotlin.Unit): S
public interface A {
@@ -1,23 +0,0 @@
// !OPT_IN: kotlin.RequiresOptIn
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
@file:OptIn(ExperimentalTypeInference::class)
import kotlin.experimental.ExperimentalTypeInference
class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit): List<S> = TODO()
@BuilderInference
suspend fun <S> GenericController<List<S>>.yieldGenerate(g: suspend GenericController<S>.() -> Unit): Unit = TODO()
val test1 = generate {
// TODO: KT-15185
yieldGenerate {
yield(4)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !OPT_IN: kotlin.RequiresOptIn
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
@@ -15,9 +16,9 @@ fun <S> generate(@BuilderInference g: suspend GenericController<S>.() -> Unit):
@BuilderInference
suspend fun <S> GenericController<List<S>>.yieldGenerate(g: suspend GenericController<S>.() -> Unit): Unit = TODO()
val test1 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
val test1 = generate {
// TODO: KT-15185
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>yieldGenerate<!> {
yieldGenerate {
yield(4)
}
}
@@ -1,11 +1,6 @@
package
public val test1: [ERROR : Type for generate {
// TODO: KT-15185
yieldGenerate {
yield(4)
}
}]
public val test1: kotlin.collections.List<kotlin.collections.List<kotlin.Int>>
public fun </*0*/ S> generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.collections.List<S>
@kotlin.BuilderInference public suspend fun </*0*/ S> GenericController<kotlin.collections.List<S>>.yieldGenerate(/*0*/ g: suspend GenericController<S>.() -> kotlin.Unit): kotlin.Unit
@@ -7,6 +7,6 @@ class Controller<T : Number> {
fun <S : Number> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
val test = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield("foo")
val test = generate {
yield(<!TYPE_MISMATCH!>"foo"<!>)
}
@@ -1,8 +1,6 @@
package
public val test: [ERROR : Type for generate {
yield("foo")
}]
public val test: kotlin.String
public fun </*0*/ S : kotlin.Number> generate(/*0*/ g: suspend Controller<S>.() -> kotlin.Unit): S
public final class Controller</*0*/ T : kotlin.Number> {
@@ -1,20 +0,0 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend GenericController<S>.(S) -> Unit): S = TODO()
val test1 = generate {
yield(4)
}
val test2 = generate<Int> {
yield(4)
}
val test3 = generate { bar: Int ->
yield(4)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
// NI_EXPECTED_FILE
@@ -7,7 +8,7 @@ class GenericController<T> {
fun <S> generate(g: suspend GenericController<S>.(S) -> Unit): S = TODO()
val test1 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
val test1 = generate {
yield(4)
}
@@ -1,8 +1,6 @@
package
public val test1: [ERROR : Type for generate {
yield(4)
}]
public val test1: kotlin.Int
public val test2: kotlin.Int
public val test3: kotlin.Int
public fun </*0*/ S> generate(/*0*/ g: suspend GenericController<S>.(S) -> kotlin.Unit): S
@@ -1,7 +1,7 @@
// FIR_IDENTICAL
// FILE: api.kt
@<!OPT_IN_IS_NOT_ENABLED!>RequiresOptIn<!>
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
annotation class Marker
@@ -19,7 +19,7 @@ fun use2() {
f()
}
@<!OPT_IN_IS_NOT_ENABLED!>OptIn<!>(Marker::class)
@OptIn(Marker::class)
fun use3() {
f()
}
@@ -38,3 +38,4 @@ public interface TypePredicate : (KotlinType) -> kotlin.Boolean {
public abstract override /*1*/ fun invoke(/*0*/ typeToCheck: KotlinType): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,19 +0,0 @@
// !LANGUAGE: +NewInference
fun main() {
val list = listOf(A())
list.forEach(A::<!OPT_IN_USAGE_ERROR!>foo<!>)
list.forEach {
it.<!OPT_IN_USAGE_ERROR!>foo<!>()
}
}
class A {
@ExperimentalTime
fun foo() {
println("a")
}
}
@<!OPT_IN_IS_NOT_ENABLED!>RequiresOptIn<!>(level = RequiresOptIn.Level.ERROR)
annotation class ExperimentalTime
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
fun main() {
@@ -15,5 +16,5 @@ class A {
}
}
@<!OPT_IN_IS_NOT_ENABLED!>RequiresOptIn<!>(level = <!OPT_IN_IS_NOT_ENABLED!>RequiresOptIn<!>.Level.ERROR)
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
annotation class ExperimentalTime
@@ -8,5 +8,5 @@ fun ff() {
val a = Test.FOO
val b = <!NO_COMPANION_OBJECT!>Test<!><!UNEXPECTED_SAFE_CALL!>?.<!>FOO
System.out.println(a + b)
<!NO_COMPANION_OBJECT!>System<!><!UNEXPECTED_SAFE_CALL!>?.<!>out.println(a + b)
<!NO_COMPANION_OBJECT!>System<!><!UNEXPECTED_SAFE_CALL!>?.<!>out<!UNSAFE_CALL!>.<!>println(a + b)
}
@@ -2,7 +2,7 @@
// LANGUAGE: +WarnAboutNonExhaustiveWhenOnAlgebraicTypes
fun test1() {
if (true) {
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (true) {
<!NO_ELSE_IN_WHEN!>when<!> (true) {
true -> println()
}
} else {
@@ -13,7 +13,7 @@ fun test1() {
fun test2() {
val mlist = arrayListOf("")
if (true) {
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (true) {
<!NO_ELSE_IN_WHEN!>when<!> (true) {
true -> println()
}
} else {