From 37346c2ce6eeda6f739bb95bee0c8fe43879de56 Mon Sep 17 00:00:00 2001 From: Anton Golov Date: Fri, 10 Nov 2023 10:14:52 +0100 Subject: [PATCH] Fix contract in AngularJS plugin. The contract for `processTupleArgument` is meant to say that the function will not return a non-null value if `nullIfNotFound = false`. However, the old contract said the opposite: that if the function returned a non-null value, then `nullIfNotFound = false`, which is not true (if the value is found, `nullIfNotFound` plays no role). At the moment, the compiler cannot use either contract meaningfully so the difference is immaterial. If https://youtrack.jetbrains.com/issue/KT-63378/Support-or-prohibit-contracts-that-use-Boolean-parameters-on-the-right-of-an-implies is resolved and support for this is added, the new contract will allow the call-sites that pass `nullIfNotFound = false` to perform a smart cast to `List` instead of having to use `!!`. --- AngularJS/src/org/angular2/entities/ivy/Angular2IvySymbolDef.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AngularJS/src/org/angular2/entities/ivy/Angular2IvySymbolDef.kt b/AngularJS/src/org/angular2/entities/ivy/Angular2IvySymbolDef.kt index 98ee1f516bd..7c2195f1985 100644 --- a/AngularJS/src/org/angular2/entities/ivy/Angular2IvySymbolDef.kt +++ b/AngularJS/src/org/angular2/entities/ivy/Angular2IvySymbolDef.kt @@ -281,7 +281,7 @@ abstract class Angular2IvySymbolDef private constructor(private val myFieldOrStu itemMapper: (T) -> R?, nullIfNotFound: Boolean): List? { contract { - returnsNotNull() implies (!nullIfNotFound) + returns(null) implies (nullIfNotFound) } val declaration = getDefFieldArgument(index) ?: return if (nullIfNotFound) null else emptyList()