diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt49276.fir.kt b/compiler/testData/diagnostics/tests/checkArguments/kt49276.fir.kt new file mode 100644 index 00000000000..0f64837b43c --- /dev/null +++ b/compiler/testData/diagnostics/tests/checkArguments/kt49276.fir.kt @@ -0,0 +1,43 @@ +// WITH_STDLIB + +fun SmartList(x: E) {} +fun SmartList(x: Collection) {} + +fun append(x: Any?) {} +fun append(x: Collection<*>) {} + +fun append2(x: Iterable<*>) {} +fun append2(x: Collection<*>) {} + +class In(x: T) + +@JvmName("append31") +fun append3(x: In) {} +fun append3(x: In>) {} + +fun append4(x: E) {} +fun > append4(x: E) {} + +fun takes(range: T) {} +fun takes(range: T) where T : Collection<*>, T: ClosedRange<*> {} + +fun main() { + SmartList(1..2) // warning + SmartList(1..10) // no warning + + append(1..10) // warning + append((1..10) as Any) // no warning + append((1..10) as Iterable) // no warning + append("a".."z") // no warning, the range is not iterable + append(1.0..2.0) + + append2(1..10) // no warning + + append3(In(1..10)) // no warning + + append4(1..10) // warning + + append4(1..10) // warning + + takes(1..10) // warning +} diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt49276.kt b/compiler/testData/diagnostics/tests/checkArguments/kt49276.kt index ef0fc8f86c1..5ff36331970 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/kt49276.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/kt49276.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB fun SmartList(x: E) {} @@ -23,10 +22,10 @@ fun takes(range: T) {} fun takes(range: T) where T : Collection<*>, T: ClosedRange<*> {} fun main() { - SmartList(1..2) // warning + SmartList(1..2) // warning SmartList(1..10) // no warning - append(1..10) // warning + append(1..10) // warning append((1..10) as Any) // no warning append((1..10) as Iterable) // no warning append("a".."z") // no warning, the range is not iterable @@ -36,9 +35,9 @@ fun main() { append3(In(1..10)) // no warning - append4(1..10) // warning + append4(1..10) // warning append4(1..10) // warning - takes(1..10) // warning + takes(1..10) // warning } diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.fir.kt b/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.fir.kt new file mode 100644 index 00000000000..dfa365cf9ba --- /dev/null +++ b/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.fir.kt @@ -0,0 +1,37 @@ +// WITH_STDLIB +// !LANGUAGE: +ProgressionsChangingResolve + +fun SmartList(x: E) {} +fun SmartList(x: Collection) {} + +fun append(x: Any?) {} +fun append(x: Collection<*>) {} + +fun append2(x: Iterable<*>) {} +fun append2(x: Collection<*>) {} + +class In(x: T) + +@JvmName("append31") +fun append3(x: In) {} +fun append3(x: In>) {} + +fun append4(x: E) {} +fun > append4(x: E) {} + +fun main() { + SmartList(1..2) // warning + SmartList(1..10) // no warning + + append(1..10) // warning + append((1..10) as Any) // no warning + append((1..10) as Iterable) // no warning + append("a".."z") // no warning, the range is not iterable + append(1.0..2.0) + + append2(1..10) // no warning + + append3(In(1..10)) // no warning + + append4(1..10) // warning +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.kt b/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.kt index feecaef7d23..5f9e35d1217 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/kt49276Error.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // !LANGUAGE: +ProgressionsChangingResolve @@ -21,10 +20,10 @@ fun append4(x: E) {} fun > append4(x: E) {} fun main() { - SmartList(1..2) // warning + SmartList( SmartList(x: Collection): Unit")!>1..2) // warning SmartList(1..10) // no warning - append(1..10) // warning + append(): Unit")!>1..10) // warning append((1..10) as Any) // no warning append((1..10) as Iterable) // no warning append("a".."z") // no warning, the range is not iterable @@ -34,5 +33,5 @@ fun main() { append3(In(1..10)) // no warning - append4(1..10) // warning + append4(> append4(x: E): Unit")!>1..10) // warning } diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt51062.fir.kt b/compiler/testData/diagnostics/tests/checkArguments/kt51062.fir.kt new file mode 100644 index 00000000000..d63df4215b0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/checkArguments/kt51062.fir.kt @@ -0,0 +1,53 @@ +// WITH_STDLIB +// FULL_JDK + +// FILE: JavaSmartList.java +import kotlin.ranges.ClosedRange; + +import java.util.Collection; + +public class JavaSmartList { + JavaSmartList(E x) {} + JavaSmartList(Collection x) {} + + static void append(Object x) {} + static void append(Collection x) {} + + static void append2(Iterable x) {} + static void append2(Collection x) {} + + public static class In { + In(T x) {} + } + + static void append3(In x) {} + static void append3(In> x) {} + + static void append4(E x) {} + static > void append4(E x) {} + + static void takes(T x) {} + static & ClosedRange> void takes(T x) {} +} + +// FILE: main.kt +fun main() { + JavaSmartList(1..2) // warning + JavaSmartList(1..10) // no warning + + JavaSmartList.append(1..10) // warning + JavaSmartList.append((1..10) as Any) // no warning + JavaSmartList.append((1..10) as Iterable) // no warning + JavaSmartList.append("a".."z") // no warning, the range is not iterable + JavaSmartList.append(1.0..2.0) + + JavaSmartList.append2(1..10) // no warning + + JavaSmartList.append3(JavaSmartList.In(1..10)) // no warning + + JavaSmartList.append4(1..10) // warning + + JavaSmartList.append4(1..10) // warning + + JavaSmartList.takes(1..10) // warning +} diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt51062.kt b/compiler/testData/diagnostics/tests/checkArguments/kt51062.kt index 233a082a146..2d89973bfc2 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/kt51062.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/kt51062.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // FULL_JDK @@ -33,10 +32,10 @@ public class JavaSmartList { // FILE: main.kt fun main() { - JavaSmartList(1..2) // warning + JavaSmartList(1..2) // warning JavaSmartList(1..10) // no warning - JavaSmartList.append(1..10) // warning + JavaSmartList.append(1..10) // warning JavaSmartList.append((1..10) as Any) // no warning JavaSmartList.append((1..10) as Iterable) // no warning JavaSmartList.append("a".."z") // no warning, the range is not iterable @@ -46,9 +45,9 @@ fun main() { JavaSmartList.append3(JavaSmartList.In(1..10)) // no warning - JavaSmartList.append4(1..10) // warning + JavaSmartList.append4(1..10) // warning JavaSmartList.append4(1..10) // warning - JavaSmartList.takes(1..10) // warning + JavaSmartList.takes(1..10) // warning } diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index aa644f2b3c3..6c2de2435ac 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -255,7 +255,6 @@ enum class LanguageFeature( // 1.9 - DisableCheckingChangedProgressionsResolve(KOTLIN_1_9), // KT-49276 ProhibitIllegalValueParameterUsageInDefaultArguments(KOTLIN_1_9, kind = BUG_FIX), // KT-25694 ProhibitConstructorCallOnFunctionalSupertype(KOTLIN_1_9, kind = BUG_FIX), // KT-46344 ProhibitArrayLiteralsInCompanionOfAnnotation(KOTLIN_1_9, kind = BUG_FIX), // KT-39041 @@ -345,6 +344,7 @@ enum class LanguageFeature( ForbidInferringTypeVariablesIntoEmptyIntersection(sinceVersion = null, kind = BUG_FIX), // KT-51221 IntrinsicConstEvaluation(sinceVersion = null, kind = UNSTABLE_FEATURE), // KT-49303 NoSourceCodeInNotNullAssertionExceptions(sinceVersion = null, sinceApiVersion = ApiVersion.KOTLIN_1_4, kind = OTHER), // KT-57570 + DisableCheckingChangedProgressionsResolve(sinceVersion = null, kind = OTHER), // KT-49276 ; init {