From 2b5524b18f32d11a39b0fa7598c7832a9380a71a Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Thu, 16 Sep 2021 20:58:52 +0300 Subject: [PATCH] [FIR] Add CAST_NEVER_SUCCEEDS --- .../diagnostics/KtFirDataClassConverters.kt | 6 ++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 4 + .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 7 ++ .../resolve/lambdaInLhsOfTypeOperatorCall.kt | 2 +- .../diagnostics/FirDiagnosticsList.kt | 1 + .../fir/analysis/diagnostics/FirErrors.kt | 1 + .../checkers/CommonExpressionCheckers.kt | 2 +- .../checkers/FirCastDiagnosticsHelpers.kt | 89 ++++++++++++++++++- .../FirCannotCheckForErasedChecker.kt | 31 ------- .../expression/FirCastOperatorsChecker.kt | 4 +- .../diagnostics/PositioningStrategies.kt | 1 + .../diagnostics/tests/Constants.fir.kt | 6 +- .../tests/annotations/ConstructorCall.fir.kt | 2 +- .../diagnostics/tests/cast/AsNothing.fir.kt | 14 --- .../diagnostics/tests/cast/AsNothing.kt | 1 + .../diagnostics/tests/cast/AsTypeAlias.fir.kt | 18 ---- .../diagnostics/tests/cast/AsTypeAlias.kt | 1 + .../diagnostics/tests/cast/constants.fir.kt | 72 +++++++-------- .../cast/neverSucceeds/MappedDirect.fir.kt | 33 ------- .../tests/cast/neverSucceeds/MappedDirect.kt | 1 + .../cast/neverSucceeds/MappedSubtypes.fir.kt | 21 ----- .../cast/neverSucceeds/MappedSubtypes.kt | 1 + .../neverSucceeds/NoGenericsUnrelated.fir.kt | 34 ------- .../cast/neverSucceeds/NoGenericsUnrelated.kt | 1 + .../tests/generics/Projections.fir.kt | 34 +++---- .../expectedTypeAdditionalTest.fir.kt | 2 +- ...icitNothingOnlyForOwnTypeParameters.fir.kt | 11 --- ...ImplicitNothingOnlyForOwnTypeParameters.kt | 1 + ...underscoredTypeInForbiddenPositions.fir.kt | 2 +- .../tests/regressions/kt701.fir.kt | 17 ---- .../diagnostics/tests/regressions/kt701.kt | 1 + .../tests/regressions/kt716.fir.kt | 4 +- .../smartCasts/castchecks/variables.fir.kt | 4 +- .../oneWarning/onBlockStatement.fir.kt | 22 ++--- .../onBlockStatementSameLine.fir.kt | 8 +- .../tests/typeParameters/kt42472.fir.kt | 2 +- .../unitConversionForSubtypes.fir.kt | 2 +- .../coroutines/suspendFunctions.fir.kt | 2 +- .../reified/reifiedNothingSubstitution.fir.kt | 4 +- .../contractBuilder/common/neg/1.fir.kt | 4 +- .../contractBuilder/common/neg/16.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/31.fir.kt | 2 +- 42 files changed, 206 insertions(+), 273 deletions(-) delete mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCannotCheckForErasedChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/AsNothing.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/AsTypeAlias.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/regressions/kt701.fir.kt diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt index a414d3100b6..bf664b878cb 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -3104,6 +3104,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.CAST_NEVER_SUCCEEDS) { firDiagnostic -> + CastNeverSucceedsImpl( + firDiagnostic as FirPsiDiagnostic, + token, + ) + } add(FirErrors.USELESS_CAST) { firDiagnostic -> UselessCastImpl( firDiagnostic as KtPsiDiagnostic, diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt index 160e97f2870..1a988dc801f 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt @@ -2173,6 +2173,10 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val type: KtType } + abstract class CastNeverSucceeds : KtFirDiagnostic() { + override val diagnosticClass get() = CastNeverSucceeds::class + } + abstract class UselessCast : KtFirDiagnostic() { override val diagnosticClass get() = UselessCast::class } diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index ebf78dbd06f..532568a6064 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -2618,6 +2618,13 @@ internal class CannotCheckForErasedImpl( override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic) } +internal class CastNeverSucceedsImpl( + firDiagnostic: FirPsiDiagnostic, + override val token: ValidityToken, +) : KtFirDiagnostic.CastNeverSucceeds(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic) +} + internal class UselessCastImpl( override val firDiagnostic: KtPsiDiagnostic, override val token: ValidityToken, diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaInLhsOfTypeOperatorCall.kt b/compiler/fir/analysis-tests/testData/resolve/lambdaInLhsOfTypeOperatorCall.kt index 02044811550..91134a71484 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaInLhsOfTypeOperatorCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaInLhsOfTypeOperatorCall.kt @@ -9,7 +9,7 @@ fun test_1(b: B) { } fun test_2(s: String) { - val func = { s.length } as B + val func = { s.length } as B } class B(val k: K, val v: V) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index a54d4e66e0e..692c616c84f 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -1105,6 +1105,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") { val CANNOT_CHECK_FOR_ERASED by error { parameter("type") } + val CAST_NEVER_SUCCEEDS by warning(PositioningStrategy.OPERATOR) val USELESS_CAST by warning(PositioningStrategy.AS_TYPE) val USELESS_IS_CHECK by warning { parameter("compileTimeCheckResult") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index b73de1a344e..c2a7d541bf1 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -591,6 +591,7 @@ object FirErrors { // Casts and is-checks val CANNOT_CHECK_FOR_ERASED by error1() + val CAST_NEVER_SUCCEEDS by warning0(SourceElementPositioningStrategies.OPERATOR) val USELESS_CAST by warning0(SourceElementPositioningStrategies.AS_TYPE) val USELESS_IS_CHECK by warning1() val IS_ENUM_ENTRY by error0() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonExpressionCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonExpressionCheckers.kt index 4bc70960f9a..dc0c5265dbc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonExpressionCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/CommonExpressionCheckers.kt @@ -132,7 +132,7 @@ object CommonExpressionCheckers : ExpressionCheckers() { override val typeOperatorCallCheckers: Set get() = setOf( FirUselessTypeOperationCallChecker, - FirCannotCheckForErasedChecker + FirCastOperatorsChecker ) override val resolvedQualifierCheckers: Set diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirCastDiagnosticsHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirCastDiagnosticsHelpers.kt index 015a1f990bf..f6d3ed7d2d7 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirCastDiagnosticsHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirCastDiagnosticsHelpers.kt @@ -5,19 +5,104 @@ package org.jetbrains.kotlin.fir.analysis.checkers +import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.declarations.utils.isInterface import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.resolve.defaultType -import org.jetbrains.kotlin.fir.resolve.platformClassMapper import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap +import org.jetbrains.kotlin.fir.scopes.platformClassMapper import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeChecker.findCorrespondingSupertypes import org.jetbrains.kotlin.types.model.typeConstructor +fun isCastPossible( + lhsType: ConeKotlinType, + rhsType: ConeKotlinType, + isSafeCase: Boolean, + context: CheckerContext +): Boolean { + val lhsLowerType = lhsType.lowerBoundIfFlexible() + val rhsLowerType = rhsType.lowerBoundIfFlexible() + val session = context.session + + if (lhsLowerType is ConeIntersectionType) { + var result = false + for (intersectedType in lhsLowerType.intersectedTypes) { + val isIntersectedCastPossible = isCastPossible(intersectedType, rhsLowerType, isSafeCase, context) + val intersectedTypeSymbol = intersectedType.toRegularClassSymbol(context.session) + if (intersectedTypeSymbol?.isInterface == false && !isIntersectedCastPossible) { + return false // Any class type in intersection type should be subtype of RHS + } + result = result or isIntersectedCastPossible + } + + return result + } + + val lhsNullable = lhsLowerType.canBeNull + val rhsNullable = rhsLowerType.canBeNull + if (lhsLowerType.isNothing) return true + if (lhsLowerType.isNullableNothing && !rhsNullable) { + return isSafeCase + } + if (rhsLowerType.isNothing) return false + if (rhsLowerType.isNullableNothing) return lhsNullable + if (lhsNullable && rhsNullable) return true + val lhsClassSymbol = lhsLowerType.toRegularClassSymbol(context.session) + val rhsClassSymbol = rhsLowerType.toRegularClassSymbol(context.session) + if (isRelated(lhsLowerType, rhsLowerType, lhsClassSymbol, rhsClassSymbol, context)) return true + // This is an oversimplification (which does not render the method incomplete): + // we consider any type parameter capable of taking any value, which may be made more precise if we considered bounds + if (lhsLowerType is ConeTypeParameterType || rhsLowerType is ConeTypeParameterType) return true + + if (isFinal(lhsLowerType, session) || isFinal(rhsLowerType, session)) return false + if (lhsClassSymbol?.isInterface == true || rhsClassSymbol?.isInterface == true) return true + return false +} + +/** + * Two types are related, roughly, when one of them is a subtype of the other constructing class + * + * Note that some types have platform-specific counterparts, i.e. kotlin.String is mapped to java.lang.String, + * such types (and all their sub- and supertypes) are related too. + * + * Due to limitations in PlatformToKotlinClassMap, we only consider mapping of platform classes to Kotlin classed + * (i.e. java.lang.String -> kotlin.String) and ignore mappings that go the other way. + */ +private fun isRelated( + aType: ConeKotlinType, + bType: ConeKotlinType, + aClassSymbol: FirRegularClassSymbol?, + bClassSymbol: FirRegularClassSymbol?, + context: CheckerContext +): Boolean { + val typeContext = context.session.typeContext + + if (AbstractTypeChecker.isSubtypeOf(typeContext, aType, bType) || + AbstractTypeChecker.isSubtypeOf(typeContext, bType, aType) + ) { + return true + } + + fun getCorrespondingKotlinClass(type: ConeKotlinType): ConeKotlinType { + return context.session.platformClassMapper.getCorrespondingKotlinClass(type.classId)?.defaultType(listOf()) ?: type + } + + val aNormalizedType = getCorrespondingKotlinClass(aClassSymbol?.defaultType() ?: aType) + val bNormalizedType = getCorrespondingKotlinClass(bClassSymbol?.defaultType() ?: bType) + + return AbstractTypeChecker.isSubtypeOf(typeContext, aNormalizedType, bNormalizedType) || + AbstractTypeChecker.isSubtypeOf(typeContext, bNormalizedType, aNormalizedType) +} + +private fun isFinal(type: ConeKotlinType, session: FirSession): Boolean { + return !type.canHaveSubtypes(session) +} + fun isCastErased(supertype: ConeKotlinType, subtype: ConeKotlinType, context: CheckerContext): Boolean { val typeContext = context.session.typeContext diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCannotCheckForErasedChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCannotCheckForErasedChecker.kt deleted file mode 100644 index 8e53b8ef6a3..00000000000 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCannotCheckForErasedChecker.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir.analysis.checkers.expression - -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.isCastErased -import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn -import org.jetbrains.kotlin.fir.expressions.FirOperation -import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall -import org.jetbrains.kotlin.fir.resolve.fullyExpandedType -import org.jetbrains.kotlin.fir.types.coneType - -object FirCannotCheckForErasedChecker : FirTypeOperatorCallChecker() { - override fun check(expression: FirTypeOperatorCall, context: CheckerContext, reporter: DiagnosticReporter) { - if (expression.operation != FirOperation.IS) return - - val session = context.session - val subjectType = expression.argumentList.arguments[0].typeRef.coneType.fullyExpandedType(session) - val conversionTypeRef = expression.conversionTypeRef - val targetType = conversionTypeRef.coneType.fullyExpandedType(session) - - if (isCastErased(subjectType, targetType, context)) { - reporter.reportOn(conversionTypeRef.source, FirErrors.CANNOT_CHECK_FOR_ERASED, targetType, context) - } - } -} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCastOperatorsChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCastOperatorsChecker.kt index 487e0f948b8..94d5b9ee7d9 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCastOperatorsChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCastOperatorsChecker.kt @@ -5,13 +5,13 @@ package org.jetbrains.kotlin.fir.analysis.checkers.expression +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn import org.jetbrains.kotlin.fir.analysis.checkers.CastingType import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.isCastErased import org.jetbrains.kotlin.fir.analysis.checkers.checkCasting -import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.expressions.FirExpressionWithSmartcast import org.jetbrains.kotlin.fir.expressions.FirOperation import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall diff --git a/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index 92f0b6ff7f3..41e35a51496 100644 --- a/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -725,6 +725,7 @@ object PositioningStrategies { override fun mark(element: KtExpression): List { return when (element) { is KtBinaryExpression -> mark(element.operationReference) + is KtBinaryExpressionWithTypeRHS -> mark(element.operationReference) is KtUnaryExpression -> mark(element.operationReference) else -> super.mark(element) } diff --git a/compiler/testData/diagnostics/tests/Constants.fir.kt b/compiler/testData/diagnostics/tests/Constants.fir.kt index 3621eb86263..9265b78c24f 100644 --- a/compiler/testData/diagnostics/tests/Constants.fir.kt +++ b/compiler/testData/diagnostics/tests/Constants.fir.kt @@ -32,11 +32,11 @@ fun test() { checkSubtype(1) checkSubtype(1) - 1 as Byte + 1 as Byte 1 as Int - 0xff as Long + 0xff as Long - 1.1 as Int + 1.1 as Int checkSubtype(1.1) varargByte(0x77, 1, 3, 200, 0b111) diff --git a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.fir.kt b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.fir.kt index 2c95786fc89..c3d66cd2adb 100644 --- a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.fir.kt @@ -33,4 +33,4 @@ fun bar(a: Ann = Ann()) { operator fun String.invoke() {} // from stdlib -fun javaClass() : Class = null as Class +fun javaClass() : Class = null as Class diff --git a/compiler/testData/diagnostics/tests/cast/AsNothing.fir.kt b/compiler/testData/diagnostics/tests/cast/AsNothing.fir.kt deleted file mode 100644 index 230f58ce8de..00000000000 --- a/compiler/testData/diagnostics/tests/cast/AsNothing.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// Nothing can be cast to Nothing -fun foo(x: String) { - x as Nothing -} - -fun gav(y: String?) { - y as Nothing -} - -// Only nullable can be cast to Nothing? -fun bar(x: String, y: String?) { - x as Nothing? - y as Nothing? -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/AsNothing.kt b/compiler/testData/diagnostics/tests/cast/AsNothing.kt index c6753ad3dcc..ceb18f9bb32 100644 --- a/compiler/testData/diagnostics/tests/cast/AsNothing.kt +++ b/compiler/testData/diagnostics/tests/cast/AsNothing.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // Nothing can be cast to Nothing fun foo(x: String) { x as Nothing diff --git a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.fir.kt b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.fir.kt deleted file mode 100644 index 279219ba2ee..00000000000 --- a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -typealias MyString = String - -val x: MyString = "" -val y = x as Any - -interface Base -class Derived : Base -interface Other : Base -typealias IBase = Base -typealias IOther = Other - -val ib: IBase = Derived() -val d = ib as Derived -val o = ib as Other -val io = ib as IOther -val s = d as String -val ms = d as MyString - diff --git a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt index 6ae90b849fb..bf3159cfff8 100644 --- a/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt +++ b/compiler/testData/diagnostics/tests/cast/AsTypeAlias.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL typealias MyString = String val x: MyString = "" diff --git a/compiler/testData/diagnostics/tests/cast/constants.fir.kt b/compiler/testData/diagnostics/tests/cast/constants.fir.kt index 0b04399ea45..0e33ead18e0 100644 --- a/compiler/testData/diagnostics/tests/cast/constants.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/constants.fir.kt @@ -1,51 +1,51 @@ fun asCall() { 1 as Int - 1 as Byte - 1 as Short - 1 as Long - 1 as Char - 1 as Double - 1 as Float + 1 as Byte + 1 as Short + 1 as Long + 1 as Char + 1 as Double + 1 as Float - 1.0 as Int - 1.0 as Byte - 1.0 as Short - 1.0 as Long - 1.0 as Char + 1.0 as Int + 1.0 as Byte + 1.0 as Short + 1.0 as Long + 1.0 as Char 1.0 as Double - 1.0 as Float + 1.0 as Float - 1f as Int - 1f as Byte - 1f as Short - 1f as Long - 1f as Char - 1f as Double + 1f as Int + 1f as Byte + 1f as Short + 1f as Long + 1f as Char + 1f as Double 1f as Float } fun asSafe() { 1 as? Int - 1 as? Byte - 1 as? Short - 1 as? Long - 1 as? Char - 1 as? Double - 1 as? Float + 1 as? Byte + 1 as? Short + 1 as? Long + 1 as? Char + 1 as? Double + 1 as? Float - 1.0 as? Int - 1.0 as? Byte - 1.0 as? Short - 1.0 as? Long - 1.0 as? Char + 1.0 as? Int + 1.0 as? Byte + 1.0 as? Short + 1.0 as? Long + 1.0 as? Char 1.0 as? Double - 1.0 as? Float + 1.0 as? Float - 1f as? Int - 1f as? Byte - 1f as? Short - 1f as? Long - 1f as? Char - 1f as? Double + 1f as? Int + 1f as? Byte + 1f as? Short + 1f as? Long + 1f as? Char + 1f as? Double 1f as? Float } diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.fir.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.fir.kt deleted file mode 100644 index 1bcb23f6af9..00000000000 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.fir.kt +++ /dev/null @@ -1,33 +0,0 @@ -// !DIAGNOSTICS: -PLATFORM_CLASS_MAPPED_TO_KOTLIN -USELESS_CAST -import java.lang.String as JString -import java.lang.CharSequence as JCS - -fun test( - s: String, - js: JString, - cs: CharSequence, - jcs: JCS -) { - s as JString - s as JCS - s as CharSequence - s as String - - js as JString - js as JCS - js as CharSequence - js as String - - cs as JString - cs as JCS - cs as CharSequence - cs as String - - jcs as JString - jcs as JCS - jcs as CharSequence - jcs as String - - jcs as Int - s as java.lang.Integer -} diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.kt index 10a42477396..53d40558fe0 100644 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.kt +++ b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedDirect.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -PLATFORM_CLASS_MAPPED_TO_KOTLIN -USELESS_CAST import java.lang.String as JString import java.lang.CharSequence as JCS diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.fir.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.fir.kt deleted file mode 100644 index c776beaf211..00000000000 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// !DIAGNOSTICS: -PLATFORM_CLASS_MAPPED_TO_KOTLIN -UNUSED_PARAMETER -ABSTRACT_MEMBER_NOT_IMPLEMENTED -USELESS_CAST -import java.lang.CharSequence as JCS - -class JSub: JCS -class Sub: CharSequence - -fun test( - s: Sub, - js: JSub, - cs: CharSequence, - jcs: JCS -) { - // js as CharSequence // - this case is not supported due to limitation in PlatformToKotlinClassMap - js as JCS - - s as CharSequence - s as JCS - - js as Sub - s as JSub -} diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.kt index b8584abd89a..52ba2e8a856 100644 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.kt +++ b/compiler/testData/diagnostics/tests/cast/neverSucceeds/MappedSubtypes.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -PLATFORM_CLASS_MAPPED_TO_KOTLIN -UNUSED_PARAMETER -ABSTRACT_MEMBER_NOT_IMPLEMENTED -USELESS_CAST import java.lang.CharSequence as JCS diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.fir.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.fir.kt deleted file mode 100644 index 791075a1f6d..00000000000 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.fir.kt +++ /dev/null @@ -1,34 +0,0 @@ -// !DIAGNOSTICS: -UNCHECKED_CAST -interface Trait1 -interface Trait2 -open class OClass1 -open class OClass2 -class FClass1 -class FClass2 - -fun test( - t1: Trait1, - oc1: OClass1, - fc1: FClass1, - tp1: TP1 -) { - t1 as Trait2 - t1 as OClass2 - t1 as FClass2 - t1 as TP2 - - oc1 as Trait2 - oc1 as OClass2 - oc1 as FClass2 - oc1 as TP2 - - fc1 as Trait2 - fc1 as OClass2 - fc1 as FClass2 - fc1 as TP2 - - tp1 as Trait2 - tp1 as OClass2 - tp1 as FClass2 - tp1 as TP2 -} diff --git a/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.kt b/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.kt index 1ff4ef851a7..ca53cd96c72 100644 --- a/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.kt +++ b/compiler/testData/diagnostics/tests/cast/neverSucceeds/NoGenericsUnrelated.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNCHECKED_CAST interface Trait1 interface Trait2 diff --git a/compiler/testData/diagnostics/tests/generics/Projections.fir.kt b/compiler/testData/diagnostics/tests/generics/Projections.fir.kt index 7b9792c7fa0..a737c41441a 100644 --- a/compiler/testData/diagnostics/tests/generics/Projections.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/Projections.fir.kt @@ -19,35 +19,35 @@ class Inv() { fun testInOut() { In().f("1"); - (null as In).f("1") - (null as In<*>).f("1") // Wrong Arg + (null as In).f("1") + (null as In<*>).f("1") // Wrong Arg In().f(1); - (null as In).f(1) - (null as In<*>).f(1); + (null as In).f(1) + (null as In<*>).f(1); Out().f(1) - (null as Out).f(1) - (null as Out<*>).f(1) + (null as Out).f(1) + (null as Out<*>).f(1) Out().f() - (null as Out).f() - (null as Out<*>).f() + (null as Out).f() + (null as Out<*>).f() Inv().f(1) - (null as Inv).f(1) - (null as Inv).f(1) // !! - (null as Inv<*>).f(1) // !! + (null as Inv).f(1) + (null as Inv).f(1) // !! + (null as Inv<*>).f(1) // !! Inv().inf(1) - (null as Inv).inf(1) - (null as Inv).inf(1) // !! - (null as Inv<*>).inf(1) // !! + (null as Inv).inf(1) + (null as Inv).inf(1) // !! + (null as Inv<*>).inf(1) // !! Inv().outf() - checkSubtype((null as Inv).outf()) // Type mismatch - (null as Inv).outf() - (null as Inv<*>).outf() + checkSubtype((null as Inv).outf()) // Type mismatch + (null as Inv).outf() + (null as Inv<*>).outf() Inv().outf(1) // Wrong Arg } diff --git a/compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.fir.kt b/compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.fir.kt index 4ae9ded5d19..d31630c19a8 100644 --- a/compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeAdditionalTest.fir.kt @@ -9,4 +9,4 @@ fun foo2(): T = TODO() val test = foo2().plus("") as String fun T.bar() = this -val barTest = "".bar() as Number +val barTest = "".bar() as Number diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.fir.kt b/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.fir.kt deleted file mode 100644 index e1451fc7e96..00000000000 --- a/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.fir.kt +++ /dev/null @@ -1,11 +0,0 @@ -fun runCatching(block: () -> R) = null as Result - -class Result { - fun getOrNull(): T? = null -} - -fun main() { - runCatching { - null - }.getOrNull() // don't report IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION -} diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.kt b/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.kt index 578b4129f24..19414915b2d 100644 --- a/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.kt +++ b/compiler/testData/diagnostics/tests/inference/nothingType/reportImplicitNothingOnlyForOwnTypeParameters.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun runCatching(block: () -> R) = null as Result class Result { diff --git a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt index 1d5726360a2..35b2d14cb66 100644 --- a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt @@ -52,7 +52,7 @@ fun test() { if (x11 is Foo<_>) { } x10 as _ - x10 as Foo<_> + x10 as Foo<_> val x12: Foo<@_ Int>? = null val x13: Foo<@_() Int>? = null diff --git a/compiler/testData/diagnostics/tests/regressions/kt701.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt701.fir.kt deleted file mode 100644 index cf0ee60d879..00000000000 --- a/compiler/testData/diagnostics/tests/regressions/kt701.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// KT-702 Type inference failed -fun getJavaClass() : java.lang.Class { return "" as Class } - -public class Throwables() { - companion object { - public fun propagateIfInstanceOf(throwable : Throwable?, declaredType : Class?) { - if (((throwable != null) && declaredType?.isInstance(throwable)!!)) - { - throw declaredType?.cast(throwable)!! - } - } - public fun propagateIfPossible(throwable : Throwable?) { - propagateIfInstanceOf(throwable, getJavaClass()) //; Type inference failed: Mismatch while expanding constraints - propagateIfInstanceOf(throwable, getJavaClass()) // Type inference failed: Mismatch while expanding constraints - } - } -} diff --git a/compiler/testData/diagnostics/tests/regressions/kt701.kt b/compiler/testData/diagnostics/tests/regressions/kt701.kt index 7eff04251d7..61b3b150de6 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt701.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt701.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // KT-702 Type inference failed fun getJavaClass() : java.lang.Class { return "" as Class } diff --git a/compiler/testData/diagnostics/tests/regressions/kt716.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt716.fir.kt index 86e1944ff77..1464afccfb6 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt716.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt716.fir.kt @@ -2,7 +2,7 @@ class TypeInfo -fun typeinfo() : TypeInfo = null as TypeInfo +fun typeinfo() : TypeInfo = null as TypeInfo fun TypeInfo.getJavaClass() : java.lang.Class { val t : java.lang.Object = this as java.lang.Object @@ -13,4 +13,4 @@ fun getJavaClass() = typeinfo().getJavaClass() fun main() { System.out.println(getJavaClass()) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/castchecks/variables.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/castchecks/variables.fir.kt index c0c4a2e291a..0333aef8a17 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/castchecks/variables.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/castchecks/variables.fir.kt @@ -43,7 +43,7 @@ fun f(a: SomeClass?) { aa.hashCode() aa.foo (aa as? SomeSubClass).foo - (aa as SomeSubClass).foo + (aa as SomeSubClass).foo } val b = (aa as? SomeSubClass)?.foo aa = null @@ -52,7 +52,7 @@ fun f(a: SomeClass?) { aa.hashCode() aa.foo (aa as? SomeSubClass).foo - (aa as SomeSubClass).foo + (aa as SomeSubClass).foo } aa = a val c = aa as? SomeSubClass diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatement.fir.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatement.fir.kt index 0662798c80a..eb7c4fb9de1 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatement.fir.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatement.fir.kt @@ -4,7 +4,7 @@ fun foo(x: Array, y: IntArray, block: (T, Int) -> Int) { @Suppress("UNCHECKED_CAST") // comment /* comment */ - r = block(x[0] as T, "" as Int) + r = block(x[0] as T, "" as Int) // to prevent unused assignment diagnostic for the above statement r.hashCode() @@ -13,42 +13,42 @@ fun foo(x: Array, y: IntArray, block: (T, Int) -> Int) { if (i != 1) { @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() } if (i != 1) @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() if (i != 2) @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() else @Suppress("UNCHECKED_CAST") - i += block(x[1] as T, "" as Int).toInt() + i += block(x[1] as T, "" as Int).toInt() while (i != 1) @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() do @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() while (i != 1) for (j in 1..100) @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() when (i) { 1 -> @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() } val l: () -> Unit = { @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() } l() @@ -56,5 +56,5 @@ fun foo(x: Array, y: IntArray, block: (T, Int) -> Int) { @Suppress("UNCHECKED_CAST") - y[i] += block(x[0] as T, "" as Int).toInt() + y[i] += block(x[0] as T, "" as Int).toInt() } diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatementSameLine.fir.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatementSameLine.fir.kt index f4d553bdfcb..4fb4e12bc5f 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatementSameLine.fir.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/onBlockStatementSameLine.fir.kt @@ -1,7 +1,7 @@ fun foo(x: Array, block: (T, Int) -> Int) { var r: Any? - @Suppress("UNCHECKED_CAST") r = block(x[0] as T, "" as Int) + @Suppress("UNCHECKED_CAST") r = block(x[0] as T, "" as Int) // to prevent unused assignment diagnostic for the above statement r.hashCode() @@ -9,11 +9,11 @@ fun foo(x: Array, block: (T, Int) -> Int) { var i = 1 if (i != 1) { - @Suppress("UNCHECKED_CAST") i += block(x[0] as T, "" as Int).toInt() + @Suppress("UNCHECKED_CAST") i += block(x[0] as T, "" as Int).toInt() } if (i != 1) @Suppress("UNCHECKED_CAST") - i += block(x[0] as T, "" as Int).toInt() + i += block(x[0] as T, "" as Int).toInt() - if (i != 1) @Suppress("UNCHECKED_CAST") i += block(x[0] as T, "" as Int).toInt() + if (i != 1) @Suppress("UNCHECKED_CAST") i += block(x[0] as T, "" as Int).toInt() } diff --git a/compiler/testData/diagnostics/tests/typeParameters/kt42472.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/kt42472.fir.kt index 884516f1ee3..1c05d53c7ae 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/kt42472.fir.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/kt42472.fir.kt @@ -8,5 +8,5 @@ fun interface ReadOnlyProperty { class Problem { val variable: Int by delegate() // delegate returns `ReadOnlyProperty` - fun delegate() = null as ReadOnlyProperty + fun delegate() = null as ReadOnlyProperty } diff --git a/compiler/testData/diagnostics/tests/unitConversion/unitConversionForSubtypes.fir.kt b/compiler/testData/diagnostics/tests/unitConversion/unitConversionForSubtypes.fir.kt index 74258132220..ec8c5f742e4 100644 --- a/compiler/testData/diagnostics/tests/unitConversion/unitConversionForSubtypes.fir.kt +++ b/compiler/testData/diagnostics/tests/unitConversion/unitConversionForSubtypes.fir.kt @@ -13,7 +13,7 @@ fun test1(s: SubInt, sWrong: SubIntWrong) { val a = "foo" foo(a) - a as (Int, String) -> String + a as (Int, String) -> String foo(a) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.fir.kt index cac3e694b33..ac8887f8a41 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.fir.kt @@ -37,6 +37,6 @@ fun test() { // TODO: should we allow somehow to call with passing continuation explicitly? severalParams("", 89, 6.9) checkType { _() } - severalParams("", 89, this as Continuation) checkType { _() } + severalParams("", 89, this as Continuation) checkType { _() } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.fir.kt index 4795e4859cc..815d312ba2a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.fir.kt @@ -9,8 +9,8 @@ fun box() { val b = Array<Nothing?>(5) { null!! } val c = foo() { null!! } val d = foo { null!! } - val e = foo { "1" as Nothing } - val e1 = foo { "1" as Nothing? } + val e = foo { "1" as Nothing } + val e1 = foo { "1" as Nothing? } val f = javaClass<Nothing>() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.fir.kt index ab9ee12cab9..98333dbe157 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/1.fir.kt @@ -47,7 +47,7 @@ fun case_5(value_1: Int?) { println("!") contract { returns(true) implies (value_1 != null) - } as ContractBuilder + } as ContractBuilder } /* @@ -93,6 +93,6 @@ fun case_9(number: Int?): Boolean { val value_1 = number != null contract { returns(false) implies (value_1) - } as ContractBuilder + } as ContractBuilder return number == null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.fir.kt index 1ab89eb02c0..515a4ce2bf2 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/16.fir.kt @@ -8,7 +8,7 @@ fun case_1(value_1: Int?) { println("!") contract { returns(true) implies (value_1 != null) - } as ContractBuilder + } as ContractBuilder } // TESTCASE NUMBER: 2 @@ -42,6 +42,6 @@ fun case_5(number: Int?): Boolean { val value_1 = number != null contract { returns(false) implies (value_1) - } as ContractBuilder + } as ContractBuilder return number == null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt index fafe7410b27..80a98856ef4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt @@ -6,7 +6,7 @@ fun case_1(x: Interface1) = x fun case_1(x: Interface2) = x fun case_1() { - val x: Interface1 = null as Interface1 + val x: Interface1 = null as Interface1 x as Interface2 case_1(x) }