[FE] Add clear warning about future changes about nullability of safe call with non nullable receiver
^KT-46860
This commit is contained in:
committed by
teamcityserver
parent
937f4c1dab
commit
f26059a7d3
+7
@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
|||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.psi.KtTypeAlias
|
import org.jetbrains.kotlin.psi.KtTypeAlias
|
||||||
@@ -3041,6 +3042,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
|||||||
token,
|
token,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
add(FirErrors.SAFE_CALL_WILL_CHANGE_NULLABILITY) { firDiagnostic ->
|
||||||
|
SafeCallWillChangeNullabilityImpl(
|
||||||
|
firDiagnostic as FirPsiDiagnostic,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
}
|
||||||
add(FirErrors.UNEXPECTED_SAFE_CALL) { firDiagnostic ->
|
add(FirErrors.UNEXPECTED_SAFE_CALL) { firDiagnostic ->
|
||||||
UnexpectedSafeCallImpl(
|
UnexpectedSafeCallImpl(
|
||||||
firDiagnostic as FirPsiDiagnostic,
|
firDiagnostic as FirPsiDiagnostic,
|
||||||
|
|||||||
+5
@@ -64,6 +64,7 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
|||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.psi.KtTypeAlias
|
import org.jetbrains.kotlin.psi.KtTypeAlias
|
||||||
@@ -2128,6 +2129,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
|||||||
abstract val receiverType: KtType
|
abstract val receiverType: KtType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class SafeCallWillChangeNullability : KtFirDiagnostic<KtSafeQualifiedExpression>() {
|
||||||
|
override val diagnosticClass get() = SafeCallWillChangeNullability::class
|
||||||
|
}
|
||||||
|
|
||||||
abstract class UnexpectedSafeCall : KtFirDiagnostic<PsiElement>() {
|
abstract class UnexpectedSafeCall : KtFirDiagnostic<PsiElement>() {
|
||||||
override val diagnosticClass get() = UnexpectedSafeCall::class
|
override val diagnosticClass get() = UnexpectedSafeCall::class
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
|||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.psi.KtTypeAlias
|
import org.jetbrains.kotlin.psi.KtTypeAlias
|
||||||
@@ -2562,6 +2563,11 @@ internal class UnnecessarySafeCallImpl(
|
|||||||
override val token: ValidityToken,
|
override val token: ValidityToken,
|
||||||
) : KtFirDiagnostic.UnnecessarySafeCall(), KtAbstractFirDiagnostic<PsiElement>
|
) : KtFirDiagnostic.UnnecessarySafeCall(), KtAbstractFirDiagnostic<PsiElement>
|
||||||
|
|
||||||
|
internal class SafeCallWillChangeNullabilityImpl(
|
||||||
|
override val firDiagnostic: FirPsiDiagnostic,
|
||||||
|
override val token: ValidityToken,
|
||||||
|
) : KtFirDiagnostic.SafeCallWillChangeNullability(), KtAbstractFirDiagnostic<KtSafeQualifiedExpression>
|
||||||
|
|
||||||
internal class UnexpectedSafeCallImpl(
|
internal class UnexpectedSafeCallImpl(
|
||||||
override val firDiagnostic: FirPsiDiagnostic,
|
override val firDiagnostic: FirPsiDiagnostic,
|
||||||
override val token: ValidityToken,
|
override val token: ValidityToken,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ fun test(ordinal: Int) {
|
|||||||
buildString {
|
buildString {
|
||||||
insert(KDocTemplate()) {
|
insert(KDocTemplate()) {
|
||||||
definition {
|
definition {
|
||||||
ordinal<!UNNECESSARY_SAFE_CALL!>?.<!>let {}
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>ordinal<!UNNECESSARY_SAFE_CALL!>?.<!>let {}<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -69,8 +69,8 @@ fun test_6(d1: D) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test_7(d1: D, d2: D) {
|
fun test_7(d1: D, d2: D) {
|
||||||
val a = d1<!UNNECESSARY_SAFE_CALL!>?.<!>any
|
val a = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>d1<!UNNECESSARY_SAFE_CALL!>?.<!>any<!>
|
||||||
val b = d2<!UNNECESSARY_SAFE_CALL!>?.<!>any
|
val b = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>d2<!UNNECESSARY_SAFE_CALL!>?.<!>any<!>
|
||||||
a as A
|
a as A
|
||||||
a.foo() // should be OK
|
a.foo() // should be OK
|
||||||
b as B
|
b as B
|
||||||
|
|||||||
+1
@@ -1084,6 +1084,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
|||||||
val UNNECESSARY_SAFE_CALL by warning<PsiElement>(PositioningStrategy.SAFE_ACCESS) {
|
val UNNECESSARY_SAFE_CALL by warning<PsiElement>(PositioningStrategy.SAFE_ACCESS) {
|
||||||
parameter<ConeKotlinType>("receiverType")
|
parameter<ConeKotlinType>("receiverType")
|
||||||
}
|
}
|
||||||
|
val SAFE_CALL_WILL_CHANGE_NULLABILITY by warning<KtSafeQualifiedExpression>()
|
||||||
val UNEXPECTED_SAFE_CALL by error<PsiElement>(PositioningStrategy.SAFE_ACCESS)
|
val UNEXPECTED_SAFE_CALL by error<PsiElement>(PositioningStrategy.SAFE_ACCESS)
|
||||||
val UNNECESSARY_NOT_NULL_ASSERTION by warning<KtExpression>(PositioningStrategy.OPERATOR) {
|
val UNNECESSARY_NOT_NULL_ASSERTION by warning<KtExpression>(PositioningStrategy.OPERATOR) {
|
||||||
parameter<ConeKotlinType>("receiverType")
|
parameter<ConeKotlinType>("receiverType")
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
|||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.psi.KtReturnExpression
|
import org.jetbrains.kotlin.psi.KtReturnExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.psi.KtTypeAlias
|
import org.jetbrains.kotlin.psi.KtTypeAlias
|
||||||
@@ -577,6 +578,7 @@ object FirErrors {
|
|||||||
val UNSAFE_OPERATOR_CALL by error3<KtExpression, FirExpression, String, FirExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
val UNSAFE_OPERATOR_CALL by error3<KtExpression, FirExpression, String, FirExpression>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||||
val ITERATOR_ON_NULLABLE by error0<KtExpression>()
|
val ITERATOR_ON_NULLABLE by error0<KtExpression>()
|
||||||
val UNNECESSARY_SAFE_CALL by warning1<PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.SAFE_ACCESS)
|
val UNNECESSARY_SAFE_CALL by warning1<PsiElement, ConeKotlinType>(SourceElementPositioningStrategies.SAFE_ACCESS)
|
||||||
|
val SAFE_CALL_WILL_CHANGE_NULLABILITY by warning0<KtSafeQualifiedExpression>()
|
||||||
val UNEXPECTED_SAFE_CALL by error0<PsiElement>(SourceElementPositioningStrategies.SAFE_ACCESS)
|
val UNEXPECTED_SAFE_CALL by error0<PsiElement>(SourceElementPositioningStrategies.SAFE_ACCESS)
|
||||||
val UNNECESSARY_NOT_NULL_ASSERTION by warning1<KtExpression, ConeKotlinType>(SourceElementPositioningStrategies.OPERATOR)
|
val UNNECESSARY_NOT_NULL_ASSERTION by warning1<KtExpression, ConeKotlinType>(SourceElementPositioningStrategies.OPERATOR)
|
||||||
val NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION by warning0<KtExpression>(SourceElementPositioningStrategies.OPERATOR)
|
val NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION by warning0<KtExpression>(SourceElementPositioningStrategies.OPERATOR)
|
||||||
|
|||||||
+5
@@ -6,11 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.fir.analysis.checkers.expression
|
package org.jetbrains.kotlin.fir.analysis.checkers.expression
|
||||||
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
import org.jetbrains.kotlin.KtNodeTypes
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirSafeCallExpression
|
import org.jetbrains.kotlin.fir.expressions.FirSafeCallExpression
|
||||||
|
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
import org.jetbrains.kotlin.fir.types.canBeNull
|
import org.jetbrains.kotlin.fir.types.canBeNull
|
||||||
import org.jetbrains.kotlin.fir.types.coneType
|
import org.jetbrains.kotlin.fir.types.coneType
|
||||||
@@ -25,6 +27,9 @@ object FirUnnecessarySafeCallChecker : FirSafeCallExpressionChecker() {
|
|||||||
}
|
}
|
||||||
if (!receiverType.canBeNull) {
|
if (!receiverType.canBeNull) {
|
||||||
reporter.reportOn(expression.source, FirErrors.UNNECESSARY_SAFE_CALL, receiverType, context)
|
reporter.reportOn(expression.source, FirErrors.UNNECESSARY_SAFE_CALL, receiverType, context)
|
||||||
|
if (!context.session.languageVersionSettings.supportsFeature(LanguageFeature.SafeCallsAreAlwaysNullable)) {
|
||||||
|
reporter.reportOn(expression.source, FirErrors.SAFE_CALL_WILL_CHANGE_NULLABILITY, context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1007,6 +1007,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory3<KtExpression, PsiElement, String, PsiElement> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
DiagnosticFactory3<KtExpression, PsiElement, String, PsiElement> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||||
DiagnosticFactory3<KtExpression, PsiElement, String, PsiElement> UNSAFE_OPERATOR_CALL = DiagnosticFactory3.create(ERROR);
|
DiagnosticFactory3<KtExpression, PsiElement, String, PsiElement> UNSAFE_OPERATOR_CALL = DiagnosticFactory3.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||||
|
DiagnosticFactory0<PsiElement> SAFE_CALL_WILL_CHANGE_NULLABILITY = DiagnosticFactory0.create(WARNING);
|
||||||
DiagnosticFactory0<PsiElement> UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||||
DiagnosticFactory0<PsiElement> NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<PsiElement> NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION = DiagnosticFactory0.create(WARNING);
|
||||||
|
|||||||
+1
@@ -718,6 +718,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
|
||||||
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
|
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
|
||||||
MAP.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}. This expression will have nullable type in future releases", RENDER_TYPE);
|
MAP.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}. This expression will have nullable type in future releases", RENDER_TYPE);
|
||||||
|
MAP.put(SAFE_CALL_WILL_CHANGE_NULLABILITY, "Safe call on a non-null receiver will have nullable type in future releases");
|
||||||
MAP.put(UNEXPECTED_SAFE_CALL, "Safe-call is not allowed here");
|
MAP.put(UNEXPECTED_SAFE_CALL, "Safe-call is not allowed here");
|
||||||
MAP.put(UNNECESSARY_NOT_NULL_ASSERTION, "Unnecessary non-null assertion (!!) on a non-null receiver of type {0}", RENDER_TYPE);
|
MAP.put(UNNECESSARY_NOT_NULL_ASSERTION, "Unnecessary non-null assertion (!!) on a non-null receiver of type {0}", RENDER_TYPE);
|
||||||
MAP.put(NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION, "Non-null assertion (!!) is called on a lambda expression");
|
MAP.put(NOT_NULL_ASSERTION_ON_LAMBDA_EXPRESSION, "Non-null assertion (!!) is called on a lambda expression");
|
||||||
|
|||||||
@@ -366,7 +366,14 @@ class CallExpressionResolver(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!receiverCanBeNull) {
|
if (!receiverCanBeNull) {
|
||||||
reportUnnecessarySafeCall(context.trace, receiver.type, callOperationNode, receiver)
|
reportUnnecessarySafeCall(
|
||||||
|
context.trace,
|
||||||
|
receiver.type,
|
||||||
|
element.qualified,
|
||||||
|
callOperationNode,
|
||||||
|
receiver,
|
||||||
|
context.languageVersionSettings
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,13 +537,18 @@ class CallExpressionResolver(
|
|||||||
fun reportUnnecessarySafeCall(
|
fun reportUnnecessarySafeCall(
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
type: KotlinType,
|
type: KotlinType,
|
||||||
|
callElement: KtQualifiedExpression,
|
||||||
callOperationNode: ASTNode,
|
callOperationNode: ASTNode,
|
||||||
explicitReceiver: Receiver?
|
explicitReceiver: Receiver?,
|
||||||
|
languageVersionSettings: LanguageVersionSettings
|
||||||
) {
|
) {
|
||||||
if (explicitReceiver is ExpressionReceiver && explicitReceiver.expression is KtSuperExpression) {
|
if (explicitReceiver is ExpressionReceiver && explicitReceiver.expression is KtSuperExpression) {
|
||||||
trace.report(UNEXPECTED_SAFE_CALL.on(callOperationNode.psi))
|
trace.report(UNEXPECTED_SAFE_CALL.on(callOperationNode.psi))
|
||||||
} else if (!type.isError) {
|
} else if (!type.isError) {
|
||||||
trace.report(UNNECESSARY_SAFE_CALL.on(callOperationNode.psi, type))
|
trace.report(UNNECESSARY_SAFE_CALL.on(callOperationNode.psi, type))
|
||||||
|
if (!languageVersionSettings.supportsFeature(LanguageFeature.SafeCallsAreAlwaysNullable)) {
|
||||||
|
trace.report(SAFE_CALL_WILL_CHANGE_NULLABILITY.on(callElement))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -58,7 +58,7 @@ public class A {
|
|||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("").length
|
a.foo("").length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||||
a.bar(null)?.length
|
a.bar(null)?.length
|
||||||
@@ -73,5 +73,5 @@ fun main(a: A) {
|
|||||||
|
|
||||||
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
||||||
a.baz3()!!.get(0).length
|
a.baz3()!!.get(0).length
|
||||||
a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ public class A {
|
|||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("").length
|
a.foo("").length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||||
a.bar(null)?.length
|
a.bar(null)?.length
|
||||||
|
|||||||
compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jsr305/springNullableWithTypeUse.kt
Vendored
+3
-3
@@ -63,17 +63,17 @@ public class A {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo("", null).length
|
a.foo("", null).length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
a.bar().length
|
a.bar().length
|
||||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||||
|
|
||||||
a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.field.length
|
a.field.length
|
||||||
|
|
||||||
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
||||||
a.baz()!!.get(0).get(0)
|
a.baz()!!.get(0).get(0)
|
||||||
a.baz()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -58,10 +58,10 @@ public class A {
|
|||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("").length
|
a.foo("").length
|
||||||
a.foo(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
a.bar("").length
|
a.bar("").length
|
||||||
a.bar(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.bar(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
a.baz1().get(0).length
|
a.baz1().get(0).length
|
||||||
a.baz1()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.get(0).length
|
a.baz1()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.get(0).length
|
||||||
|
|||||||
Vendored
+2
-2
@@ -58,7 +58,7 @@ public class A {
|
|||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("").length
|
a.foo("").length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
a.bar("")<!UNSAFE_CALL!>.<!>length
|
a.bar("")<!UNSAFE_CALL!>.<!>length
|
||||||
a.bar(null)?.length
|
a.bar(null)?.length
|
||||||
@@ -73,5 +73,5 @@ fun main(a: A) {
|
|||||||
|
|
||||||
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
a.baz3()<!UNSAFE_CALL!>.<!>get(0).length
|
||||||
a.baz3()!!.get(0).length
|
a.baz3()!!.get(0).length
|
||||||
a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.baz3()!!.get(0)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ fun safeCalls() {
|
|||||||
val a = jsr.string?.length
|
val a = jsr.string?.length
|
||||||
val b = jsrNullable?.string?.length
|
val b = jsrNullable?.string?.length
|
||||||
|
|
||||||
val c = jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
val c = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
val d = jbNullable?.string?.length
|
val d = jbNullable?.string?.length
|
||||||
|
|
||||||
val e = platform.string?.length
|
val e = platform.string?.length
|
||||||
|
|||||||
Vendored
+1
-1
@@ -64,7 +64,7 @@ fun safeCalls() {
|
|||||||
val a = jsr.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
val a = jsr.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
||||||
val b = jsrNullable?.string?.length
|
val b = jsrNullable?.string?.length
|
||||||
|
|
||||||
val c = jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
val c = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>jb.string<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
val d = jbNullable?.string?.length
|
val d = jbNullable?.string?.length
|
||||||
|
|
||||||
val e = platform.string?.length
|
val e = platform.string?.length
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ fun main(a: A) {
|
|||||||
a.field.length
|
a.field.length
|
||||||
a.field = null
|
a.field = null
|
||||||
|
|
||||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.nonNullField.length
|
a.nonNullField.length
|
||||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ fun main(a: A) {
|
|||||||
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.length
|
||||||
a.field = null
|
a.field = null
|
||||||
|
|
||||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.nonNullField.length
|
a.nonNullField.length
|
||||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ fun main(a: A) {
|
|||||||
a.field<!UNSAFE_CALL!>.<!>length
|
a.field<!UNSAFE_CALL!>.<!>length
|
||||||
a.field = null
|
a.field = null
|
||||||
|
|
||||||
a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.nonNullField<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.nonNullField.length
|
a.nonNullField.length
|
||||||
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
a.nonNullField = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ public class A {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo("", null).length
|
a.foo("", null).length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ fun main(a: A, b: B, c: C) {
|
|||||||
c.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
c.foo2(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||||
c.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
c.foo3(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||||
c.bar1(null).length
|
c.bar1(null).length
|
||||||
c.bar1(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c.bar1(null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
c.bar2(null)<!UNSAFE_CALL!>.<!>length
|
c.bar2(null)<!UNSAFE_CALL!>.<!>length
|
||||||
c.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
c.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>).length
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -127,7 +127,7 @@ public class A {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A, b: A.B, c: A.C) {
|
fun main(a: A, b: A.B, c: A.C) {
|
||||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo("", null).length
|
a.foo("", null).length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
|||||||
a.bar().length
|
a.bar().length
|
||||||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
|
||||||
|
|
||||||
a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.field<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.field.length
|
a.field.length
|
||||||
|
|
||||||
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
a.baz()<!UNSAFE_CALL!>.<!>get(0)
|
||||||
@@ -150,7 +150,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
|||||||
b.foo(null, "")<!UNSAFE_CALL!>.<!>length
|
b.foo(null, "")<!UNSAFE_CALL!>.<!>length
|
||||||
|
|
||||||
b.foobar(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
b.foobar(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
b.foobar("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b.foobar("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
b.bar()<!UNSAFE_CALL!>.<!>length
|
b.bar()<!UNSAFE_CALL!>.<!>length
|
||||||
b.bar()!!.length
|
b.bar()!!.length
|
||||||
@@ -163,7 +163,7 @@ fun main(a: A, b: A.B, c: A.C) {
|
|||||||
b.baz()!!.get(0)?.get(0)
|
b.baz()!!.get(0)?.get(0)
|
||||||
|
|
||||||
// c
|
// c
|
||||||
c.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
c.foo("", null).length
|
c.foo("", null).length
|
||||||
c.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
c.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ public class A {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo("", null).length
|
a.foo("", null).length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ public class A {
|
|||||||
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: test.A) {
|
fun main(a: test.A) {
|
||||||
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo("", null).length
|
a.foo("", null).length
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "").length
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -15,6 +15,6 @@ public class A {
|
|||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
fun main(a: A) {
|
fun main(a: A) {
|
||||||
a.foo("").length
|
a.foo("").length
|
||||||
a.foo("")<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo("")<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fun bar(doIt: Int.() -> Int) {
|
fun bar(doIt: Int.() -> Int) {
|
||||||
1.doIt()
|
1.doIt()
|
||||||
1<!UNNECESSARY_SAFE_CALL!>?.<!>doIt()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>1<!UNNECESSARY_SAFE_CALL!>?.<!>doIt()<!>
|
||||||
val i: Int? = 1
|
val i: Int? = 1
|
||||||
<!ARGUMENT_TYPE_MISMATCH!>i<!>.doIt()
|
<!ARGUMENT_TYPE_MISMATCH!>i<!>.doIt()
|
||||||
i?.doIt()
|
i?.doIt()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fun bar(doIt: Int.() -> Int) {
|
fun bar(doIt: Int.() -> Int) {
|
||||||
1.doIt()
|
1.doIt()
|
||||||
1<!UNNECESSARY_SAFE_CALL!>?.<!>doIt()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>1<!UNNECESSARY_SAFE_CALL!>?.<!>doIt()<!>
|
||||||
val i: Int? = 1
|
val i: Int? = 1
|
||||||
i<!UNSAFE_CALL!>.<!>doIt()
|
i<!UNSAFE_CALL!>.<!>doIt()
|
||||||
i?.doIt()
|
i?.doIt()
|
||||||
|
|||||||
@@ -82,6 +82,6 @@ fun test() {
|
|||||||
val i : Int? = null
|
val i : Int? = null
|
||||||
i.(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)();
|
i.(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)();
|
||||||
<!INAPPLICABLE_CANDIDATE!>{}<!><Int>()
|
<!INAPPLICABLE_CANDIDATE!>{}<!><Int>()
|
||||||
1<!UNNECESSARY_SAFE_CALL!>?.<!>(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>1<!UNNECESSARY_SAFE_CALL!>?.<!>(<!UNRESOLVED_REFERENCE!>fun Int.() = 1<!>)()<!>
|
||||||
1.<!NO_RECEIVER_ALLOWED!>{}<!>()
|
1.<!NO_RECEIVER_ALLOWED!>{}<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,6 @@ fun test() {
|
|||||||
val i : Int? = null
|
val i : Int? = null
|
||||||
i<!UNSAFE_CALL!>.<!>(fun Int.() = 1)();
|
i<!UNSAFE_CALL!>.<!>(fun Int.() = 1)();
|
||||||
{}<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>()
|
{}<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>()
|
||||||
1<!UNNECESSARY_SAFE_CALL!>?.<!>(fun Int.() = 1)()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>1<!UNNECESSARY_SAFE_CALL!>?.<!>(fun Int.() = 1)()<!>
|
||||||
1.<!NO_RECEIVER_ALLOWED!>{}<!>()
|
1.<!NO_RECEIVER_ALLOWED!>{}<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,6 @@ fun foo() {
|
|||||||
// these both also ok (with smart cast / unnecessary safe call)
|
// these both also ok (with smart cast / unnecessary safe call)
|
||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
rule.apply()
|
rule.apply()
|
||||||
rule<!UNNECESSARY_SAFE_CALL!>?.<!>apply()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>rule<!UNNECESSARY_SAFE_CALL!>?.<!>apply()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -18,6 +18,6 @@ fun foo() {
|
|||||||
// these both also ok (with smart cast / unnecessary safe call)
|
// these both also ok (with smart cast / unnecessary safe call)
|
||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>rule<!>.apply()
|
<!DEBUG_INFO_SMARTCAST!>rule<!>.apply()
|
||||||
rule<!UNNECESSARY_SAFE_CALL!>?.<!>apply()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>rule<!UNNECESSARY_SAFE_CALL!>?.<!>apply()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
|
|
||||||
fun ff() {
|
fun ff() {
|
||||||
val i: Int = 1
|
val i: Int = 1
|
||||||
val a: Int = i<!UNNECESSARY_SAFE_CALL!>?.<!>plus(2)
|
val a: Int = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>i<!UNNECESSARY_SAFE_CALL!>?.<!>plus(2)<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
|
|
||||||
fun ff() {
|
fun ff() {
|
||||||
val i: Int = 1
|
val i: Int = 1
|
||||||
val a: Int? = i<!UNNECESSARY_SAFE_CALL!>?.<!>plus(2)
|
val a: Int? = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>i<!UNNECESSARY_SAFE_CALL!>?.<!>plus(2)<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,5 +2,5 @@ fun Int.gg() = null
|
|||||||
|
|
||||||
fun ff() {
|
fun ff() {
|
||||||
val a: Int = 1
|
val a: Int = 1
|
||||||
val b: Int = <!INITIALIZER_TYPE_MISMATCH, TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
|
val b: Int = <!INITIALIZER_TYPE_MISMATCH, SAFE_CALL_WILL_CHANGE_NULLABILITY, TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ fun Int.gg() = null
|
|||||||
|
|
||||||
fun ff() {
|
fun ff() {
|
||||||
val a: Int = 1
|
val a: Int = 1
|
||||||
val b: Int = <!TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
|
val b: Int = <!SAFE_CALL_WILL_CHANGE_NULLABILITY, TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ fun test11() {
|
|||||||
|
|
||||||
fun test12() {
|
fun test12() {
|
||||||
fun Any.bar(i: Int) {}
|
fun Any.bar(i: Int) {}
|
||||||
todo()<!UNREACHABLE_CODE!><!UNNECESSARY_SAFE_CALL!>?.<!>bar(1)<!>
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>todo()<!UNREACHABLE_CODE!><!UNNECESSARY_SAFE_CALL!>?.<!>bar(1)<!><!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun todo(): Nothing = throw Exception()
|
fun todo(): Nothing = throw Exception()
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ fun test11() {
|
|||||||
|
|
||||||
fun test12() {
|
fun test12() {
|
||||||
fun Any.bar(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
fun Any.bar(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||||
todo()<!UNNECESSARY_SAFE_CALL!>?.<!><!UNREACHABLE_CODE!>bar(1)<!>
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>todo()<!UNNECESSARY_SAFE_CALL!>?.<!><!UNREACHABLE_CODE!>bar(1)<!><!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun todo(): Nothing = throw Exception()
|
fun todo(): Nothing = throw Exception()
|
||||||
+1
-1
@@ -8,6 +8,6 @@ fun foo(): String {
|
|||||||
}
|
}
|
||||||
fun bar(): String {
|
fun bar(): String {
|
||||||
val x = fn() ?: return ""
|
val x = fn() ?: return ""
|
||||||
val y = x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } <!USELESS_ELVIS!>?: "unreachable"<!>
|
val y = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() }<!> <!USELESS_ELVIS!>?: "unreachable"<!>
|
||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ fun foo(): String {
|
|||||||
}
|
}
|
||||||
fun bar(): String {
|
fun bar(): String {
|
||||||
val x = fn() ?: return ""
|
val x = fn() ?: return ""
|
||||||
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>y<!> =<!> x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } <!UNREACHABLE_CODE, USELESS_ELVIS!>?: "unreachable"<!>
|
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>y<!> =<!> <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() }<!> <!UNREACHABLE_CODE, USELESS_ELVIS!>?: "unreachable"<!>
|
||||||
<!UNREACHABLE_CODE!>return y<!>
|
<!UNREACHABLE_CODE!>return y<!>
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ fun <T: Any, E> T.foo(x : E, y : A) : T {
|
|||||||
y plus 1
|
y plus 1
|
||||||
y + 1.0
|
y + 1.0
|
||||||
|
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)<!>
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ import outer.*
|
|||||||
command?.equals1(null)
|
command?.equals1(null)
|
||||||
|
|
||||||
val c = Command()
|
val c = Command()
|
||||||
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)<!>
|
||||||
|
|
||||||
if (command == null) 1
|
if (command == null) 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fun <T: Any, E> T.foo(x : E, y : A) : T {
|
|||||||
y plus 1
|
y plus 1
|
||||||
y + 1.0
|
y + 1.0
|
||||||
|
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)<!>
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ import outer.*
|
|||||||
command?.equals1(null)
|
command?.equals1(null)
|
||||||
|
|
||||||
val c = Command()
|
val c = Command()
|
||||||
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)<!>
|
||||||
|
|
||||||
if (command == null) 1
|
if (command == null) 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ fun foo(l: A<String>?) {
|
|||||||
foo(l?.bar()) checkType { _<String?>() }
|
foo(l?.bar()) checkType { _<String?>() }
|
||||||
foo(l?.gav()) checkType { _<String?>() }
|
foo(l?.gav()) checkType { _<String?>() }
|
||||||
if (l != null) {
|
if (l != null) {
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fooNotNull(l: A<String>) {
|
fun fooNotNull(l: A<String>) {
|
||||||
// No errors should be here
|
// No errors should be here
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><String>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
|
|||||||
+4
-4
@@ -27,15 +27,15 @@ fun foo(l: A<String>?) {
|
|||||||
foo(l?.bar()) checkType { _<String?>() }
|
foo(l?.bar()) checkType { _<String?>() }
|
||||||
foo(l?.gav()) checkType { _<String?>() }
|
foo(l?.gav()) checkType { _<String?>() }
|
||||||
if (l != null) {
|
if (l != null) {
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { _<String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { _<String>() }
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { _<String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { _<String>() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fooNotNull(l: A<String>) {
|
fun fooNotNull(l: A<String>) {
|
||||||
// No errors should be here
|
// No errors should be here
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()) checkType { _<String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!>) checkType { _<String>() }
|
||||||
foo(l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()) checkType { _<String>() }
|
foo(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>l<!UNNECESSARY_SAFE_CALL!>?.<!>gav()<!>) checkType { _<String>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
||||||
|
|
||||||
x.length
|
x.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
x.bar1()
|
x.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
@@ -20,14 +20,14 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
x.bar4()
|
x.bar4()
|
||||||
|
|
||||||
|
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
x<!UNSAFE_CALL!>.<!>length
|
x<!UNSAFE_CALL!>.<!>length
|
||||||
|
|
||||||
if (x is String) {
|
if (x is String) {
|
||||||
x.length
|
x.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
x.bar1()
|
x.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
@@ -36,7 +36,7 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
|
|
||||||
if (x is CharSequence) {
|
if (x is CharSequence) {
|
||||||
x.length
|
x.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
x.bar1()
|
x.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
|
||||||
|
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
@@ -20,14 +20,14 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar4()
|
<!DEBUG_INFO_SMARTCAST!>x<!>.bar4()
|
||||||
|
|
||||||
|
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
x<!UNSAFE_CALL!>.<!>length
|
x<!UNSAFE_CALL!>.<!>length
|
||||||
|
|
||||||
if (x is String) {
|
if (x is String) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
@@ -36,7 +36,7 @@ fun <T : CharSequence?> foo(x: T) {
|
|||||||
|
|
||||||
if (x is CharSequence) {
|
if (x is CharSequence) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
|
||||||
x.bar2()
|
x.bar2()
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ fun <T : String?> T.foo() {
|
|||||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||||
|
|
||||||
length
|
length
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
bar1()
|
bar1()
|
||||||
bar2()
|
bar2()
|
||||||
@@ -19,14 +19,14 @@ fun <T : String?> T.foo() {
|
|||||||
bar4()
|
bar4()
|
||||||
|
|
||||||
|
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!UNSAFE_CALL!>length<!>
|
<!UNSAFE_CALL!>length<!>
|
||||||
|
|
||||||
if (this is String) {
|
if (this is String) {
|
||||||
length
|
length
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
bar1()
|
bar1()
|
||||||
bar2()
|
bar2()
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ fun <T : String?> T.foo() {
|
|||||||
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
|
||||||
|
|
||||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
||||||
bar2()
|
bar2()
|
||||||
@@ -19,14 +19,14 @@ fun <T : String?> T.foo() {
|
|||||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar4<!>()
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar4<!>()
|
||||||
|
|
||||||
|
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!UNSAFE_CALL!>length<!>
|
<!UNSAFE_CALL!>length<!>
|
||||||
|
|
||||||
if (this is String) {
|
if (this is String) {
|
||||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
|
|
||||||
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
|
||||||
bar2()
|
bar2()
|
||||||
|
|||||||
+3
-3
@@ -57,13 +57,13 @@ fun test() {
|
|||||||
if (get() === null) {}
|
if (get() === null) {}
|
||||||
|
|
||||||
if (x != null) {
|
if (x != null) {
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>hashCode()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>hashCode()<!>
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1)<!>
|
||||||
x.equals("")
|
x.equals("")
|
||||||
x.hashCode()
|
x.hashCode()
|
||||||
x.toString()
|
x.toString()
|
||||||
x.test()
|
x.test()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>test2()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>test2()<!>
|
||||||
x.test2()
|
x.test2()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+8
-8
@@ -25,36 +25,36 @@ fun <R1 : R2, R2> build4(x: R2, @BuilderInference block: TestInterface<R1>.() ->
|
|||||||
fun test(a: String?) {
|
fun test(a: String?) {
|
||||||
val ret1 = build {
|
val ret1 = build {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
val ret2 = build2 {
|
val ret2 = build2 {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
val ret3 = build3 {
|
val ret3 = build3 {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
val ret4 = build4(1) {
|
val ret4 = build4(1) {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
|
|||||||
+6
-6
@@ -34,27 +34,27 @@ fun test(a: String?) {
|
|||||||
}
|
}
|
||||||
val ret2 = build2 {
|
val ret2 = build2 {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
val ret3 = build3 {
|
val ret3 = build3 {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
val ret4 = build4(1) {
|
val ret4 = build4(1) {
|
||||||
emit(1)
|
emit(1)
|
||||||
get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>get()<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
val x = get()
|
val x = get()
|
||||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>x<!UNNECESSARY_SAFE_CALL!>?.<!>equals("")<!>
|
||||||
x <!USELESS_ELVIS!>?: 1<!>
|
x <!USELESS_ELVIS!>?: 1<!>
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
""
|
""
|
||||||
|
|||||||
@@ -54,5 +54,5 @@ fun test2(t: Test?) {
|
|||||||
val xSafeCallSafeCastExplicitType = t?.findViewById<X>(0) <!USELESS_CAST!>as? X<!>
|
val xSafeCallSafeCastExplicitType = t?.findViewById<X>(0) <!USELESS_CAST!>as? X<!>
|
||||||
|
|
||||||
val xSafeCallCast = t?.findViewById(0) as X
|
val xSafeCallCast = t?.findViewById(0) as X
|
||||||
val xSafeCallCastExplicitType = t<!UNNECESSARY_SAFE_CALL!>?.<!>findViewById<X>(0) as X
|
val xSafeCallCastExplicitType = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>t<!UNNECESSARY_SAFE_CALL!>?.<!>findViewById<X>(0)<!> as X
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,5 +54,5 @@ fun test2(t: Test?) {
|
|||||||
val xSafeCallSafeCastExplicitType = t?.findViewById<X>(0) <!USELESS_CAST!>as? X<!>
|
val xSafeCallSafeCastExplicitType = t?.findViewById<X>(0) <!USELESS_CAST!>as? X<!>
|
||||||
|
|
||||||
val xSafeCallCast = t?.findViewById(0) as X
|
val xSafeCallCast = t?.findViewById(0) as X
|
||||||
val xSafeCallCastExplicitType = t<!UNNECESSARY_SAFE_CALL!>?.<!>findViewById<X>(0) as X
|
val xSafeCallCastExplicitType = <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>t<!UNNECESSARY_SAFE_CALL!>?.<!>findViewById<X>(0)<!> as X
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ interface B {
|
|||||||
|
|
||||||
fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) {
|
fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) {
|
||||||
u?.b?.foo()!! // was UNNECESSARY_SAFE_CALL everywhere, because result type (of 'foo()') wasn't made nullable
|
u?.b?.foo()!! // was UNNECESSARY_SAFE_CALL everywhere, because result type (of 'foo()') wasn't made nullable
|
||||||
u<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.b<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>u<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.b<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
x?.b!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x?.b!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
// x?.b is not null
|
// x?.b is not null
|
||||||
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.b<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
x<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.b<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
@@ -23,7 +23,7 @@ fun test(u: A?, x: A?, y: A?, z: A?, w: A, v: A?) {
|
|||||||
// z?.nb is not null
|
// z?.nb is not null
|
||||||
z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.nb!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
z<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.nb!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
|
||||||
w.b<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>w.b<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
w.b<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
w.b<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
w.nb?.foo()!!
|
w.nb?.foo()!!
|
||||||
w.nb!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
w.nb!!.foo()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
|||||||
+1
-1
@@ -18,5 +18,5 @@ fun smartCastAfterIntersection(a: One, b: Two) = run {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test(one: One, two: Two) {
|
fun test(one: One, two: Two) {
|
||||||
smartCastAfterIntersection(one, two)<!UNNECESSARY_SAFE_CALL!>?.<!><!UNRESOLVED_REFERENCE!>base<!>()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>smartCastAfterIntersection(one, two)<!UNNECESSARY_SAFE_CALL!>?.<!><!UNRESOLVED_REFERENCE!>base<!>()<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class Throwables() {
|
|||||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) : Unit {
|
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) : Unit {
|
||||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||||
{
|
{
|
||||||
throw declaredType<!UNNECESSARY_SAFE_CALL!>?.<!>cast(throwable)!!
|
throw <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>declaredType<!UNNECESSARY_SAFE_CALL!>?.<!>cast(throwable)<!>!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public fun propagateIfPossible(throwable : Throwable?) : Unit {
|
public fun propagateIfPossible(throwable : Throwable?) : Unit {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNNECESSARY_NOT_NULL_ASSERTION -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNNECESSARY_NOT_NULL_ASSERTION -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
fun getFun(s: (p: Int) -> Unit): Function1<Int, Int> = {11}
|
fun getFun(s: (p: Int) -> Unit): Function1<Int, Int> = {11}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION -CONFLICTING_JVM_DECLARATIONS
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION -CONFLICTING_JVM_DECLARATIONS -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
inline fun String.submit(action: Function1<Int, Int>) {
|
inline fun String.submit(action: Function1<Int, Int>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -30,6 +30,6 @@ import p.*
|
|||||||
|
|
||||||
fun <Y, Z> test(b: B<Y, Z>?) {
|
fun <Y, Z> test(b: B<Y, Z>?) {
|
||||||
if (b is C<Y, Z>) {
|
if (b is C<Y, Z>) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(null)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(null)<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsNameMismatch.kt
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -31,6 +31,6 @@ fun test(b: B?, c: C) {
|
|||||||
b?.foo(1, 1)
|
b?.foo(1, 1)
|
||||||
c.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)
|
c.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,6 +31,6 @@ fun test(b: B?, c: C) {
|
|||||||
b?.foo(1, 1)
|
b?.foo(1, 1)
|
||||||
c.foo(1, 1)
|
c.foo(1, 1)
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(1, 1)<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -31,6 +31,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
b?.getParent()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b?.getParent()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,6 +31,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>b<!>?.getParent()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!><!DEBUG_INFO_SMARTCAST!>b<!>?.getParent()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m0
|
// MODULE: m0
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -29,6 +29,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!>foo(1, "")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!>foo(1, "")<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,6 +29,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>b<!><!UNNECESSARY_SAFE_CALL!>?.<!>foo(1, "")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!><!DEBUG_INFO_SMARTCAST!>b<!><!UNNECESSARY_SAFE_CALL!>?.<!>foo(1, "")<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
package p
|
package p
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m1
|
// MODULE: m1
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL -SAFE_CALL_WILL_CHANGE_NULLABILITY
|
||||||
|
|
||||||
// MODULE: m0
|
// MODULE: m0
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|||||||
+1
-1
@@ -34,6 +34,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C && b is D) {
|
if (b is C && b is D) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!>getParent()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!>getParent()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -30,6 +30,6 @@ import p.*
|
|||||||
|
|
||||||
fun test(b: B?) {
|
fun test(b: B?) {
|
||||||
if (b is C) {
|
if (b is C) {
|
||||||
b<!UNNECESSARY_SAFE_CALL!>?.<!>foo("")
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>b<!UNNECESSARY_SAFE_CALL!>?.<!>foo("")<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -25,9 +25,9 @@ fun A.test2() {
|
|||||||
this.bar()
|
this.bar()
|
||||||
this.buzz()
|
this.buzz()
|
||||||
|
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>foo() // warning
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!> // warning
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar() // warning
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>bar()<!> // warning
|
||||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>buzz()<!> // warning
|
||||||
}
|
}
|
||||||
|
|
||||||
fun A?.test3() {
|
fun A?.test3() {
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ fun <N : Number?> test(arg: N) {
|
|||||||
|
|
||||||
makeDefinitelyNotNull(arg)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
makeDefinitelyNotNull(arg)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
|
||||||
makeDefinitelyNotNull(arg)<!UNNECESSARY_SAFE_CALL!>?.<!>toInt()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>makeDefinitelyNotNull(arg)<!UNNECESSARY_SAFE_CALL!>?.<!>toInt()<!>
|
||||||
|
|
||||||
val nullImposible = when (val dnn = makeDefinitelyNotNull(arg)) {
|
val nullImposible = when (val dnn = makeDefinitelyNotNull(arg)) {
|
||||||
<!SENSELESS_NULL_IN_WHEN!>null<!> -> false
|
<!SENSELESS_NULL_IN_WHEN!>null<!> -> false
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,13 +1,13 @@
|
|||||||
fun <T> test(t: T): String? {
|
fun <T> test(t: T): String? {
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
return t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
return <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()<!>
|
||||||
}
|
}
|
||||||
return t?.toString()
|
return t?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> T.testThis(): String? {
|
fun <T> T.testThis(): String? {
|
||||||
if (this != null) {
|
if (this != null) {
|
||||||
return this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
return <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()<!>
|
||||||
}
|
}
|
||||||
return this?.toString()
|
return this?.toString()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,13 +1,13 @@
|
|||||||
fun <T> test(t: T): String? {
|
fun <T> test(t: T): String? {
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
return t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
return <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>t<!UNNECESSARY_SAFE_CALL!>?.<!>toString()<!>
|
||||||
}
|
}
|
||||||
return <!DEBUG_INFO_CONSTANT!>t<!>?.toString()
|
return <!DEBUG_INFO_CONSTANT!>t<!>?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> T.testThis(): String? {
|
fun <T> T.testThis(): String? {
|
||||||
if (this != null) {
|
if (this != null) {
|
||||||
return this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()
|
return <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>this<!UNNECESSARY_SAFE_CALL!>?.<!>toString()<!>
|
||||||
}
|
}
|
||||||
return this?.toString()
|
return this?.toString()
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-27
@@ -52,40 +52,40 @@ fun foo(a: A?) {
|
|||||||
a?.w.inc()
|
a?.w.inc()
|
||||||
|
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l += 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!> += 1
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0]
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0]
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0]++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0]++
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0] = 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0] = 1
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0]
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0]
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0]++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0]++
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0] = 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0] = 1
|
||||||
// No warning is reported because
|
// No warning is reported because
|
||||||
// 1. All kinds of green code with safe+call + invoke we identified fails with CCE if `a != null`, anyway
|
// 1. All kinds of green code with safe+call + invoke we identified fails with CCE if `a != null`, anyway
|
||||||
// 2. In case of null value, the behavior is intended (no call performed)
|
// 2. In case of null value, the behavior is intended (no call performed)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>q()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q()<!>
|
||||||
a<!UNNECESSARY_SAFE_CALL, UNNECESSARY_SAFE_CALL!>?.<!>w++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY, SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL, UNNECESSARY_SAFE_CALL!>?.<!>w<!>++
|
||||||
|
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l) += 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>) += 1
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0]
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0]
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0]++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0]++
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0] = 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0] = 1
|
||||||
|
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0]
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0]
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0]++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0]++
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0] = 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0] = 1
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>q)()
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q<!>)()
|
||||||
(a<!UNNECESSARY_SAFE_CALL, UNNECESSARY_SAFE_CALL!>?.<!>w)++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY, SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL, UNNECESSARY_SAFE_CALL!>?.<!>w<!>)++
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.plusAssign(1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.plusAssign(1)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.get(0)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.get(0).inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.get(0).inc()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.set(0, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.set(0, 1)
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).get(0)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).get(0).inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).get(0).inc()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).set(0, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).set(0, 1)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>q.invoke()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q<!>.invoke()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>w.inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>w<!>.inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,40 +52,40 @@ fun foo(a: A?) {
|
|||||||
a?.w.inc()
|
a?.w.inc()
|
||||||
|
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l += 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!> += 1
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0]
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0]
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0]++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0]++
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l[0] = 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>[0] = 1
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0]
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0]
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0]++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0]++
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll[0][0] = 1
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>[0][0] = 1
|
||||||
// No warning is reported because
|
// No warning is reported because
|
||||||
// 1. All kinds of green code with safe+call + invoke we identified fails with CCE if `a != null`, anyway
|
// 1. All kinds of green code with safe+call + invoke we identified fails with CCE if `a != null`, anyway
|
||||||
// 2. In case of null value, the behavior is intended (no call performed)
|
// 2. In case of null value, the behavior is intended (no call performed)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>q()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q()<!>
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>w++
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>w<!>++
|
||||||
|
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l) += 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>) += 1
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0]
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0]
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0]++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0]++
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>l)[0] = 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>)[0] = 1
|
||||||
|
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0]
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0]
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0]++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0]++
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>ll)[0][0] = 1
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>)[0][0] = 1
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>q)()
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q<!>)()
|
||||||
(a<!UNNECESSARY_SAFE_CALL!>?.<!>w)++
|
(<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>w<!>)++
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.plusAssign(1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.plusAssign(1)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.get(0)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.get(0).inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.get(0).inc()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>l.set(0, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>l<!>.set(0, 1)
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).get(0)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).get(0).inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).get(0).inc()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>ll.get(0).set(0, 1)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>ll<!>.get(0).set(0, 1)
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>q.invoke()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>q<!>.invoke()
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>w.inc()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>w<!>.inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -19,6 +19,6 @@ public class A<T> {
|
|||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
A.create().bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>A.create().bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
A<String?>().bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>A<String?>().bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -15,6 +15,6 @@ public class A<T> {
|
|||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
fun test(a: A<out CharSequence>) {
|
fun test(a: A<out CharSequence>) {
|
||||||
a.bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
a.bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a.bar()<!UNNECESSARY_SAFE_CALL!>?.<!>length<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ public class J {
|
|||||||
fun list(j: J): Any {
|
fun list(j: J): Any {
|
||||||
val a = j.n()!!
|
val a = j.n()!!
|
||||||
|
|
||||||
a<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>a<!UNNECESSARY_SAFE_CALL!>?.<!>get(0)<!>
|
||||||
if (<!SENSELESS_COMPARISON!>a == null<!>) {}
|
if (<!SENSELESS_COMPARISON!>a == null<!>) {}
|
||||||
a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -25,20 +25,20 @@ fun test() {
|
|||||||
// platform type with no annotation
|
// platform type with no annotation
|
||||||
val platformJ = J.staticJ
|
val platformJ = J.staticJ
|
||||||
|
|
||||||
platformNN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>platformNN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
|
||||||
platformN?.foo()
|
platformN?.foo()
|
||||||
platformJ?.foo()
|
platformJ?.foo()
|
||||||
|
|
||||||
if (platformNN != null) {
|
if (platformNN != null) {
|
||||||
platformNN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>platformNN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platformN != null) {
|
if (platformN != null) {
|
||||||
platformN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>platformN<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platformJ != null) {
|
if (platformJ != null) {
|
||||||
platformJ<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>platformJ<!UNNECESSARY_SAFE_CALL!>?.<!>foo()<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun test(room : Object) {
|
|||||||
for(item: Item? in items) {
|
for(item: Item? in items) {
|
||||||
if (item?.room === room) {
|
if (item?.room === room) {
|
||||||
// item?.room is not null
|
// item?.room is not null
|
||||||
System.out.println("You see " + item<!UNNECESSARY_SAFE_CALL!>?.<!>name)
|
System.out.println("You see " + <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>item<!UNNECESSARY_SAFE_CALL!>?.<!>name<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun test(room : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Object<!>) {
|
|||||||
for(item: Item? in items) {
|
for(item: Item? in items) {
|
||||||
if (item?.room === room) {
|
if (item?.room === room) {
|
||||||
// item?.room is not null
|
// item?.room is not null
|
||||||
System.out.println("You see " + item<!UNNECESSARY_SAFE_CALL!>?.<!>name)
|
System.out.println("You see " + <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>item<!UNNECESSARY_SAFE_CALL!>?.<!>name<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -4,6 +4,6 @@ fun main() {
|
|||||||
|
|
||||||
val command : Any = 1
|
val command : Any = 1
|
||||||
|
|
||||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)<!>
|
||||||
command.equals(null)
|
command.equals(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ fun main() {
|
|||||||
|
|
||||||
val command : Any = 1
|
val command : Any = 1
|
||||||
|
|
||||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
|
<!SAFE_CALL_WILL_CHANGE_NULLABILITY!>command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)<!>
|
||||||
command.equals(null)
|
command.equals(null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class Throwables() {
|
|||||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) {
|
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) {
|
||||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||||
{
|
{
|
||||||
throw declaredType<!UNNECESSARY_SAFE_CALL!>?.<!>cast(throwable)!!
|
throw <!SAFE_CALL_WILL_CHANGE_NULLABILITY!>declaredType<!UNNECESSARY_SAFE_CALL!>?.<!>cast(throwable)<!>!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public fun propagateIfPossible(throwable : Throwable?) {
|
public fun propagateIfPossible(throwable : Throwable?) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user