[kotlin] KTIJ-38940 Add/fix K2_ERRORs

(cherry picked from commit 1b4d68597cff30e589b2ba3e674f46c852b313f1)

IJ-CR-214534

GitOrigin-RevId: 1f6ba685d5f3627e42c66c6d1a364140b0cd362b
This commit is contained in:
Victoria Petrakovich
2026-09-01 23:49:16 +00:00
committed by intellij-monorepo-bot
parent 0d399eb5eb
commit d6f1954e71
16 changed files with 16 additions and 2 deletions
@@ -1,5 +1,5 @@
// AFTER_ERROR: Incompatible types: String and Int
// K2_AFTER_ERROR:
// K2_AFTER_ERROR: Check for instance is always 'true'.
fun test(x: Int) {
<caret>x as? String //comment1
?: return
@@ -1,5 +1,5 @@
// AFTER_ERROR: Incompatible types: String and Int
// K2_AFTER_ERROR:
// K2_AFTER_ERROR: Check for instance is always 'true'.
fun test(x: Int) {
if (x !is String //comment1
) return
@@ -1,3 +1,4 @@
// K2_AFTER_ERROR: This annotation is not repeatable.
annotation class Annotation1(val a: Int = 0)
annotation class Annotation2(val a: Int = 0)
annotation class Annotation3(val a: Int = 0)
@@ -1,3 +1,4 @@
// K2_AFTER_ERROR: This annotation is not repeatable.
annotation class Annotation1(val a: Int = 0)
annotation class Annotation2(val a: Int = 0)
annotation class Annotation3(val a: Int = 0)
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
fun foo(a: String) {
if (<caret>a is Int) {
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
fun foo(a: String) {
if (<caret>false) {
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
interface Base
interface Derived: Base
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
interface Base
interface Derived: Base
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
open class A
class B: A()
class C: A()
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
open class A
class B: A()
class C: A()
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
open class A
class B: A()
class C: A()
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'false'.
open class A
class B: A()
class C: A()
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'true'.
interface Base
interface Derived: Base
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'true'.
interface Base
interface Derived: Base
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'true'.
fun foo(a: String) {
if (<caret>a !is Int) {
@@ -1,4 +1,5 @@
// "Remove redundant 'is' check" "true"
// K2_ERROR: Check for instance is always 'true'.
fun foo(a: String) {
if (<caret>true) {