From e3f2a22b6e676916ff4e0edf3ccfe6bb3bcf52fa Mon Sep 17 00:00:00 2001 From: Komi Golov Date: Fri, 12 Jul 2024 17:51:53 +0200 Subject: [PATCH] Shorten mangled names and make type/scope/name distinction explicit Our current mangled names are inconveniently long. I'm working on making them shorter, but it's quite a bit of work; this should make things a bit easier to read without reworking too much. --- .../formver/conversion/ProgramConverter.kt | 1 + .../formver/domains/RuntimeTypeDomain.kt | 3 +- .../embeddings/ClassPredicateBuilder.kt | 4 +- .../formver/embeddings/TypeEmbedding.kt | 46 +- .../embeddings/expression/ExpEmbedding.kt | 1 + .../expression/VariableEmbedding.kt | 1 + .../embeddings/expression/debug/Utils.kt | 1 + .../kotlin/formver/names/FreshNames.kt | 45 +- .../kotlin/formver/names/KotlinName.kt | 42 +- .../kotlin/formver/names/NameEmbeddings.kt | 1 + .../kotlin/formver/names/NameMangling.md | 41 + .../kotlin/formver/names/NameScope.kt | 18 +- .../kotlin/formver/names/ScopedKotlinName.kt | 11 +- .../formver/ViperPoweredDeclarationChecker.kt | 1 + .../kotlin/formver/viper/MangledName.kt | 11 +- .../kotlin/formver/viper/ast/Declaration.kt | 5 +- .../kotlin/formver/viper/ast/Domain.kt | 19 +- .../kotlin/formver/viper/ast/Field.kt | 1 + .../kotlin/formver/viper/ast/Predicate.kt | 5 +- .../kotlin/formver/viper/ast/Program.kt | 5 +- .../kotlin/formver/viper/ast/Stmt.kt | 5 +- .../jetbrains/kotlin/formver/viper/ast/Var.kt | 2 +- .../as_type_contract.fir.diag.txt | 43 +- .../bad_contracts/binary_search.fir.diag.txt | 630 ++++++------ .../bad_contracts/cond_effects.fir.diag.txt | 118 ++- .../bad_contracts/do_not_verify.fir.diag.txt | 13 +- .../is_type_contract.fir.diag.txt | 35 +- .../bad_contracts/list.fir.diag.txt | 410 ++++---- .../returns_booleans.fir.diag.txt | 26 +- .../returns_not_null.fir.diag.txt | 13 +- .../bad_contracts/returns_null.fir.diag.txt | 28 +- .../bad_contracts/viper_verify.fir.diag.txt | 28 +- .../as_type_contract.fir.diag.txt | 97 +- .../backing_field_getters.fir.diag.txt | 425 ++++---- .../good_contracts/binary_search.fir.diag.txt | 296 +++--- .../good_contracts/custom_list.fir.diag.txt | 143 ++- .../custom_run_functions.fir.diag.txt | 938 +++++++++--------- .../inline_correctness.fir.diag.txt | 266 +++-- .../is_type_contract.fir.diag.txt | 135 ++- .../good_contracts/list.fir.diag.txt | 406 ++++---- .../multiple_interfaces.fir.diag.txt | 335 +++---- .../good_contracts/nullability.fir.diag.txt | 11 +- .../override_properties_types.fir.diag.txt | 108 +- .../private_properties.fir.diag.txt | 139 ++- .../returns_booleans.fir.diag.txt | 195 ++-- .../good_contracts/returns_null.fir.diag.txt | 110 +- .../good_contracts/simple.fir.diag.txt | 18 +- .../no_contracts/basic.fir.diag.txt | 85 +- .../classes/field_getters.fir.diag.txt | 196 ++-- .../classes/inheritance.fir.diag.txt | 229 +++-- .../classes/inheritance_fields.fir.diag.txt | 173 ++-- .../classes/interface.fir.diag.txt | 84 +- .../classes/member_functions.fir.diag.txt | 99 +- .../classes/multiple_interfaces.fir.diag.txt | 98 +- .../classes/predicates.fir.diag.txt | 226 ++--- .../classes/predicates_access.fir.diag.txt | 445 ++++----- .../classes/primary_constructors.fir.diag.txt | 94 +- .../classes/property_getters.fir.diag.txt | 105 +- .../secondary_constructors.fir.diag.txt | 79 +- .../no_contracts/classes/setters.fir.diag.txt | 124 ++- .../classes/subtyping.fir.diag.txt | 64 +- .../classes/unique_predicates.fir.diag.txt | 212 ++-- .../exp_side_effects.fir.diag.txt | 57 +- .../control_flow/function_call.fir.diag.txt | 48 +- .../no_contracts/control_flow/if.fir.diag.txt | 69 +- .../control_flow/loop.fir.diag.txt | 63 +- .../control_flow/loop_invariants.fir.diag.txt | 134 ++- .../non-local-returns.fir.diag.txt | 195 ++-- .../control_flow/recursion.fir.diag.txt | 12 +- .../return_break_continue.fir.diag.txt | 333 +++---- .../control_flow/try_catch.fir.diag.txt | 386 ++++--- .../control_flow/when.fir.diag.txt | 319 +++--- .../extension_properties.fir.diag.txt | 116 +-- .../no_contracts/full_viper_dump.fir.diag.txt | 366 ++++--- .../no_contracts/function_object.fir.diag.txt | 74 +- .../function_overloading.fir.diag.txt | 216 ++-- .../inlining/captured.fir.diag.txt | 340 ++++--- .../no_contracts/inlining/inline.fir.diag.txt | 100 +- .../inlining/lambdas.fir.diag.txt | 244 +++-- .../operators/arithmetic.fir.diag.txt | 62 +- .../operators/as_operator.fir.diag.txt | 103 +- .../operators/boolean_logic.fir.diag.txt | 85 +- .../operators/comparison.fir.diag.txt | 64 +- .../no_contracts/operators/elvis.fir.diag.txt | 75 +- .../operators/is_operator.fir.diag.txt | 47 +- .../operators/safe_call.fir.diag.txt | 174 ++-- .../no_contracts/shadowing.fir.diag.txt | 111 +-- .../no_contracts/types/any.fir.diag.txt | 26 +- .../no_contracts/types/generics.fir.diag.txt | 181 ++-- .../no_contracts/types/nullable.fir.diag.txt | 91 +- .../no_contracts/types/smartcast.fir.diag.txt | 61 +- 91 files changed, 5611 insertions(+), 6089 deletions(-) create mode 100644 plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameMangling.md diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/conversion/ProgramConverter.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/conversion/ProgramConverter.kt index 4d7af58d59f33b..fbab6f15028089 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/conversion/ProgramConverter.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/conversion/ProgramConverter.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.formver.linearization.SharedLinearizationState import org.jetbrains.kotlin.formver.names.* import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.Program +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.ifTrue diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/domains/RuntimeTypeDomain.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/domains/RuntimeTypeDomain.kt index d2bb08a89cd6c8..944922d1f5f18d 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/domains/RuntimeTypeDomain.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/domains/RuntimeTypeDomain.kt @@ -8,9 +8,10 @@ package org.jetbrains.kotlin.formver.domains import org.jetbrains.kotlin.formver.embeddings.ClassTypeEmbedding import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.* +import org.jetbrains.kotlin.formver.viper.mangled -const val RUNTIME_TYPE_DOMAIN_NAME = "RuntimeType" +const val RUNTIME_TYPE_DOMAIN_NAME = "RT" /** diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/ClassPredicateBuilder.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/ClassPredicateBuilder.kt index 8554ef4b595d15..7a0548b1fbf264 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/ClassPredicateBuilder.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/ClassPredicateBuilder.kt @@ -8,14 +8,14 @@ package org.jetbrains.kotlin.formver.embeddings import org.jetbrains.kotlin.formver.conversion.AccessPolicy import org.jetbrains.kotlin.formver.embeddings.expression.* import org.jetbrains.kotlin.formver.linearization.pureToViper -import org.jetbrains.kotlin.formver.names.ClassPredicateSubjectName +import org.jetbrains.kotlin.formver.names.ThisReceiverName import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.PermExp import org.jetbrains.kotlin.formver.viper.ast.Predicate import org.jetbrains.kotlin.utils.addIfNotNull internal class ClassPredicateBuilder private constructor(private val type: ClassTypeEmbedding) { - private val subject = PlaceholderVariableEmbedding(ClassPredicateSubjectName, type) + private val subject = PlaceholderVariableEmbedding(ThisReceiverName, type) private val body = mutableListOf() companion object { diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/TypeEmbedding.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/TypeEmbedding.kt index aba29144c08cda..4dcdc71fa3756d 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/TypeEmbedding.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/TypeEmbedding.kt @@ -8,14 +8,13 @@ package org.jetbrains.kotlin.formver.embeddings import org.jetbrains.kotlin.formver.domains.Injection import org.jetbrains.kotlin.formver.domains.RuntimeTypeDomain import org.jetbrains.kotlin.formver.embeddings.callables.CallableSignatureData -import org.jetbrains.kotlin.formver.names.ClassScope +import org.jetbrains.kotlin.formver.names.* import org.jetbrains.kotlin.formver.names.NameMatcher -import org.jetbrains.kotlin.formver.names.ScopedKotlinName -import org.jetbrains.kotlin.formver.names.SimpleKotlinName import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.Exp import org.jetbrains.kotlin.formver.viper.ast.PermExp import org.jetbrains.kotlin.formver.viper.ast.Predicate +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.utils.addToStdlib.ifTrue /** @@ -106,49 +105,42 @@ fun TypeEmbedding.mapNotNullUniqueFields(action: (SimpleKotlinName, FieldEmb data object UnitTypeEmbedding : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.unitType() - override val name = object : MangledName { - override val mangled: String = "T_Unit" - } + override val name = TypeName("Unit") } data object NothingTypeEmbedding : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.nothingType() - override val name = object : MangledName { - override val mangled: String = "T_Nothing" - } + override val name = TypeName("Nothing") override fun pureInvariants(): List = listOf(FalseTypeInvariant) } data object AnyTypeEmbedding : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.anyType() - override val name = object : MangledName { - override val mangled: String = "T_Any" - } + override val name = TypeName("Any") } data object NullableAnyTypeEmbedding : TypeEmbedding by NullableTypeEmbedding(AnyTypeEmbedding) data object IntTypeEmbedding : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.intType() - override val name = object : MangledName { - override val mangled: String = "T_Int" - } + override val name = TypeName("Int") } data object BooleanTypeEmbedding : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.boolType() - override val name = object : MangledName { - override val mangled: String = "T_Boolean" - } + override val name = TypeName("Boolean") } data class NullableTypeEmbedding(val elementType: TypeEmbedding) : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.nullable(elementType.runtimeType) override val name = object : MangledName { - override val mangled: String = "N" + elementType.name.mangled + override val mangledScope: String? + get() = elementType.name.mangledScope?.let { "N$it" } + override val mangledBaseName: String + get() = elementType.name.mangledBaseName } override fun accessInvariants(): List = elementType.accessInvariants().map { IfNonNullInvariant(it) } @@ -170,8 +162,11 @@ data class NullableTypeEmbedding(val elementType: TypeEmbedding) : TypeEmbedding data class FunctionTypeEmbedding(val signature: CallableSignatureData) : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.functionType() override val name = object : MangledName { - override val mangled: String = - "fun_take\$${signature.formalArgTypes.joinToString("$") { it.name.mangled }}\$return\$${signature.returnType.name.mangled}" + // TODO: this can cause some number of collisions; fix it if it becomes an issue. + override val mangledBaseName: String = + signature.formalArgTypes.joinToString("$") { it.name.mangled } + override val mangledType: String + get() = "TF" } } @@ -237,12 +232,13 @@ data class ClassTypeEmbedding(val className: ScopedKotlinName, val isInterface: } // TODO: incorporate generic parameters. - override val name = object : MangledName { - override val mangled: String = "T_class_${className.mangled}" - } + override val name = TypeName("class_${className.mangled}") private val uniquePredicateName = object : MangledName { - override val mangled: String = "Unique\$T_class_${className.mangled}" + override val mangledType: String + get() = "U" + override val mangledBaseName: String + get() = name.mangled } val runtimeTypeFunc = RuntimeTypeDomain.classTypeFunc(name) diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ExpEmbedding.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ExpEmbedding.kt index 83e42c10bda804..a18627dfb2511b 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ExpEmbedding.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ExpEmbedding.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.Exp import org.jetbrains.kotlin.formver.viper.ast.PermExp import org.jetbrains.kotlin.formver.viper.ast.Stmt +import org.jetbrains.kotlin.formver.viper.mangled sealed interface ExpEmbedding { val type: TypeEmbedding diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/VariableEmbedding.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/VariableEmbedding.kt index cca8810a8ad30a..673881217ca551 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/VariableEmbedding.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/VariableEmbedding.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.formver.embeddings.expression.debug.TreeView import org.jetbrains.kotlin.formver.names.AnonymousName import org.jetbrains.kotlin.formver.viper.MangledName import org.jetbrains.kotlin.formver.viper.ast.* +import org.jetbrains.kotlin.formver.viper.mangled sealed interface VariableEmbedding : PureExpEmbedding, PropertyAccessEmbedding { val name: MangledName diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/debug/Utils.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/debug/Utils.kt index 0c1b9d0de8c772..d474220e608859 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/debug/Utils.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/debug/Utils.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.formver.embeddings.TypeEmbedding import org.jetbrains.kotlin.formver.embeddings.callables.NamedFunctionSignature import org.jetbrains.kotlin.formver.viper.ast.Label import org.jetbrains.kotlin.formver.viper.ast.PermExp +import org.jetbrains.kotlin.formver.viper.mangled val Label.debugTreeView: TreeView get() = PlaintextLeaf(name.mangled) diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/FreshNames.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/FreshNames.kt index aa53c8e027b33d..c64a803e06aa02 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/FreshNames.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/FreshNames.kt @@ -17,47 +17,46 @@ import org.jetbrains.kotlin.formver.viper.MangledName * e.g. storage for the result of subexpressions. */ data class AnonymousName(val n: Int) : MangledName { - override val mangled: String - get() = "anonymous\$$n" + override val mangledType: String + get() = "a" + override val mangledBaseName: String + get() = n.toString() } /** * Name for return variable that should *only* be used in signatures of methods without a body. */ data object PlaceholderReturnVariableName : MangledName { - override val mangled: String + override val mangledBaseName: String get() = "ret" } data class ReturnVariableName(val n: Int) : MangledName { - override val mangled: String - get() = "ret\$$n" + override val mangledType: String + get() = "r" + override val mangledBaseName: String + get() = n.toString() } data object ThisReceiverName : MangledName { - override val mangled: String + override val mangledBaseName: String get() = "this" } data object SetterValueName : MangledName { - override val mangled = "value" + override val mangledBaseName: String + get() = "value" } -abstract class SpecialNameBase(name: String) : MangledName { - override val mangled: String = "special\$$name" +data class SpecialName(override val mangledBaseName: String) : MangledName { + override val mangledType: String + get() = "sp" } -data class SpecialName(val name: String) : SpecialNameBase(name) -data object GetterFunctionSubjectName : SpecialNameBase("get\$function\$subject") -data object ClassPredicateSubjectName : SpecialNameBase("class\$predicate\$subject") - -data class GetterFunctionName(val className: MangledName, val fieldName: MangledName) : MangledName { - override val mangled: String - get() = "${className.mangled}\$get\$${fieldName.mangled}" -} - -abstract class NumberedLabelName(kind: String, n: Int) : MangledName { - override val mangled = "label\$$kind\$$n" +abstract class NumberedLabelName(override val mangledScope: String, n: Int) : MangledName { + override val mangledType: String + get() = "lbl" + override val mangledBaseName: String = n.toString() } data class ReturnLabelName(val scopeDepth: Int) : NumberedLabelName("ret", scopeDepth) @@ -65,3 +64,9 @@ data class BreakLabelName(val n: Int) : NumberedLabelName("break", n) data class ContinueLabelName(val n: Int) : NumberedLabelName("continue", n) data class CatchLabelName(val n: Int) : NumberedLabelName("catch", n) data class TryExitLabelName(val n: Int) : NumberedLabelName("try_exit", n) + +data class TypeName(override val mangledBaseName: String) : MangledName { + override val mangledType: String + get() = "T" +} + diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/KotlinName.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/KotlinName.kt index b2624da07ad45a..230e4da12a9ddc 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/KotlinName.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/KotlinName.kt @@ -5,8 +5,10 @@ package org.jetbrains.kotlin.formver.names +import org.jetbrains.kotlin.formver.embeddings.ClassTypeEmbedding import org.jetbrains.kotlin.formver.embeddings.TypeEmbedding import org.jetbrains.kotlin.formver.viper.MangledName +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -19,44 +21,46 @@ import org.jetbrains.kotlin.name.Name sealed interface KotlinName : MangledName data class SimpleKotlinName(val name: Name) : KotlinName { - override val mangled: String = name.asStringStripSpecialMarkers() + override val mangledBaseName: String = name.asStringStripSpecialMarkers() } -abstract class PrefixedKotlinName(prefix: String, name: Name) : KotlinName { - override val mangled: String = "${prefix}_${name.asStringStripSpecialMarkers()}" +abstract class TypedKotlinName(override val mangledType: String, name: Name) : KotlinName { + override val mangledBaseName: String = name.asStringStripSpecialMarkers() } -abstract class PrefixedKotlinNameWithType(prefix: String, name: Name, type: TypeEmbedding) : KotlinName { - override val mangled: String = "${prefix}_${name.asStringStripSpecialMarkers()}\$${type.name.mangled}" +abstract class TypedKotlinNameWithType(override val mangledType: String, name: Name, type: TypeEmbedding) : KotlinName { + override val mangledBaseName: String = "${name.asStringStripSpecialMarkers()}\$${type.name.mangled}" } -data class FunctionKotlinName(val name: Name, val type: TypeEmbedding) : PrefixedKotlinNameWithType("fun", name, type) +data class FunctionKotlinName(val name: Name, val type: TypeEmbedding) : TypedKotlinNameWithType("f", name, type) /** * This name will never occur in the viper output, but rather is used to lookup properties. */ -data class PropertyKotlinName(val name: Name) : PrefixedKotlinName("property_property", name) -data class BackingFieldKotlinName(val name: Name) : PrefixedKotlinName("backing_field", name) -data class GetterKotlinName(val name: Name) : PrefixedKotlinName("property_getter", name) -data class SetterKotlinName(val name: Name) : PrefixedKotlinName("property_setter", name) -data class ExtensionSetterKotlinName(val name: Name, val type: TypeEmbedding) : PrefixedKotlinNameWithType( - "ext_setter", +data class PropertyKotlinName(val name: Name) : TypedKotlinName("pp", name) +data class BackingFieldKotlinName(val name: Name) : TypedKotlinName("bf", name) +data class GetterKotlinName(val name: Name) : TypedKotlinName("pg", name) +data class SetterKotlinName(val name: Name) : TypedKotlinName("ps", name) +data class ExtensionSetterKotlinName(val name: Name, val type: TypeEmbedding) : TypedKotlinNameWithType( + "es", name, type ) -data class ExtensionGetterKotlinName(val name: Name, val type: TypeEmbedding) : PrefixedKotlinNameWithType - ( - "ext_getter", - name, type -) +data class ExtensionGetterKotlinName(val name: Name, val type: TypeEmbedding) : TypedKotlinNameWithType + ("es", name, type) data class ClassKotlinName(val name: FqName) : KotlinName { - override val mangled: String = "class_${name.asViperString()}" + override val mangledType: String + get() = "c" + override val mangledBaseName: String = name.asViperString() constructor(classSegments: List) : this(FqName.fromSegments(classSegments)) } data class ConstructorKotlinName(val type: TypeEmbedding) : KotlinName { - override val mangled: String = "constructor\$${type.name.mangled}" + override val mangledType: String + get() = "con" + override val mangledBaseName: String + get() = type.name.mangledBaseName } diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameEmbeddings.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameEmbeddings.kt index cd85f161d9b9d2..751b0eda5aaec1 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameEmbeddings.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameEmbeddings.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.declarations.utils.visibility import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.formver.conversion.ProgramConversionContext +import org.jetbrains.kotlin.formver.embeddings.ClassTypeEmbedding import org.jetbrains.kotlin.formver.embeddings.TypeEmbedding import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameMangling.md b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameMangling.md new file mode 100644 index 00000000000000..09431a59bcb4e0 --- /dev/null +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameMangling.md @@ -0,0 +1,41 @@ +# Name mangling + +There are two hard problems in computer science: +cache invalidation, naming, and off-by-one errors. + +When translating Kotlin to Viper, we need to pick distinct names for objects. +Viper is significantly less forgiving than Kotlin when it comes to shadowing, +so we aim to pick unique names globally. + +We do this by scoping and typing the names: +* Names are given a scope corresponding (roughly) to their scope in the original + Kotlin program. +* Names are given a type based on the kind of thing they refer to. + +Since this typically makes names long, we use abbreviations, or omit the type +and/or scope for the most common cases. + +For scopes: +* `pkg` for package +* `g` for global +* `p` for parameter +* `ln` for local, where `n` is the number of the scope. + +For types: +* `c` for class +* `f` for function +* `d` for domain +* `l` for label +* `a` for anonymous value +* `con` for constructor +* `pp` for property (internal use only) +* `bf` for backing field +* `pg` for property getter +* `ps` for property setter +* `eg` for extension getter +* `es` for extension setter + +There are still holdover (longer) names. + +Ideally, we would like this system to be modular and configurable, dropping +prefixes when they are unused, etc. However, that is WIP. \ No newline at end of file diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameScope.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameScope.kt index a0e7a1c05bd877..addd30b2906f9c 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameScope.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/NameScope.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.formver.names import org.jetbrains.kotlin.formver.viper.MangledName +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.name.FqName sealed interface NameScope : MangledName @@ -13,16 +14,16 @@ sealed interface NameScope : MangledName sealed interface PackagePrefixScope : NameScope { val packageName: FqName val suffix: String - override val mangled: String + override val mangledBaseName: String get() = if (packageName.isRoot) { suffix } else { - "pkg\$${packageName.asViperString()}\$$suffix" + "pkg_${packageName.asViperString()}\$$suffix" } } data class GlobalScope(override val packageName: FqName) : PackagePrefixScope { - override val suffix = "global" + override val suffix = "g" constructor(segments: List) : this(FqName.fromSegments(segments)) } @@ -31,7 +32,7 @@ sealed interface ClassScope : PackagePrefixScope { val className: ClassKotlinName } -data class DefaultClassScope(override val packageName: FqName, override val className: ClassKotlinName, ) : ClassScope { +data class DefaultClassScope(override val packageName: FqName, override val className: ClassKotlinName) : ClassScope { override val suffix = className.mangled } @@ -41,7 +42,8 @@ data class DefaultClassScope(override val packageName: FqName, override val clas */ data class PublicClassScope(override val packageName: FqName, override val className: ClassKotlinName) : ClassScope { override val suffix = className.mangled + "_public" - override val mangled = "public" + override val mangledBaseName: String + get() = "public" } data class PrivateClassScope(override val packageName: FqName, override val className: ClassKotlinName) : ClassScope { @@ -49,9 +51,11 @@ data class PrivateClassScope(override val packageName: FqName, override val clas } data object ParameterScope : NameScope { - override val mangled = "local" + override val mangledBaseName: String + get() = "p" } data class LocalScope(val level: Int) : NameScope { - override val mangled = "local$level" + override val mangledBaseName: String + get() = "l$level" } diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/ScopedKotlinName.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/ScopedKotlinName.kt index e6c06c0e143dde..0d2be50d85a92f 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/ScopedKotlinName.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/names/ScopedKotlinName.kt @@ -6,14 +6,19 @@ package org.jetbrains.kotlin.formver.names import org.jetbrains.kotlin.formver.viper.MangledName +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.name.FqName /** * Name of a Kotlin entity in the original program in a specified scope and optionally distinguished by type. */ data class ScopedKotlinName(val scope: NameScope, val name: KotlinName) : MangledName { - override val mangled: String - get() = listOf(scope.mangled, name.mangled).joinToString("$") + override val mangledScope: String + get() = scope.mangled + override val mangledBaseName: String + get() = name.mangledBaseName + override val mangledType: String? + get() = name.mangledType } -fun FqName.asViperString() = asString().replace('.', '$') \ No newline at end of file +fun FqName.asViperString() = asString().replace('.', '_') \ No newline at end of file diff --git a/plugins/formal-verification/formver.plugin/src/org/jetbrains/kotlin/formver/ViperPoweredDeclarationChecker.kt b/plugins/formal-verification/formver.plugin/src/org/jetbrains/kotlin/formver/ViperPoweredDeclarationChecker.kt index 8eb9ceca59b61b..712f958518b27c 100644 --- a/plugins/formal-verification/formver.plugin/src/org/jetbrains/kotlin/formver/ViperPoweredDeclarationChecker.kt +++ b/plugins/formal-verification/formver.plugin/src/org/jetbrains/kotlin/formver/ViperPoweredDeclarationChecker.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.formver.conversion.ProgramConverter import org.jetbrains.kotlin.formver.embeddings.expression.debug.print import org.jetbrains.kotlin.formver.reporting.reportVerifierError import org.jetbrains.kotlin.formver.viper.Verifier +import org.jetbrains.kotlin.formver.viper.mangled import org.jetbrains.kotlin.formver.viper.ast.Program import org.jetbrains.kotlin.formver.viper.ast.unwrapOr import org.jetbrains.kotlin.formver.viper.errors.VerifierError diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/MangledName.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/MangledName.kt index e2310cd556b84b..77a0a026c32636 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/MangledName.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/MangledName.kt @@ -12,5 +12,12 @@ package org.jetbrains.kotlin.formver.viper * approach makes it easier to see where they came from during debugging. */ interface MangledName { - val mangled: String -} \ No newline at end of file + val mangledType: String? + get() = null + val mangledScope: String? + get() = null + val mangledBaseName: String +} + +val MangledName.mangled: String + get() = listOfNotNull(mangledType, mangledScope, mangledBaseName).joinToString("$") diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Declaration.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Declaration.kt index 56fde41d1eb6dd..7dcb67ca0484de 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Declaration.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Declaration.kt @@ -5,10 +5,7 @@ package org.jetbrains.kotlin.formver.viper.ast -import org.jetbrains.kotlin.formver.viper.IntoSilver -import org.jetbrains.kotlin.formver.viper.MangledName -import org.jetbrains.kotlin.formver.viper.toScalaSeq -import org.jetbrains.kotlin.formver.viper.toSilver +import org.jetbrains.kotlin.formver.viper.* sealed interface Declaration : IntoSilver { data class LocalVarDecl( diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Domain.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Domain.kt index d3bfd5931bda48..6203576f634689 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Domain.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Domain.kt @@ -13,13 +13,16 @@ import viper.silver.ast.NamedDomainAxiom * We also convert domain names and their function and axiom names as * they have to be globally unique as well. */ -data class DomainName(val name: String) : MangledName { - // Info: Can't use 'domain' as prefix as Viper recognizes it as a keyword - override val mangled: String = "dom\$$name" +data class DomainName(override val mangledBaseName: String) : MangledName { + override val mangledType: String + get() = "D" } -data class DomainFuncName(val domainName: DomainName, val funcName: String) : MangledName { - override val mangled: String = "${domainName.mangled}\$${funcName}" +data class DomainFuncName(val domainName: DomainName, override val mangledBaseName: String) : MangledName { + override val mangledType: String + get() = "DF" + override val mangledScope: String + get() = domainName.mangledBaseName } /** Represents the name of a possible anonymous axiom. @@ -31,8 +34,10 @@ sealed interface OptionalDomainAxiomLabel { val domainName: DomainName } -data class NamedDomainAxiomLabel(override val domainName: DomainName, val axiomName: String) : OptionalDomainAxiomLabel, MangledName { - override val mangled: String = "${domainName.mangled}\$${axiomName}" +data class NamedDomainAxiomLabel(override val domainName: DomainName, override val mangledBaseName: String) : + OptionalDomainAxiomLabel, MangledName { + override val mangledScope: String + get() = domainName.mangledBaseName } data class AnonymousDomainAxiomLabel(override val domainName: DomainName) : OptionalDomainAxiomLabel diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Field.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Field.kt index f71c92d23c2078..1afb4ff5c54f31 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Field.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Field.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.formver.viper.ast import org.jetbrains.kotlin.formver.viper.IntoSilver import org.jetbrains.kotlin.formver.viper.MangledName +import org.jetbrains.kotlin.formver.viper.mangled class Field( val name: MangledName, diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Predicate.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Predicate.kt index 69d7f45ae54b38..924d358ca7c55f 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Predicate.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Predicate.kt @@ -5,10 +5,7 @@ package org.jetbrains.kotlin.formver.viper.ast -import org.jetbrains.kotlin.formver.viper.IntoSilver -import org.jetbrains.kotlin.formver.viper.MangledName -import org.jetbrains.kotlin.formver.viper.toScalaOption -import org.jetbrains.kotlin.formver.viper.toScalaSeq +import org.jetbrains.kotlin.formver.viper.* class Predicate( val name: MangledName, diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Program.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Program.kt index 16cd5d3ce6b64b..e7dadfa24363c2 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Program.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Program.kt @@ -5,10 +5,7 @@ package org.jetbrains.kotlin.formver.viper.ast -import org.jetbrains.kotlin.formver.viper.IntoSilver -import org.jetbrains.kotlin.formver.viper.emptySeq -import org.jetbrains.kotlin.formver.viper.toScalaSeq -import org.jetbrains.kotlin.formver.viper.toSilver +import org.jetbrains.kotlin.formver.viper.* data class Program( val domains: List, diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Stmt.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Stmt.kt index b313e8de5230a8..802145286ff5f4 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Stmt.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Stmt.kt @@ -5,10 +5,7 @@ package org.jetbrains.kotlin.formver.viper.ast -import org.jetbrains.kotlin.formver.viper.IntoSilver -import org.jetbrains.kotlin.formver.viper.MangledName -import org.jetbrains.kotlin.formver.viper.toScalaSeq -import org.jetbrains.kotlin.formver.viper.toSilver +import org.jetbrains.kotlin.formver.viper.* sealed interface Stmt : IntoSilver { diff --git a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Var.kt b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Var.kt index 373cdad8acb032..eeb78b381b655f 100644 --- a/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Var.kt +++ b/plugins/formal-verification/formver.viper/src/org/jetbrains/kotlin/formver/viper/ast/Var.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.formver.viper.MangledName */ data class Var(val name: String, val type: Type) { val mangledName = object : MangledName { - override val mangled: String = name + override val mangledBaseName: String = name } fun use(): Exp.LocalVar = Exp.LocalVar(mangledName, type) diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/as_type_contract.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/as_type_contract.fir.diag.txt index e2123f3fa81e51..a4705d14155001 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/as_type_contract.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/as_type_contract.fir.diag.txt @@ -1,30 +1,29 @@ /as_type_contract.kt:(150,154): info: Generated Viper text for getX: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_getX$fun_take$T_Any$return$NT_Int(local$a: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - !dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$T_class_global$class_IntHolder()) +method f$g$getX$TF$T$Any(p$a: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 != DF$RT$nullValue() ==> + !DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$T$class_c$g$IntHolder()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$anyType()) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$T_class_global$class_IntHolder())) { - anonymous$0 := local$a + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$anyType()) + if (DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$T$class_c$g$IntHolder())) { + a$0 := p$a } else { - anonymous$0 := dom$RuntimeType$nullValue()} - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_IntHolder())) - inhale anonymous$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_IntHolder(anonymous$0), wildcard) - if (anonymous$0 != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - unfold acc(T_class_global$class_IntHolder(anonymous$0), wildcard) - anonymous$1 := anonymous$0.public$backing_field_x - ret$0 := anonymous$1 + a$0 := DF$RT$nullValue()} + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$nullable(DF$RT$T$class_c$g$IntHolder())) + inhale a$0 != DF$RT$nullValue() ==> + acc(T$class_c$g$IntHolder(a$0), wildcard) + if (a$0 != DF$RT$nullValue()) { + var a$1: Ref + unfold acc(T$class_c$g$IntHolder(a$0), wildcard) + a$1 := a$0.bf$public$x + r$0 := a$1 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /as_type_contract.kt:(194,236): warning: Cannot verify that if a non-null value is returned then a !is IntHolder. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/binary_search.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/binary_search.fir.diag.txt index 98c9f957823af3..ae2c4da507a86e 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/binary_search.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/binary_search.fir.diag.txt @@ -1,413 +1,383 @@ /binary_search.kt:(90,110): info: Generated Viper text for mid_increased_by_one: -field special$size: Ref +field sp$size: Ref -method global$fun_mid_increased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$mid_increased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr: Ref, + p$target: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$size: Ref - var local0$mid: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - local0$size := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$size), dom$RuntimeType$intType()) + var l0$size: Ref + var l0$mid: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + l0$size := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$size), DF$RT$intType()) inhale 2 != 0 - anonymous$1 := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$intType()) - anonymous$0 := special$divInts(anonymous$1, dom$RuntimeType$intToRef(2)) - local0$mid := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - anonymous$2 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$arr) - if (dom$RuntimeType$boolFromRef(anonymous$2)) { - ret$0 := dom$RuntimeType$boolToRef(false) + a$1 := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + a$0 := sp$divInts(a$1, DF$RT$intToRef(2)) + l0$mid := sp$plusInts(a$0, DF$RT$intToRef(1)) + a$2 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$arr) + if (DF$RT$boolFromRef(a$2)) { + r$0 := DF$RT$boolToRef(false) } else { - var anonymous$3: Ref - anonymous$3 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$3) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + var a$3: Ref + a$3 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$3) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$4: Ref - anonymous$4 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$4) < - dom$RuntimeType$intFromRef(local$target)) { - var anonymous$5: Ref - anonymous$5 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), local0$size) - ret$0 := global$fun_mid_increased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$5, - local$target) + var a$4: Ref + a$4 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$4) < DF$RT$intFromRef(p$target)) { + var a$5: Ref + a$5 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + sp$plusInts(l0$mid, DF$RT$intToRef(1)), l0$size) + r$0 := f$g$mid_increased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$5, + p$target) } else { - var anonymous$6: Ref - anonymous$6 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - dom$RuntimeType$intToRef(0), local0$mid) - ret$0 := global$fun_mid_increased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$6, - local$target) + var a$6: Ref + a$6 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + DF$RT$intToRef(0), l0$mid) + r$0 := f$g$mid_increased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$6, + p$target) } } } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) /binary_search.kt:(305,313): warning: Invalid index for list 'arr', the index may be greater than the list's size. /binary_search.kt:(511,531): info: Generated Viper text for mid_decreased_by_one: -field special$size: Ref +field sp$size: Ref -method global$fun_mid_decreased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$mid_decreased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr: Ref, + p$target: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$size: Ref - var local0$mid: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - local0$size := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$size), dom$RuntimeType$intType()) + var l0$size: Ref + var l0$mid: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + l0$size := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$size), DF$RT$intType()) inhale 2 != 0 - anonymous$1 := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$intType()) - anonymous$0 := special$divInts(anonymous$1, dom$RuntimeType$intToRef(2)) - local0$mid := special$minusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - anonymous$2 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$arr) - if (dom$RuntimeType$boolFromRef(anonymous$2)) { - ret$0 := dom$RuntimeType$boolToRef(false) + a$1 := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + a$0 := sp$divInts(a$1, DF$RT$intToRef(2)) + l0$mid := sp$minusInts(a$0, DF$RT$intToRef(1)) + a$2 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$arr) + if (DF$RT$boolFromRef(a$2)) { + r$0 := DF$RT$boolToRef(false) } else { - var anonymous$3: Ref - anonymous$3 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$3) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + var a$3: Ref + a$3 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$3) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$4: Ref - anonymous$4 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$4) < - dom$RuntimeType$intFromRef(local$target)) { - var anonymous$5: Ref - anonymous$5 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), local0$size) - ret$0 := global$fun_mid_decreased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$5, - local$target) + var a$4: Ref + a$4 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$4) < DF$RT$intFromRef(p$target)) { + var a$5: Ref + a$5 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + sp$plusInts(l0$mid, DF$RT$intToRef(1)), l0$size) + r$0 := f$g$mid_decreased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$5, + p$target) } else { - var anonymous$6: Ref - anonymous$6 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - dom$RuntimeType$intToRef(0), local0$mid) - ret$0 := global$fun_mid_decreased_by_one$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$6, - local$target) + var a$6: Ref + a$6 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + DF$RT$intToRef(0), l0$mid) + r$0 := f$g$mid_decreased_by_one$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$6, + p$target) } } } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) /binary_search.kt:(726,734): warning: Invalid index for list 'arr', the index may be less than zero. /binary_search.kt:(932,964): info: Generated Viper text for mid_decreased_by_one_in_rec_call: -field special$size: Ref +field sp$size: Ref -method global$fun_mid_decreased_by_one_in_rec_call$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$mid_decreased_by_one_in_rec_call$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr: Ref, + p$target: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$size: Ref - var local0$mid: Ref - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - local0$size := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$size), dom$RuntimeType$intType()) + var l0$size: Ref + var l0$mid: Ref + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + l0$size := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$size), DF$RT$intType()) inhale 2 != 0 - anonymous$0 := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - local0$mid := special$divInts(anonymous$0, dom$RuntimeType$intToRef(2)) - anonymous$1 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$arr) - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - ret$0 := dom$RuntimeType$boolToRef(false) + a$0 := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + l0$mid := sp$divInts(a$0, DF$RT$intToRef(2)) + a$1 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$arr) + if (DF$RT$boolFromRef(a$1)) { + r$0 := DF$RT$boolToRef(false) } else { - var anonymous$2: Ref - anonymous$2 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$2) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + var a$2: Ref + a$2 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$2) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$3: Ref - anonymous$3 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$3) < - dom$RuntimeType$intFromRef(local$target)) { - var anonymous$4: Ref - anonymous$4 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), local0$size) - ret$0 := global$fun_mid_decreased_by_one_in_rec_call$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$4, - local$target) + var a$3: Ref + a$3 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$3) < DF$RT$intFromRef(p$target)) { + var a$4: Ref + a$4 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + sp$plusInts(l0$mid, DF$RT$intToRef(1)), l0$size) + r$0 := f$g$mid_decreased_by_one_in_rec_call$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$4, + p$target) } else { - var anonymous$5: Ref - anonymous$5 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - dom$RuntimeType$intToRef(0), special$minusInts(local0$mid, dom$RuntimeType$intToRef(1))) - ret$0 := global$fun_mid_decreased_by_one_in_rec_call$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$5, - local$target) + var a$5: Ref + a$5 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + DF$RT$intToRef(0), sp$minusInts(l0$mid, DF$RT$intToRef(1))) + r$0 := f$g$mid_decreased_by_one_in_rec_call$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$5, + p$target) } } } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) /binary_search.kt:(1345,1368): warning: Invalid sub-list range for list 'arr', the range may be greater than the list's size. /binary_search.kt:(1405,1425): info: Generated Viper text for unsafe_binary_search: -field special$size: Ref +field sp$size: Ref -method global$fun_unsafe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref, local$left: Ref, local$right: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$unsafe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr: Ref, + p$target: Ref, p$left: Ref, p$right: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$mid: Ref - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$left), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$right), dom$RuntimeType$intType()) - if (dom$RuntimeType$intFromRef(local$left) > - dom$RuntimeType$intFromRef(local$right)) { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 + var l0$mid: Ref + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$left), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$right), DF$RT$intType()) + if (DF$RT$intFromRef(p$left) > DF$RT$intFromRef(p$right)) { + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 } inhale 2 != 0 - anonymous$0 := special$divInts(special$minusInts(local$right, local$left), - dom$RuntimeType$intToRef(2)) - local0$mid := special$plusInts(local$left, anonymous$0) - anonymous$1 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$1) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + a$0 := sp$divInts(sp$minusInts(p$right, p$left), DF$RT$intToRef(2)) + l0$mid := sp$plusInts(p$left, a$0) + a$1 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$1) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$2: Ref - anonymous$2 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$2) < - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := global$fun_unsafe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr, - local$target, special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), - local$right) + var a$2: Ref + a$2 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$2) < DF$RT$intFromRef(p$target)) { + r$0 := f$g$unsafe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr, + p$target, sp$plusInts(l0$mid, DF$RT$intToRef(1)), p$right) } else { - ret$0 := global$fun_unsafe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr, - local$target, local$left, special$minusInts(local0$mid, dom$RuntimeType$intToRef(1)))} + r$0 := f$g$unsafe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr, + p$target, p$left, sp$minusInts(l0$mid, DF$RT$intToRef(1)))} } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) /binary_search.kt:(1608,1616): warning: Invalid index for list 'arr', the index may be less than zero. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/cond_effects.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/cond_effects.fir.diag.txt index b2cbf704bf6fa5..27bb2ac9d93d7f 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/cond_effects.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/cond_effects.fir.diag.txt @@ -1,98 +1,92 @@ /cond_effects.kt:(121,146): info: Generated Viper text for compoundConditionalEffect: -method global$fun_compoundConditionalEffect$fun_take$T_Boolean$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) - ensures true ==> dom$RuntimeType$boolFromRef(local$b) && false +method f$g$compoundConditionalEffect$TF$T$Boolean(p$b: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) + ensures true ==> DF$RT$boolFromRef(p$b) && false { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /cond_effects.kt:(190,220): warning: Cannot verify that if the function returns then (b && false). /cond_effects.kt:(271,287): info: Generated Viper text for mayReturnNonNull: -method global$fun_mayReturnNonNull$fun_take$NT_Any$return$NT_Any(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ensures ret$0 == dom$RuntimeType$nullValue() ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) +method f$g$mayReturnNonNull$TF$Any(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$anyType())) + ensures r$0 == DF$RT$nullValue() ==> + DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /cond_effects.kt:(328,360): warning: Cannot verify that if a null value is returned then x is Int. /cond_effects.kt:(424,437): info: Generated Viper text for mayReturnNull: -method global$fun_mayReturnNull$fun_take$NT_Any$return$NT_Any(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) +method f$g$mayReturnNull$TF$Any(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$anyType())) + ensures r$0 != DF$RT$nullValue() ==> + DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /cond_effects.kt:(478,513): warning: Cannot verify that if a non-null value is returned then x is Int. /cond_effects.kt:(723,741): info: Generated Viper text for isNullOrEmptyWrong: -method global$fun_isNullOrEmptyWrong$fun_take$NT_class_pkg$kotlin$global$class_CharSequence$return$T_Boolean(local$seq: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - local$seq != dom$RuntimeType$nullValue() +method f$g$isNullOrEmptyWrong$TF$class_c$pkg_kotlin$g$CharSequence(p$seq: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> p$seq != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$seq), dom$RuntimeType$nullable(dom$RuntimeType$T_class_pkg$kotlin$global$class_CharSequence())) - inhale local$seq != dom$RuntimeType$nullValue() ==> - acc(T_class_pkg$kotlin$global$class_CharSequence(local$seq), wildcard) - if (!(local$seq == dom$RuntimeType$nullValue())) { - var anonymous$0: Ref - var anonymous$1: Ref - anonymous$1 := public$property_getter_length(local$seq) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - ret$0 := special$notBool(dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(anonymous$0) == - 0)) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$seq), DF$RT$nullable(DF$RT$T$class_c$pkg_kotlin$g$CharSequence())) + inhale p$seq != DF$RT$nullValue() ==> + acc(T$class_c$pkg_kotlin$g$CharSequence(p$seq), wildcard) + if (!(p$seq == DF$RT$nullValue())) { + var a$0: Ref + var a$1: Ref + a$1 := pg$public$length(p$seq) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + r$0 := sp$notBool(DF$RT$boolToRef(DF$RT$intFromRef(a$0) == 0)) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref) /cond_effects.kt:(796,832): warning: Cannot verify that if a false value is returned then seq != null. /cond_effects.kt:(925,942): info: Generated Viper text for recursiveContract: -field public$backing_field_length: Ref +field bf$public$length: Ref -method global$fun_recursiveContract$fun_take$T_Int$NT_Any$return$T_Boolean(local$n: Ref, - local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_pkg$kotlin$global$class_String()) +method f$g$recursiveContract$TF$T$Int$Any(p$n: Ref, p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> + DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$pkg_kotlin$g$String()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$n), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - if (dom$RuntimeType$intFromRef(local$n) == 0) { - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), - dom$RuntimeType$intType())) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$n), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + if (DF$RT$intFromRef(p$n) == 0) { + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType())) } else { - ret$0 := global$fun_recursiveContract$fun_take$T_Int$NT_Any$return$T_Boolean(special$minusInts(local$n, - dom$RuntimeType$intToRef(1)), local$x)} - goto label$ret$0 - label label$ret$0 + r$0 := f$g$recursiveContract$TF$T$Int$Any(sp$minusInts(p$n, DF$RT$intToRef(1)), + p$x)} + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref) /cond_effects.kt:(994,1029): warning: Cannot verify that if a true value is returned then x is String. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/do_not_verify.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/do_not_verify.fir.diag.txt index 8f8e799bbfcdb5..04fb0443558a27 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/do_not_verify.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/do_not_verify.fir.diag.txt @@ -1,10 +1,9 @@ /do_not_verify.kt:(245,256): info: Generated Viper text for bad_returns: -method global$fun_bad_returns$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$bad_returns$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/is_type_contract.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/is_type_contract.fir.diag.txt index df618f5e7a029c..e301d31c7c68b1 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/is_type_contract.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/is_type_contract.fir.diag.txt @@ -1,34 +1,29 @@ /is_type_contract.kt:(151,172): info: Generated Viper text for unverifiableTypeCheck: -field public$backing_field_length: Ref +field bf$public$length: Ref -method global$fun_unverifiableTypeCheck$fun_take$NT_Int$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$unitType()) +method f$g$unverifiableTypeCheck$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures true ==> DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), - dom$RuntimeType$T_class_pkg$kotlin$global$class_String())) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$pkg_kotlin$g$String())) + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref) /is_type_contract.kt:(216,245): warning: Cannot verify that if the function returns then x is Unit. /is_type_contract.kt:(319,341): info: Generated Viper text for nullableNotNonNullable: -method global$fun_nullableNotNonNullable$fun_take$NT_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) - ensures true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) +method f$g$nullableNotNonNullable$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) + ensures true ==> DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /is_type_contract.kt:(376,404): warning: Cannot verify that if the function returns then x is Int. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/list.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/list.fir.diag.txt index 818ccc9b7af591..b74a23e24a618b 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/list.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/list.fir.diag.txt @@ -1,274 +1,256 @@ /list.kt:(91,110): info: Generated Viper text for empty_list_expr_get: -field special$size: Ref +field sp$size: Ref -method global$fun_empty_list_expr_get$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$empty_list_expr_get$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$s: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - local0$s := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(anonymous$0, - dom$RuntimeType$intToRef(0)) - label label$ret$0 + var l0$s: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := f$pkg_kotlin_collections$g$emptyList$TF$() + l0$s := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$0, + DF$RT$intToRef(0)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - - -method pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(ret.special$size) == 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + + +method f$pkg_kotlin_collections$g$emptyList$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(ret.sp$size) == 0 /list.kt:(127,146): warning: Invalid index for the following list sub-expression, the index may be greater than the list's size. /list.kt:(168,182): info: Generated Viper text for empty_list_get: -field special$size: Ref +field sp$size: Ref -method global$fun_empty_list_get$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$empty_list_get$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$myList: Ref - var local0$s: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$myList := pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - local0$s := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local0$myList, - dom$RuntimeType$intToRef(0)) - label label$ret$0 + var l0$myList: Ref + var l0$s: Ref + r$0 := DF$RT$unitValue() + l0$myList := f$pkg_kotlin_collections$g$emptyList$TF$() + l0$s := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(l0$myList, + DF$RT$intToRef(0)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) - returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - - -method pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(ret.special$size) == 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + + +method f$pkg_kotlin_collections$g$emptyList$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(ret.sp$size) == 0 /list.kt:(239,248): warning: Invalid index for list 'myList', the index may be greater than the list's size. /list.kt:(270,281): info: Generated Viper text for unsafe_last: -field special$size: Ref - -method global$fun_unsafe_last$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Int(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +field sp$size: Ref + +method f$g$unsafe_last$TF$T$class_c$pkg_kotlin_collections$g$List(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$l), wildcard) - anonymous$0 := local$l.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - ret$0 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$l, - special$minusInts(anonymous$0, dom$RuntimeType$intToRef(1))) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$l), wildcard) + a$0 := p$l.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + r$0 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$l, + sp$minusInts(a$0, DF$RT$intToRef(1))) + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) /list.kt:(315,328): warning: Invalid index for list 'l', the index may be less than zero. /list.kt:(350,357): info: Generated Viper text for add_get: -field special$size: Ref - -method global$fun_add_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$return$T_Unit(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +field sp$size: Ref + +method f$g$add_get$TF$T$class_c$pkg_kotlin_collections$g$MutableList(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var local0$n: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_MutableList()) - inhale acc(T_class_pkg$kotlin$collections$global$class_MutableList(local$l), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := pkg$kotlin$collections$class_MutableList$fun_add$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Boolean(local$l, - dom$RuntimeType$intToRef(1)) - local0$n := pkg$kotlin$collections$class_MutableList$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Int(local$l, - dom$RuntimeType$intToRef(1)) - label label$ret$0 + var a$0: Ref + var l0$n: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$MutableList()) + inhale acc(T$class_c$pkg_kotlin_collections$g$MutableList(p$l), wildcard) + r$0 := DF$RT$unitValue() + a$0 := f$pkg_kotlin_collections$c$MutableList$add$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(p$l, + DF$RT$intToRef(1)) + l0$n := f$pkg_kotlin_collections$c$MutableList$get$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(p$l, + DF$RT$intToRef(1)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_MutableList$fun_add$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Boolean(this: Ref, - local$element: Ref) +method f$pkg_kotlin_collections$c$MutableList$add$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(this: Ref, + p$element: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + 1 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + 1 -method pkg$kotlin$collections$class_MutableList$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$MutableList$get$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) /list.kt:(406,410): warning: Invalid index for list 'l', the index may be greater than the list's size. /list.kt:(432,446): info: Generated Viper text for empty_list_sub: -field special$size: Ref +field sp$size: Ref -method global$fun_empty_list_sub$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$empty_list_sub$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$l: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - local0$l := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(anonymous$0, - dom$RuntimeType$intToRef(0), dom$RuntimeType$intToRef(1)) - label label$ret$0 + var l0$l: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := f$pkg_kotlin_collections$g$emptyList$TF$() + l0$l := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(a$0, + DF$RT$intToRef(0), DF$RT$intToRef(1)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) - - -method pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(ret.special$size) == 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) + + +method f$pkg_kotlin_collections$g$emptyList$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(ret.sp$size) == 0 /list.kt:(463,493): warning: Invalid sub-list range for the following list sub-expression, the range may be greater than the list's size. /list.kt:(515,538): info: Generated Viper text for empty_list_sub_negative: -field special$size: Ref +field sp$size: Ref -method global$fun_empty_list_sub_negative$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$empty_list_sub_negative$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$l: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - local0$l := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(anonymous$0, - dom$RuntimeType$intToRef(-1), dom$RuntimeType$intToRef(1)) - label label$ret$0 + var l0$l: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := f$pkg_kotlin_collections$g$emptyList$TF$() + l0$l := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(a$0, + DF$RT$intToRef(-1), DF$RT$intToRef(1)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) - returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) - - -method pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(ret.special$size) == 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) + + +method f$pkg_kotlin_collections$g$emptyList$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(ret.sp$size) == 0 /list.kt:(555,586): warning: Invalid sub-list range for the following list sub-expression, the range may be including negative indices. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_booleans.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_booleans.fir.diag.txt index 580b5f6de19afd..e13cd5baf9357e 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_booleans.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_booleans.fir.diag.txt @@ -1,25 +1,23 @@ /returns_booleans.kt:(121,146): info: Generated Viper text for incorrectly_returns_false: -method global$fun_incorrectly_returns_false$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$incorrectly_returns_false$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(183,196): warning: Function may return a false value. /returns_booleans.kt:(264,288): info: Generated Viper text for incorrectly_returns_true: -method global$fun_incorrectly_returns_true$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false +method f$g$incorrectly_returns_true$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false { - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(325,339): warning: Function may return a true value. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_not_null.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_not_null.fir.diag.txt index 89e94acf12ceaf..151ce5a780adff 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_not_null.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_not_null.fir.diag.txt @@ -1,12 +1,11 @@ /returns_not_null.kt:(121,133): info: Generated Viper text for returns_null: -method global$fun_returns_null$fun_take$$return$NT_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 != dom$RuntimeType$nullValue() +method f$g$returns_null$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 != DF$RT$nullValue() { - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue() + goto lbl$ret$0 + label lbl$ret$0 } /returns_not_null.kt:(167,183): warning: Function may return a null value. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_null.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_null.fir.diag.txt index 11d945b6950b87..78ee22aef9e209 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_null.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/returns_null.fir.diag.txt @@ -1,27 +1,25 @@ /returns_null.kt:(121,146): info: Generated Viper text for returns_null_unverifiable: -method global$fun_returns_null_unverifiable$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$returns_null_unverifiable$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) ensures true ==> false { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$nullValue() + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(187,210): warning: Cannot verify that if the function returns then false. /returns_null.kt:(277,302): info: Generated Viper text for non_nullable_returns_null: -method global$fun_non_nullable_returns_null$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - ensures ret$0 == dom$RuntimeType$nullValue() +method f$g$non_nullable_returns_null$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + ensures r$0 == DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(341,354): warning: Function may return a non-null value. diff --git a/plugins/formal-verification/testData/diagnostics/bad_contracts/viper_verify.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/bad_contracts/viper_verify.fir.diag.txt index 14d13f41766810..44a6316a9b53e4 100644 --- a/plugins/formal-verification/testData/diagnostics/bad_contracts/viper_verify.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/bad_contracts/viper_verify.fir.diag.txt @@ -1,28 +1,26 @@ /viper_verify.kt:(125,137): info: Generated Viper text for verify_false: -method global$fun_verify_false$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$verify_false$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - ret$0 := dom$RuntimeType$unitValue() + r$0 := DF$RT$unitValue() assert false - label label$ret$0 + label lbl$ret$0 } /viper_verify.kt:(153,158): warning: Viper verification error: Assert might fail. Assertion false might not hold. /viper_verify.kt:(181,196): info: Generated Viper text for verify_compound: -method global$fun_verify_compound$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$verify_compound$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() + var a$0: Ref + r$0 := DF$RT$unitValue() if (true) { - anonymous$0 := dom$RuntimeType$boolToRef(false) + a$0 := DF$RT$boolToRef(false) } else { - anonymous$0 := dom$RuntimeType$boolToRef(false)} - assert dom$RuntimeType$boolFromRef(anonymous$0) - label label$ret$0 + a$0 := DF$RT$boolToRef(false)} + assert DF$RT$boolFromRef(a$0) + label lbl$ret$0 } -/viper_verify.kt:(212,225): warning: Viper verification error: Assert might fail. Assertion dom$RuntimeType$boolFromRef(anonymous$0) might not hold. +/viper_verify.kt:(212,225): warning: Viper verification error: Assert might fail. Assertion DF$RT$boolFromRef(a$0) might not hold. diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/as_type_contract.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/as_type_contract.fir.diag.txt index 22c141f1e83aec..29ce04235fb458 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/as_type_contract.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/as_type_contract.fir.diag.txt @@ -1,66 +1,61 @@ /as_type_contract.kt:(152,162): info: Generated Viper text for asOperator: -method global$fun_asOperator$fun_take$T_class_global$class_Foo$return$T_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Bar()) - ensures acc(T_class_global$class_Bar(ret$0), wildcard) +method f$g$asOperator$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Bar()) + ensures acc(T$class_c$g$Bar(r$0), wildcard) ensures true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Bar()) + DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Bar()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := local$foo - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := p$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } /as_type_contract.kt:(307,321): info: Generated Viper text for safeAsOperator: -method global$fun_safeAsOperator$fun_take$T_class_global$class_Foo$return$NT_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Bar()) +method f$g$safeAsOperator$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) + ensures r$0 != DF$RT$nullValue() ==> + DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Bar()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := local$foo - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - inhale ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := p$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + inhale r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } /as_type_contract.kt:(504,508): info: Generated Viper text for getX: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_getX$fun_take$T_Any$return$NT_Int(local$a: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$T_class_global$class_IntHolder()) - ensures ret$0 == dom$RuntimeType$nullValue() ==> - !dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$T_class_global$class_IntHolder()) +method f$g$getX$TF$T$Any(p$a: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 != DF$RT$nullValue() ==> + DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$T$class_c$g$IntHolder()) + ensures r$0 == DF$RT$nullValue() ==> + !DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$T$class_c$g$IntHolder()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$anyType()) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$T_class_global$class_IntHolder())) { - anonymous$0 := local$a + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$anyType()) + if (DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$T$class_c$g$IntHolder())) { + a$0 := p$a } else { - anonymous$0 := dom$RuntimeType$nullValue()} - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_IntHolder())) - inhale anonymous$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_IntHolder(anonymous$0), wildcard) - if (anonymous$0 != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - unfold acc(T_class_global$class_IntHolder(anonymous$0), wildcard) - anonymous$1 := anonymous$0.public$backing_field_x - ret$0 := anonymous$1 + a$0 := DF$RT$nullValue()} + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$nullable(DF$RT$T$class_c$g$IntHolder())) + inhale a$0 != DF$RT$nullValue() ==> + acc(T$class_c$g$IntHolder(a$0), wildcard) + if (a$0 != DF$RT$nullValue()) { + var a$1: Ref + unfold acc(T$class_c$g$IntHolder(a$0), wildcard) + a$1 := a$0.bf$public$x + r$0 := a$1 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/backing_field_getters.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/backing_field_getters.fir.diag.txt index 584961c76b3319..a611d0ee4a9c69 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/backing_field_getters.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/backing_field_getters.fir.diag.txt @@ -1,287 +1,260 @@ /backing_field_getters.kt:(178,188): info: Generated Viper text for cascadeGet: -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_cascadeGet$fun_take$T_class_global$class_X$return$T_class_global$class_Z(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Z()) - ensures acc(T_class_global$class_Z(ret$0), wildcard) +method f$g$cascadeGet$TF$T$class_c$g$X(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Z()) + ensures acc(T$class_c$g$Z(r$0), wildcard) ensures true { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_X()) - inhale acc(T_class_global$class_X(local$x), wildcard) - unfold acc(T_class_global$class_X(local$x), wildcard) - anonymous$0 := local$x.public$backing_field_y - unfold acc(T_class_global$class_Y(anonymous$0), wildcard) - ret$0 := anonymous$0.public$backing_field_z - goto label$ret$0 - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$X()) + inhale acc(T$class_c$g$X(p$x), wildcard) + unfold acc(T$class_c$g$X(p$x), wildcard) + a$0 := p$x.bf$public$y + unfold acc(T$class_c$g$Y(a$0), wildcard) + r$0 := a$0.bf$public$z + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(300,321): info: Generated Viper text for receiverNotNullProved: -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_receiverNotNullProved$fun_take$NT_class_global$class_X$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - local$x != dom$RuntimeType$nullValue() +method f$g$receiverNotNullProved$TF$class_c$g$X(p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> p$x != DF$RT$nullValue() { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_X())) - inhale local$x != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_X(local$x), wildcard) - if (local$x != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - unfold acc(T_class_global$class_X(local$x), wildcard) - anonymous$1 := local$x.public$backing_field_y - anonymous$0 := anonymous$1 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$T$class_c$g$X())) + inhale p$x != DF$RT$nullValue() ==> acc(T$class_c$g$X(p$x), wildcard) + if (p$x != DF$RT$nullValue()) { + var a$1: Ref + unfold acc(T$class_c$g$X(p$x), wildcard) + a$1 := p$x.bf$public$y + a$0 := a$1 } else { - anonymous$0 := dom$RuntimeType$nullValue()} - ret$0 := special$notBool(dom$RuntimeType$boolToRef(anonymous$0 == - dom$RuntimeType$nullValue())) - goto label$ret$0 - label label$ret$0 + a$0 := DF$RT$nullValue()} + r$0 := sp$notBool(DF$RT$boolToRef(a$0 == DF$RT$nullValue())) + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(560,578): info: Generated Viper text for cascadeNullableGet: -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_cascadeNullableGet$fun_take$NT_class_global$class_NullableX$return$NT_class_global$class_Z(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Z())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Z(ret$0), wildcard) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - local$x != dom$RuntimeType$nullValue() +method f$g$cascadeNullableGet$TF$class_c$g$NullableX(p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Z())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Z(r$0), wildcard) + ensures r$0 != DF$RT$nullValue() ==> p$x != DF$RT$nullValue() { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_NullableX())) - inhale local$x != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_NullableX(local$x), wildcard) - if (local$x != dom$RuntimeType$nullValue()) { - unfold acc(T_class_global$class_NullableX(local$x), wildcard) - anonymous$0 := local$x.public$backing_field_y + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$T$class_c$g$NullableX())) + inhale p$x != DF$RT$nullValue() ==> + acc(T$class_c$g$NullableX(p$x), wildcard) + if (p$x != DF$RT$nullValue()) { + unfold acc(T$class_c$g$NullableX(p$x), wildcard) + a$0 := p$x.bf$public$y } else { - anonymous$0 := dom$RuntimeType$nullValue()} - if (anonymous$0 != dom$RuntimeType$nullValue()) { - unfold acc(T_class_global$class_NullableY(anonymous$0), wildcard) - ret$0 := anonymous$0.public$backing_field_z + a$0 := DF$RT$nullValue()} + if (a$0 != DF$RT$nullValue()) { + unfold acc(T$class_c$g$NullableY(a$0), wildcard) + r$0 := a$0.bf$public$z } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(729,756): info: Generated Viper text for cascadeNullableSmartcastGet: -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_cascadeNullableSmartcastGet$fun_take$NT_class_global$class_NullableX$return$NT_class_global$class_Z(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Z())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Z(ret$0), wildcard) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - local$x != dom$RuntimeType$nullValue() +method f$g$cascadeNullableSmartcastGet$TF$class_c$g$NullableX(p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Z())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Z(r$0), wildcard) + ensures r$0 != DF$RT$nullValue() ==> p$x != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_NullableX())) - inhale local$x != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_NullableX(local$x), wildcard) - if (local$x == dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$nullValue() - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$T$class_c$g$NullableX())) + inhale p$x != DF$RT$nullValue() ==> + acc(T$class_c$g$NullableX(p$x), wildcard) + if (p$x == DF$RT$nullValue()) { + var a$0: Ref + a$0 := DF$RT$nullValue() + r$0 := a$0 } else { - var anonymous$1: Ref - unfold acc(T_class_global$class_NullableX(local$x), wildcard) - anonymous$1 := local$x.public$backing_field_y - if (anonymous$1 == dom$RuntimeType$nullValue()) { - var anonymous$2: Ref - anonymous$2 := dom$RuntimeType$nullValue() - ret$0 := anonymous$2 + var a$1: Ref + unfold acc(T$class_c$g$NullableX(p$x), wildcard) + a$1 := p$x.bf$public$y + if (a$1 == DF$RT$nullValue()) { + var a$2: Ref + a$2 := DF$RT$nullValue() + r$0 := a$2 } else { - var anonymous$3: Ref - unfold acc(T_class_global$class_NullableX(local$x), wildcard) - anonymous$3 := local$x.public$backing_field_y - unfold acc(T_class_global$class_NullableY(anonymous$3), wildcard) - ret$0 := anonymous$3.public$backing_field_z + var a$3: Ref + unfold acc(T$class_c$g$NullableX(p$x), wildcard) + a$3 := p$x.bf$public$y + unfold acc(T$class_c$g$NullableY(a$3), wildcard) + r$0 := a$3.bf$public$z } } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(987,1017): info: Generated Viper text for nullableReceiverNotNullSafeGet: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Baz$constructor$fun_take$$return$T_class_global$class_Baz() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Baz()) - ensures acc(T_class_global$class_Baz(ret), wildcard) - ensures acc(Unique$T_class_global$class_Baz(ret), write) +method con$c$Baz$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Baz()) + ensures acc(T$class_c$g$Baz(ret), wildcard) + ensures acc(U$T$class_c$g$Baz(ret), write) -method global$fun_nullableReceiverNotNullSafeGet$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false +method f$g$nullableReceiverNotNullSafeGet$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false { - var local0$f: Ref - var anonymous$0: Ref - var anonymous$1: Ref - anonymous$0 := class_Baz$constructor$fun_take$$return$T_class_global$class_Baz() - local0$f := anonymous$0 - if (local0$f != dom$RuntimeType$nullValue()) { - var anonymous$2: Ref - unfold acc(T_class_global$class_Baz(local0$f), wildcard) - anonymous$2 := local0$f.public$backing_field_x - anonymous$1 := anonymous$2 + var l0$f: Ref + var a$0: Ref + var a$1: Ref + a$0 := con$c$Baz$() + l0$f := a$0 + if (l0$f != DF$RT$nullValue()) { + var a$2: Ref + unfold acc(T$class_c$g$Baz(l0$f), wildcard) + a$2 := l0$f.bf$public$x + a$1 := a$2 } else { - anonymous$1 := dom$RuntimeType$nullValue()} - ret$0 := dom$RuntimeType$boolToRef(anonymous$1 == - dom$RuntimeType$nullValue()) - goto label$ret$0 - label label$ret$0 + a$1 := DF$RT$nullValue()} + r$0 := DF$RT$boolToRef(a$1 == DF$RT$nullValue()) + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(1167,1194): info: Generated Viper text for nullableReceiverNullSafeGet: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_nullableReceiverNullSafeGet$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$nullableReceiverNullSafeGet$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var local0$f: Ref - var anonymous$0: Ref - local0$f := dom$RuntimeType$nullValue() - if (local0$f != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - unfold acc(T_class_global$class_Baz(local0$f), wildcard) - anonymous$1 := local0$f.public$backing_field_x - anonymous$0 := anonymous$1 + var l0$f: Ref + var a$0: Ref + l0$f := DF$RT$nullValue() + if (l0$f != DF$RT$nullValue()) { + var a$1: Ref + unfold acc(T$class_c$g$Baz(l0$f), wildcard) + a$1 := l0$f.bf$public$x + a$0 := a$1 } else { - anonymous$0 := dom$RuntimeType$nullValue()} - ret$0 := dom$RuntimeType$boolToRef(anonymous$0 == - dom$RuntimeType$nullValue()) - goto label$ret$0 - label label$ret$0 + a$0 := DF$RT$nullValue()} + r$0 := DF$RT$boolToRef(a$0 == DF$RT$nullValue()) + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(1377,1403): info: Generated Viper text for nonNullableReceiverSafeGet: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Baz$constructor$fun_take$$return$T_class_global$class_Baz() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Baz()) - ensures acc(T_class_global$class_Baz(ret), wildcard) - ensures acc(Unique$T_class_global$class_Baz(ret), write) +method con$c$Baz$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Baz()) + ensures acc(T$class_c$g$Baz(ret), wildcard) + ensures acc(U$T$class_c$g$Baz(ret), write) -method global$fun_nonNullableReceiverSafeGet$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false +method f$g$nonNullableReceiverSafeGet$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false { - var local0$f: Ref - var anonymous$0: Ref - local0$f := class_Baz$constructor$fun_take$$return$T_class_global$class_Baz() - if (local0$f != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - unfold acc(T_class_global$class_Baz(local0$f), wildcard) - anonymous$1 := local0$f.public$backing_field_x - anonymous$0 := anonymous$1 + var l0$f: Ref + var a$0: Ref + l0$f := con$c$Baz$() + if (l0$f != DF$RT$nullValue()) { + var a$1: Ref + unfold acc(T$class_c$g$Baz(l0$f), wildcard) + a$1 := l0$f.bf$public$x + a$0 := a$1 } else { - anonymous$0 := dom$RuntimeType$nullValue()} - ret$0 := dom$RuntimeType$boolToRef(anonymous$0 == - dom$RuntimeType$nullValue()) - goto label$ret$0 - label label$ret$0 + a$0 := DF$RT$nullValue()} + r$0 := DF$RT$boolToRef(a$0 == DF$RT$nullValue()) + goto lbl$ret$0 + label lbl$ret$0 } /backing_field_getters.kt:(1681,1693): info: Generated Viper text for checkPrimary: -field public$backing_field_x: Ref - -field public$backing_field_y: Ref - -field public$backing_field_z: Ref - -method class_ClassI$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_ClassI(local$x: Ref, - local$y: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_ClassI()) - ensures acc(T_class_global$class_ClassI(ret), wildcard) - ensures acc(Unique$T_class_global$class_ClassI(ret), write) - ensures (unfolding acc(T_class_global$class_ClassI(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_x) == - dom$RuntimeType$intFromRef(local$x) && - dom$RuntimeType$intFromRef(ret.public$backing_field_y) == - dom$RuntimeType$intFromRef(local$y)) - - -method class_ClassII$constructor$fun_take$T_class_global$class_Z$return$T_class_global$class_ClassII(local$z: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_ClassII()) - ensures acc(T_class_global$class_ClassII(ret), wildcard) - ensures acc(Unique$T_class_global$class_ClassII(ret), write) - ensures (unfolding acc(T_class_global$class_ClassII(ret), wildcard) in - ret.public$backing_field_z == local$z) - - -method class_Z$constructor$fun_take$$return$T_class_global$class_Z() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Z()) - ensures acc(T_class_global$class_Z(ret), wildcard) - ensures acc(Unique$T_class_global$class_Z(ret), write) - - -method global$fun_checkPrimary$fun_take$T_Int$T_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> false +field bf$public$x: Ref + +field bf$public$y: Ref + +field bf$public$z: Ref + +method con$c$ClassI$T$Int$T$Int(p$x: Ref, p$y: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$ClassI()) + ensures acc(T$class_c$g$ClassI(ret), wildcard) + ensures acc(U$T$class_c$g$ClassI(ret), write) + ensures (unfolding acc(T$class_c$g$ClassI(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$x) == DF$RT$intFromRef(p$x) && + DF$RT$intFromRef(ret.bf$public$y) == DF$RT$intFromRef(p$y)) + + +method con$c$ClassII$T$class_c$g$Z(p$z: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$ClassII()) + ensures acc(T$class_c$g$ClassII(ret), wildcard) + ensures acc(U$T$class_c$g$ClassII(ret), write) + ensures (unfolding acc(T$class_c$g$ClassII(ret), wildcard) in + ret.bf$public$z == p$z) + + +method con$c$Z$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Z()) + ensures acc(T$class_c$g$Z(ret), wildcard) + ensures acc(U$T$class_c$g$Z(ret), write) + + +method f$g$checkPrimary$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> false { - var local0$classI: Ref - var local0$z: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - local0$classI := class_ClassI$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_ClassI(local$x, - local$y) - local0$z := class_Z$constructor$fun_take$$return$T_class_global$class_Z() - if (!(dom$RuntimeType$intFromRef(local$x) == - dom$RuntimeType$intFromRef(local$y))) { - anonymous$0 := dom$RuntimeType$boolToRef(true) + var l0$classI: Ref + var l0$z: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + l0$classI := con$c$ClassI$T$Int$T$Int(p$x, p$y) + l0$z := con$c$Z$() + if (!(DF$RT$intFromRef(p$x) == DF$RT$intFromRef(p$y))) { + a$0 := DF$RT$boolToRef(true) } else { - var anonymous$1: Ref - var anonymous$2: Ref - unfold acc(T_class_global$class_ClassI(local0$classI), wildcard) - anonymous$1 := local0$classI.public$backing_field_x - unfold acc(T_class_global$class_ClassI(local0$classI), wildcard) - anonymous$2 := local0$classI.public$backing_field_y - anonymous$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(anonymous$1) == - dom$RuntimeType$intFromRef(anonymous$2)) + var a$1: Ref + var a$2: Ref + unfold acc(T$class_c$g$ClassI(l0$classI), wildcard) + a$1 := l0$classI.bf$public$x + unfold acc(T$class_c$g$ClassI(l0$classI), wildcard) + a$2 := l0$classI.bf$public$y + a$0 := DF$RT$boolToRef(DF$RT$intFromRef(a$1) == DF$RT$intFromRef(a$2)) } - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - var anonymous$3: Ref - var anonymous$4: Ref - anonymous$4 := class_ClassII$constructor$fun_take$T_class_global$class_Z$return$T_class_global$class_ClassII(local0$z) - unfold acc(T_class_global$class_ClassII(anonymous$4), wildcard) - anonymous$3 := anonymous$4.public$backing_field_z - ret$0 := dom$RuntimeType$boolToRef(anonymous$3 == local0$z) + if (DF$RT$boolFromRef(a$0)) { + var a$3: Ref + var a$4: Ref + a$4 := con$c$ClassII$T$class_c$g$Z(l0$z) + unfold acc(T$class_c$g$ClassII(a$4), wildcard) + a$3 := a$4.bf$public$z + r$0 := DF$RT$boolToRef(a$3 == l0$z) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_z(this: Ref) returns (ret: Ref) - +method pg$public$z(this: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/binary_search.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/binary_search.fir.diag.txt index bba26b41a33d02..886f29ee407f90 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/binary_search.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/binary_search.fir.diag.txt @@ -1,190 +1,176 @@ /binary_search.kt:(90,108): info: Generated Viper text for safe_binary_search: -field special$size: Ref +field sp$size: Ref -method global$fun_safe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$safe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr: Ref, + p$target: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$size: Ref - var local0$mid: Ref - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - local0$size := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$size), dom$RuntimeType$intType()) + var l0$size: Ref + var l0$mid: Ref + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + l0$size := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$size), DF$RT$intType()) inhale 2 != 0 - anonymous$0 := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - local0$mid := special$divInts(anonymous$0, dom$RuntimeType$intToRef(2)) - anonymous$1 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$arr) - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - ret$0 := dom$RuntimeType$boolToRef(false) + a$0 := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + l0$mid := sp$divInts(a$0, DF$RT$intToRef(2)) + a$1 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$arr) + if (DF$RT$boolFromRef(a$1)) { + r$0 := DF$RT$boolToRef(false) } else { - var anonymous$2: Ref - anonymous$2 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$2) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + var a$2: Ref + a$2 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$2) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$3: Ref - anonymous$3 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$3) < - dom$RuntimeType$intFromRef(local$target)) { - var anonymous$4: Ref - anonymous$4 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), local0$size) - ret$0 := global$fun_safe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$4, - local$target) + var a$3: Ref + a$3 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$3) < DF$RT$intFromRef(p$target)) { + var a$4: Ref + a$4 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + sp$plusInts(l0$mid, DF$RT$intToRef(1)), l0$size) + r$0 := f$g$safe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$4, + p$target) } else { - var anonymous$5: Ref - anonymous$5 := pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(local$arr, - dom$RuntimeType$intToRef(0), local0$mid) - ret$0 := global$fun_safe_binary_search$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Boolean(anonymous$5, - local$target) + var a$5: Ref + a$5 := f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(p$arr, + DF$RT$intToRef(0), l0$mid) + r$0 := f$g$safe_binary_search$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(a$5, + p$target) } } } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 -method pkg$kotlin$collections$class_List$fun_subList$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$return$T_class_pkg$kotlin$collections$global$class_List(this: Ref, - local$fromIndex: Ref, local$toIndex: Ref) +method f$pkg_kotlin_collections$c$List$subList$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int(this: Ref, + p$fromIndex: Ref, p$toIndex: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$fromIndex) <= - dom$RuntimeType$intFromRef(local$toIndex) - requires dom$RuntimeType$intFromRef(local$fromIndex) >= 0 - requires dom$RuntimeType$intFromRef(local$toIndex) <= - dom$RuntimeType$intFromRef(this.special$size) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$intFromRef(ret.special$size) == - dom$RuntimeType$intFromRef(local$toIndex) - - dom$RuntimeType$intFromRef(local$fromIndex) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$fromIndex) <= DF$RT$intFromRef(p$toIndex) + requires DF$RT$intFromRef(p$fromIndex) >= 0 + requires DF$RT$intFromRef(p$toIndex) <= DF$RT$intFromRef(this.sp$size) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$intFromRef(ret.sp$size) == + DF$RT$intFromRef(p$toIndex) - DF$RT$intFromRef(p$fromIndex) /binary_search.kt:(537,563): info: Generated Viper text for unsafe_binary_search_fixed: -field special$size: Ref +field sp$size: Ref -method global$fun_unsafe_binary_search_fixed$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr: Ref, - local$target: Ref, local$left: Ref, local$right: Ref) - returns (ret$0: Ref) - requires acc(local$arr.special$size, write) - requires dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures acc(local$arr.special$size, write) - ensures dom$RuntimeType$intFromRef(local$arr.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$unsafe_binary_search_fixed$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr: Ref, + p$target: Ref, p$left: Ref, p$right: Ref) + returns (r$0: Ref) + requires acc(p$arr.sp$size, write) + requires DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures acc(p$arr.sp$size, write) + ensures DF$RT$intFromRef(p$arr.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var local0$mid: Ref - var anonymous$3: Ref - var anonymous$4: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arr), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$arr), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$target), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$left), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$right), dom$RuntimeType$intType()) - if (dom$RuntimeType$intFromRef(local$left) > - dom$RuntimeType$intFromRef(local$right)) { - anonymous$1 := dom$RuntimeType$boolToRef(true) + var a$0: Ref + var a$1: Ref + var l0$mid: Ref + var a$3: Ref + var a$4: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arr), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$arr), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$target), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$left), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$right), DF$RT$intType()) + if (DF$RT$intFromRef(p$left) > DF$RT$intFromRef(p$right)) { + a$1 := DF$RT$boolToRef(true) } else { - anonymous$1 := special$ltInts(local$left, dom$RuntimeType$intToRef(0))} - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - anonymous$0 := dom$RuntimeType$boolToRef(true) + a$1 := sp$ltInts(p$left, DF$RT$intToRef(0))} + if (DF$RT$boolFromRef(a$1)) { + a$0 := DF$RT$boolToRef(true) } else { - var anonymous$2: Ref - anonymous$2 := local$arr.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$0 := special$geInts(local$right, anonymous$2) + var a$2: Ref + a$2 := p$arr.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$0 := sp$geInts(p$right, a$2) } - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 + if (DF$RT$boolFromRef(a$0)) { + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 } inhale 2 != 0 - anonymous$3 := special$divInts(special$minusInts(local$right, local$left), - dom$RuntimeType$intToRef(2)) - local0$mid := special$plusInts(local$left, anonymous$3) - anonymous$4 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$4) == - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := dom$RuntimeType$boolToRef(true) + a$3 := sp$divInts(sp$minusInts(p$right, p$left), DF$RT$intToRef(2)) + l0$mid := sp$plusInts(p$left, a$3) + a$4 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$4) == DF$RT$intFromRef(p$target)) { + r$0 := DF$RT$boolToRef(true) } else { - var anonymous$5: Ref - anonymous$5 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$arr, - local0$mid) - if (dom$RuntimeType$intFromRef(anonymous$5) < - dom$RuntimeType$intFromRef(local$target)) { - ret$0 := global$fun_unsafe_binary_search_fixed$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr, - local$target, special$plusInts(local0$mid, dom$RuntimeType$intToRef(1)), - local$right) + var a$5: Ref + a$5 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$arr, + l0$mid) + if (DF$RT$intFromRef(a$5) < DF$RT$intFromRef(p$target)) { + r$0 := f$g$unsafe_binary_search_fixed$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr, + p$target, sp$plusInts(l0$mid, DF$RT$intToRef(1)), p$right) } else { - ret$0 := global$fun_unsafe_binary_search_fixed$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$T_Int$T_Int$return$T_Boolean(local$arr, - local$target, local$left, special$minusInts(local0$mid, dom$RuntimeType$intToRef(1)))} + r$0 := f$g$unsafe_binary_search_fixed$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int$T$Int$T$Int(p$arr, + p$target, p$left, sp$minusInts(l0$mid, DF$RT$intToRef(1)))} } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/custom_list.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/custom_list.fir.diag.txt index cb016b829fcf75..61b8256deeb88f 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/custom_list.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/custom_list.fir.diag.txt @@ -1,97 +1,88 @@ /custom_list.kt:(168,171): info: Generated Viper text for get: -field class_CustomList_private$backing_field_value: Ref +field bf$c$CustomList_private$value: Ref -field special$size: Ref +field sp$size: Ref -method class_CustomList$fun_get$fun_take$T_class_global$class_CustomList$T_Int$return$T_Int(this: Ref, - local$index: Ref) - returns (ret$0: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) +method f$c$CustomList$get$TF$T$class_c$g$CustomList$T$Int(this: Ref, p$index: Ref) + returns (r$0: Ref) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_CustomList()) - inhale acc(T_class_global$class_CustomList(this), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$index), dom$RuntimeType$intType()) - unfold acc(T_class_global$class_CustomList(this), wildcard) - ret$0 := this.class_CustomList_private$backing_field_value - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$CustomList()) + inhale acc(T$class_c$g$CustomList(this), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$index), DF$RT$intType()) + unfold acc(T$class_c$g$CustomList(this), wildcard) + r$0 := this.bf$c$CustomList_private$value + goto lbl$ret$0 + label lbl$ret$0 } /custom_list.kt:(248,252): info: Generated Viper text for test: -field class_CustomList_private$backing_field_value: Ref +field bf$c$CustomList_private$value: Ref -field special$size: Ref +field sp$size: Ref -method class_CustomList$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_CustomList(local$size: Ref, - local$value: Ref) +method con$c$CustomList$T$Int$T$Int(p$size: Ref, p$value: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_CustomList()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_global$class_CustomList(ret), wildcard) - ensures acc(Unique$T_class_global$class_CustomList(ret), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$CustomList()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$g$CustomList(ret), wildcard) + ensures acc(U$T$class_c$g$CustomList(ret), write) -method class_CustomList$fun_get$fun_take$T_class_global$class_CustomList$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$c$CustomList$get$TF$T$class_c$g$CustomList$T$Int(this: Ref, p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) -method class_CustomList$fun_isEmpty$fun_take$T_class_global$class_CustomList$return$T_Boolean(this: Ref) +method f$c$CustomList$isEmpty$TF$T$class_c$g$CustomList(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 -method global$fun_test$fun_take$T_Int$return$T_Unit(local$n: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$test$TF$T$Int(p$n: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$customList: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$n), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$customList := class_CustomList$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_CustomList(local$n, - dom$RuntimeType$intToRef(0)) - anonymous$0 := class_CustomList$fun_isEmpty$fun_take$T_class_global$class_CustomList$return$T_Boolean(local0$customList) - if (!dom$RuntimeType$boolFromRef(anonymous$0)) { - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - anonymous$2 := local0$customList.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$1 := class_CustomList$fun_get$fun_take$T_class_global$class_CustomList$T_Int$return$T_Int(local0$customList, - special$minusInts(anonymous$2, dom$RuntimeType$intToRef(1))) - anonymous$3 := class_CustomList$fun_get$fun_take$T_class_global$class_CustomList$T_Int$return$T_Int(local0$customList, - dom$RuntimeType$intToRef(0)) + var l0$customList: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$n), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$customList := con$c$CustomList$T$Int$T$Int(p$n, DF$RT$intToRef(0)) + a$0 := f$c$CustomList$isEmpty$TF$T$class_c$g$CustomList(l0$customList) + if (!DF$RT$boolFromRef(a$0)) { + var a$1: Ref + var a$2: Ref + var a$3: Ref + a$2 := l0$customList.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$1 := f$c$CustomList$get$TF$T$class_c$g$CustomList$T$Int(l0$customList, + sp$minusInts(a$2, DF$RT$intToRef(1))) + a$3 := f$c$CustomList$get$TF$T$class_c$g$CustomList$T$Int(l0$customList, + DF$RT$intToRef(0)) } - label label$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/custom_run_functions.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/custom_run_functions.fir.diag.txt index 437dfcc193bfd9..1a2499abef9763 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/custom_run_functions.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/custom_run_functions.fir.diag.txt @@ -1,508 +1,488 @@ /custom_run_functions.kt:(1058,1064): info: Generated Viper text for useRun: -method global$fun_useRun$fun_take$$return$T_Boolean() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$useRun$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var local0$one: Ref - var local0$two: Ref - var local0$three: Ref - var local0$genericResult: Ref - var anonymous$9: Ref - var ret$1: Ref - var anonymous$10: Ref - var ret$2: Ref - var anonymous$11: Ref - var ret$3: Ref - var anonymous$12: Ref - var ret$4: Ref - var anonymous$13: Ref - var ret$5: Ref - var anonymous$14: Ref - var ret$6: Ref - var local0$capturedResult: Ref - var anonymous$15: Ref - var ret$7: Ref - var anonymous$16: Ref - var ret$8: Ref - var anonymous$17: Ref - var ret$9: Ref - var anonymous$18: Ref - var ret$10: Ref - var anonymous$19: Ref - var ret$11: Ref - var anonymous$20: Ref - var ret$12: Ref - var local0$intResult: Ref - var anonymous$21: Ref - var ret$13: Ref - var ret$14: Ref - var anonymous$22: Ref - var ret$15: Ref - var ret$16: Ref - var anonymous$23: Ref - var ret$17: Ref - var ret$18: Ref - var local0$doubleIntRunResult: Ref - var anonymous$24: Ref - var ret$19: Ref - var anonymous$0: Ref - var ret$21: Ref - var anonymous$1: Ref - var ret$20: Ref - var local0$genericReceiverResult: Ref - var anonymous$25: Ref - var ret$22: Ref - var anonymous$2: Ref - var anonymous$26: Ref - var ret$23: Ref - var anonymous$27: Ref - var anonymous$28: Ref - var anonymous$29: Ref - var anonymous$30: Ref - var anonymous$31: Ref - var anonymous$32: Ref - var anonymous$33: Ref - var anonymous$34: Ref - var anonymous$35: Ref - var anonymous$36: Ref - local0$one := dom$RuntimeType$intToRef(1) - local0$two := dom$RuntimeType$intToRef(2) - local0$three := dom$RuntimeType$intToRef(3) - ret$2 := dom$RuntimeType$intToRef(1) - goto label$ret$2 - label label$ret$2 - anonymous$10 := ret$2 - ret$1 := anonymous$10 - goto label$ret$1 - label label$ret$1 - anonymous$9 := ret$1 - ret$4 := dom$RuntimeType$intToRef(2) - goto label$ret$4 - label label$ret$4 - anonymous$12 := ret$4 - ret$3 := anonymous$12 - goto label$ret$3 - label label$ret$3 - anonymous$11 := ret$3 - ret$6 := dom$RuntimeType$intToRef(3) - goto label$ret$6 - label label$ret$6 - anonymous$14 := ret$6 - ret$5 := anonymous$14 - goto label$ret$5 - label label$ret$5 - anonymous$13 := ret$5 - local0$genericResult := dom$RuntimeType$boolToRef(special$plusInts(anonymous$9, - anonymous$11) == - anonymous$13) - ret$8 := dom$RuntimeType$intToRef(1) - goto label$ret$8 - label label$ret$8 - anonymous$16 := ret$8 - ret$7 := anonymous$16 - goto label$ret$7 - label label$ret$7 - anonymous$15 := ret$7 - ret$10 := dom$RuntimeType$intToRef(2) - goto label$ret$10 - label label$ret$10 - anonymous$18 := ret$10 - ret$9 := anonymous$18 - goto label$ret$9 - label label$ret$9 - anonymous$17 := ret$9 - ret$12 := dom$RuntimeType$intToRef(3) - goto label$ret$12 - label label$ret$12 - anonymous$20 := ret$12 - ret$11 := anonymous$20 - goto label$ret$11 - label label$ret$11 - anonymous$19 := ret$11 - local0$capturedResult := dom$RuntimeType$boolToRef(special$plusInts(anonymous$15, - anonymous$17) == - anonymous$19) - ret$14 := dom$RuntimeType$intToRef(1) - goto label$ret$14 - label label$ret$14 - ret$13 := ret$14 - goto label$ret$13 - label label$ret$13 - anonymous$21 := ret$13 - ret$16 := dom$RuntimeType$intToRef(2) - goto label$ret$16 - label label$ret$16 - ret$15 := ret$16 - goto label$ret$15 - label label$ret$15 - anonymous$22 := ret$15 - ret$18 := dom$RuntimeType$intToRef(3) - goto label$ret$18 - label label$ret$18 - ret$17 := ret$18 - goto label$ret$17 - label label$ret$17 - anonymous$23 := ret$17 - local0$intResult := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(anonymous$21) + - dom$RuntimeType$intFromRef(anonymous$22) == - dom$RuntimeType$intFromRef(anonymous$23)) - anonymous$0 := dom$RuntimeType$intToRef(1) - ret$20 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - goto label$ret$20 - label label$ret$20 - anonymous$1 := ret$20 - ret$21 := special$plusInts(anonymous$1, dom$RuntimeType$intToRef(1)) - goto label$ret$21 - label label$ret$21 - ret$19 := ret$21 - goto label$ret$19 - label label$ret$19 - anonymous$24 := ret$19 - local0$doubleIntRunResult := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(anonymous$24) == - 3) - anonymous$2 := dom$RuntimeType$intToRef(1) - ret$23 := special$plusInts(anonymous$2, dom$RuntimeType$intToRef(2)) - goto label$ret$23 - label label$ret$23 - anonymous$26 := ret$23 - ret$22 := anonymous$26 - goto label$ret$22 - label label$ret$22 - anonymous$25 := ret$22 - local0$genericReceiverResult := dom$RuntimeType$boolToRef(anonymous$25 == - dom$RuntimeType$intToRef(3)) - if (dom$RuntimeType$boolFromRef(local0$intResult)) { - anonymous$36 := local0$genericResult + var l0$one: Ref + var l0$two: Ref + var l0$three: Ref + var l0$genericResult: Ref + var a$9: Ref + var r$1: Ref + var a$10: Ref + var r$2: Ref + var a$11: Ref + var r$3: Ref + var a$12: Ref + var r$4: Ref + var a$13: Ref + var r$5: Ref + var a$14: Ref + var r$6: Ref + var l0$capturedResult: Ref + var a$15: Ref + var r$7: Ref + var a$16: Ref + var r$8: Ref + var a$17: Ref + var r$9: Ref + var a$18: Ref + var r$10: Ref + var a$19: Ref + var r$11: Ref + var a$20: Ref + var r$12: Ref + var l0$intResult: Ref + var a$21: Ref + var r$13: Ref + var r$14: Ref + var a$22: Ref + var r$15: Ref + var r$16: Ref + var a$23: Ref + var r$17: Ref + var r$18: Ref + var l0$doubleIntRunResult: Ref + var a$24: Ref + var r$19: Ref + var a$0: Ref + var r$21: Ref + var a$1: Ref + var r$20: Ref + var l0$genericReceiverResult: Ref + var a$25: Ref + var r$22: Ref + var a$2: Ref + var a$26: Ref + var r$23: Ref + var a$27: Ref + var a$28: Ref + var a$29: Ref + var a$30: Ref + var a$31: Ref + var a$32: Ref + var a$33: Ref + var a$34: Ref + var a$35: Ref + var a$36: Ref + l0$one := DF$RT$intToRef(1) + l0$two := DF$RT$intToRef(2) + l0$three := DF$RT$intToRef(3) + r$2 := DF$RT$intToRef(1) + goto lbl$ret$2 + label lbl$ret$2 + a$10 := r$2 + r$1 := a$10 + goto lbl$ret$1 + label lbl$ret$1 + a$9 := r$1 + r$4 := DF$RT$intToRef(2) + goto lbl$ret$4 + label lbl$ret$4 + a$12 := r$4 + r$3 := a$12 + goto lbl$ret$3 + label lbl$ret$3 + a$11 := r$3 + r$6 := DF$RT$intToRef(3) + goto lbl$ret$6 + label lbl$ret$6 + a$14 := r$6 + r$5 := a$14 + goto lbl$ret$5 + label lbl$ret$5 + a$13 := r$5 + l0$genericResult := DF$RT$boolToRef(sp$plusInts(a$9, a$11) == a$13) + r$8 := DF$RT$intToRef(1) + goto lbl$ret$8 + label lbl$ret$8 + a$16 := r$8 + r$7 := a$16 + goto lbl$ret$7 + label lbl$ret$7 + a$15 := r$7 + r$10 := DF$RT$intToRef(2) + goto lbl$ret$10 + label lbl$ret$10 + a$18 := r$10 + r$9 := a$18 + goto lbl$ret$9 + label lbl$ret$9 + a$17 := r$9 + r$12 := DF$RT$intToRef(3) + goto lbl$ret$12 + label lbl$ret$12 + a$20 := r$12 + r$11 := a$20 + goto lbl$ret$11 + label lbl$ret$11 + a$19 := r$11 + l0$capturedResult := DF$RT$boolToRef(sp$plusInts(a$15, a$17) == a$19) + r$14 := DF$RT$intToRef(1) + goto lbl$ret$14 + label lbl$ret$14 + r$13 := r$14 + goto lbl$ret$13 + label lbl$ret$13 + a$21 := r$13 + r$16 := DF$RT$intToRef(2) + goto lbl$ret$16 + label lbl$ret$16 + r$15 := r$16 + goto lbl$ret$15 + label lbl$ret$15 + a$22 := r$15 + r$18 := DF$RT$intToRef(3) + goto lbl$ret$18 + label lbl$ret$18 + r$17 := r$18 + goto lbl$ret$17 + label lbl$ret$17 + a$23 := r$17 + l0$intResult := DF$RT$boolToRef(DF$RT$intFromRef(a$21) + + DF$RT$intFromRef(a$22) == + DF$RT$intFromRef(a$23)) + a$0 := DF$RT$intToRef(1) + r$20 := sp$plusInts(a$0, DF$RT$intToRef(1)) + goto lbl$ret$20 + label lbl$ret$20 + a$1 := r$20 + r$21 := sp$plusInts(a$1, DF$RT$intToRef(1)) + goto lbl$ret$21 + label lbl$ret$21 + r$19 := r$21 + goto lbl$ret$19 + label lbl$ret$19 + a$24 := r$19 + l0$doubleIntRunResult := DF$RT$boolToRef(DF$RT$intFromRef(a$24) == 3) + a$2 := DF$RT$intToRef(1) + r$23 := sp$plusInts(a$2, DF$RT$intToRef(2)) + goto lbl$ret$23 + label lbl$ret$23 + a$26 := r$23 + r$22 := a$26 + goto lbl$ret$22 + label lbl$ret$22 + a$25 := r$22 + l0$genericReceiverResult := DF$RT$boolToRef(a$25 == DF$RT$intToRef(3)) + if (DF$RT$boolFromRef(l0$intResult)) { + a$36 := l0$genericResult } else { - anonymous$36 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$36)) { - anonymous$35 := local0$capturedResult + a$36 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$36)) { + a$35 := l0$capturedResult } else { - anonymous$35 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$35)) { - var ret$24: Ref - var local24$result: Ref - var ret$25: Ref - ret$25 := special$plusInts(dom$RuntimeType$intToRef(1), dom$RuntimeType$intToRef(2)) - goto label$ret$25 - label label$ret$25 - local24$result := ret$25 - ret$24 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local24$result) == - 3) - goto label$ret$24 - label label$ret$24 - anonymous$34 := ret$24 + a$35 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$35)) { + var r$24: Ref + var l24$result: Ref + var r$25: Ref + r$25 := sp$plusInts(DF$RT$intToRef(1), DF$RT$intToRef(2)) + goto lbl$ret$25 + label lbl$ret$25 + l24$result := r$25 + r$24 := DF$RT$boolToRef(DF$RT$intFromRef(l24$result) == 3) + goto lbl$ret$24 + label lbl$ret$24 + a$34 := r$24 } else { - anonymous$34 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$34)) { - var anonymous$37: Ref - var ret$26: Ref - var local26$result: Ref - var ret$27: Ref - ret$27 := dom$RuntimeType$intToRef(4) - goto label$ret$27 - label label$ret$27 - local26$result := ret$27 - ret$26 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local26$result) == - 3) - goto label$ret$26 - label label$ret$26 - anonymous$37 := ret$26 - anonymous$33 := special$notBool(anonymous$37) + a$34 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$34)) { + var a$37: Ref + var r$26: Ref + var l26$result: Ref + var r$27: Ref + r$27 := DF$RT$intToRef(4) + goto lbl$ret$27 + label lbl$ret$27 + l26$result := r$27 + r$26 := DF$RT$boolToRef(DF$RT$intFromRef(l26$result) == 3) + goto lbl$ret$26 + label lbl$ret$26 + a$37 := r$26 + a$33 := sp$notBool(a$37) } else { - anonymous$33 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$33)) { - var ret$28: Ref - var local28$result: Ref - var ret$29: Ref - var anonymous$3: Ref - anonymous$3 := dom$RuntimeType$intToRef(1) - ret$29 := special$plusInts(anonymous$3, dom$RuntimeType$intToRef(2)) - goto label$ret$29 - label label$ret$29 - local28$result := ret$29 - ret$28 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local28$result) == - 3) - goto label$ret$28 - label label$ret$28 - anonymous$32 := ret$28 + a$33 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$33)) { + var r$28: Ref + var l28$result: Ref + var r$29: Ref + var a$3: Ref + a$3 := DF$RT$intToRef(1) + r$29 := sp$plusInts(a$3, DF$RT$intToRef(2)) + goto lbl$ret$29 + label lbl$ret$29 + l28$result := r$29 + r$28 := DF$RT$boolToRef(DF$RT$intFromRef(l28$result) == 3) + goto lbl$ret$28 + label lbl$ret$28 + a$32 := r$28 } else { - anonymous$32 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$32)) { - var anonymous$38: Ref - var ret$30: Ref - var local30$result: Ref - var ret$31: Ref - var anonymous$4: Ref - anonymous$4 := dom$RuntimeType$intToRef(1) - ret$31 := anonymous$4 - goto label$ret$31 - label label$ret$31 - local30$result := ret$31 - ret$30 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local30$result) == - 3) - goto label$ret$30 - label label$ret$30 - anonymous$38 := ret$30 - anonymous$31 := special$notBool(anonymous$38) + a$32 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$32)) { + var a$38: Ref + var r$30: Ref + var l30$result: Ref + var r$31: Ref + var a$4: Ref + a$4 := DF$RT$intToRef(1) + r$31 := a$4 + goto lbl$ret$31 + label lbl$ret$31 + l30$result := r$31 + r$30 := DF$RT$boolToRef(DF$RT$intFromRef(l30$result) == 3) + goto lbl$ret$30 + label lbl$ret$30 + a$38 := r$30 + a$31 := sp$notBool(a$38) } else { - anonymous$31 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$31)) { - var ret$32: Ref - var local32$result: Ref - var ret$33: Ref - var anonymous$5: Ref - anonymous$5 := dom$RuntimeType$intToRef(1) - ret$33 := special$plusInts(anonymous$5, dom$RuntimeType$intToRef(2)) - goto label$ret$33 - label label$ret$33 - local32$result := ret$33 - ret$32 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local32$result) == - 3) - goto label$ret$32 - label label$ret$32 - anonymous$30 := ret$32 + a$31 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$31)) { + var r$32: Ref + var l32$result: Ref + var r$33: Ref + var a$5: Ref + a$5 := DF$RT$intToRef(1) + r$33 := sp$plusInts(a$5, DF$RT$intToRef(2)) + goto lbl$ret$33 + label lbl$ret$33 + l32$result := r$33 + r$32 := DF$RT$boolToRef(DF$RT$intFromRef(l32$result) == 3) + goto lbl$ret$32 + label lbl$ret$32 + a$30 := r$32 } else { - anonymous$30 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$30)) { - var ret$34: Ref - var local34$result: Ref - var ret$35: Ref - var anonymous$6: Ref - anonymous$6 := dom$RuntimeType$intToRef(1) - ret$35 := special$plusInts(anonymous$6, dom$RuntimeType$intToRef(2)) - goto label$ret$35 - label label$ret$35 - local34$result := ret$35 - ret$34 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local34$result) == - 3) - goto label$ret$34 - label label$ret$34 - anonymous$29 := ret$34 + a$30 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$30)) { + var r$34: Ref + var l34$result: Ref + var r$35: Ref + var a$6: Ref + a$6 := DF$RT$intToRef(1) + r$35 := sp$plusInts(a$6, DF$RT$intToRef(2)) + goto lbl$ret$35 + label lbl$ret$35 + l34$result := r$35 + r$34 := DF$RT$boolToRef(DF$RT$intFromRef(l34$result) == 3) + goto lbl$ret$34 + label lbl$ret$34 + a$29 := r$34 } else { - anonymous$29 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$29)) { - var ret$36: Ref - var local36$result: Ref - var ret$38: Ref - var anonymous$8: Ref - var ret$37: Ref - var anonymous$7: Ref - anonymous$7 := dom$RuntimeType$intToRef(1) - ret$37 := special$plusInts(anonymous$7, dom$RuntimeType$intToRef(1)) - goto label$ret$37 - label label$ret$37 - anonymous$8 := ret$37 - ret$38 := special$plusInts(anonymous$8, dom$RuntimeType$intToRef(1)) - goto label$ret$38 - label label$ret$38 - local36$result := ret$38 - ret$36 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local36$result) == - 3) - goto label$ret$36 - label label$ret$36 - anonymous$28 := ret$36 + a$29 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$29)) { + var r$36: Ref + var l36$result: Ref + var r$38: Ref + var a$8: Ref + var r$37: Ref + var a$7: Ref + a$7 := DF$RT$intToRef(1) + r$37 := sp$plusInts(a$7, DF$RT$intToRef(1)) + goto lbl$ret$37 + label lbl$ret$37 + a$8 := r$37 + r$38 := sp$plusInts(a$8, DF$RT$intToRef(1)) + goto lbl$ret$38 + label lbl$ret$38 + l36$result := r$38 + r$36 := DF$RT$boolToRef(DF$RT$intFromRef(l36$result) == 3) + goto lbl$ret$36 + label lbl$ret$36 + a$28 := r$36 } else { - anonymous$28 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$28)) { - anonymous$27 := local0$doubleIntRunResult + a$28 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$28)) { + a$27 := l0$doubleIntRunResult } else { - anonymous$27 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$27)) { - ret$0 := local0$genericReceiverResult + a$27 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$27)) { + r$0 := l0$genericReceiverResult } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } /custom_run_functions.kt:(2226,2241): info: Generated Viper text for complexScenario: -method global$fun_complexScenario$fun_take$T_Boolean$return$T_Boolean(local$arg: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - dom$RuntimeType$boolFromRef(local$arg) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - !dom$RuntimeType$boolFromRef(local$arg) +method f$g$complexScenario$TF$T$Boolean(p$arg: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> DF$RT$boolFromRef(p$arg) + ensures DF$RT$boolFromRef(r$0) == false ==> !DF$RT$boolFromRef(p$arg) { - var anonymous$5: Ref - var ret$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$arg), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$arg)) { - var anonymous$6: Ref - var ret$2: Ref - var anonymous$7: Ref - var ret$3: Ref - var local5$result: Ref - var ret$4: Ref - var anonymous$0: Ref - var anonymous$8: Ref - var ret$5: Ref - var anonymous$9: Ref - var ret$6: Ref - var ret$7: Ref - var ret$9: Ref - var anonymous$1: Ref - var ret$8: Ref - anonymous$0 := dom$RuntimeType$intToRef(1) - ret$8 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - goto label$ret$8 - label label$ret$8 - anonymous$1 := ret$8 - ret$9 := special$plusInts(anonymous$1, dom$RuntimeType$intToRef(1)) - goto label$ret$9 - label label$ret$9 - ret$7 := ret$9 - goto label$ret$7 - label label$ret$7 - ret$6 := ret$7 - goto label$ret$6 - label label$ret$6 - anonymous$9 := ret$6 - ret$5 := anonymous$9 - goto label$ret$5 - label label$ret$5 - anonymous$8 := ret$5 - ret$4 := anonymous$8 - goto label$ret$4 - label label$ret$4 - local5$result := ret$4 - ret$3 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local5$result) == - 3) - goto label$ret$3 - label label$ret$3 - anonymous$7 := ret$3 - ret$2 := anonymous$7 - goto label$ret$2 - label label$ret$2 - anonymous$6 := ret$2 - ret$1 := anonymous$6 + var a$5: Ref + var r$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$arg), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$arg)) { + var a$6: Ref + var r$2: Ref + var a$7: Ref + var r$3: Ref + var l5$result: Ref + var r$4: Ref + var a$0: Ref + var a$8: Ref + var r$5: Ref + var a$9: Ref + var r$6: Ref + var r$7: Ref + var r$9: Ref + var a$1: Ref + var r$8: Ref + a$0 := DF$RT$intToRef(1) + r$8 := sp$plusInts(a$0, DF$RT$intToRef(1)) + goto lbl$ret$8 + label lbl$ret$8 + a$1 := r$8 + r$9 := sp$plusInts(a$1, DF$RT$intToRef(1)) + goto lbl$ret$9 + label lbl$ret$9 + r$7 := r$9 + goto lbl$ret$7 + label lbl$ret$7 + r$6 := r$7 + goto lbl$ret$6 + label lbl$ret$6 + a$9 := r$6 + r$5 := a$9 + goto lbl$ret$5 + label lbl$ret$5 + a$8 := r$5 + r$4 := a$8 + goto lbl$ret$4 + label lbl$ret$4 + l5$result := r$4 + r$3 := DF$RT$boolToRef(DF$RT$intFromRef(l5$result) == 3) + goto lbl$ret$3 + label lbl$ret$3 + a$7 := r$3 + r$2 := a$7 + goto lbl$ret$2 + label lbl$ret$2 + a$6 := r$2 + r$1 := a$6 } else { - var anonymous$10: Ref - anonymous$10 := dom$RuntimeType$nullValue() - ret$1 := anonymous$10 + var a$10: Ref + a$10 := DF$RT$nullValue() + r$1 := a$10 } - goto label$ret$1 - label label$ret$1 - anonymous$5 := ret$1 - if (anonymous$5 != dom$RuntimeType$nullValue()) { - ret$0 := anonymous$5 + goto lbl$ret$1 + label lbl$ret$1 + a$5 := r$1 + if (a$5 != DF$RT$nullValue()) { + r$0 := a$5 } else { - var anonymous$11: Ref - var ret$10: Ref - var anonymous$12: Ref - var ret$11: Ref - var ret$12: Ref - var local15$result: Ref - var ret$13: Ref - var anonymous$2: Ref - var anonymous$13: Ref - var ret$14: Ref - var anonymous$14: Ref - var ret$15: Ref - var anonymous$15: Ref - var ret$16: Ref - var anonymous$3: Ref - var anonymous$16: Ref - var ret$17: Ref - var anonymous$17: Ref - var ret$18: Ref - var anonymous$4: Ref - var anonymous$18: Ref - var ret$19: Ref - anonymous$2 := dom$RuntimeType$intToRef(1) - anonymous$3 := special$plusInts(anonymous$2, dom$RuntimeType$intToRef(1)) - anonymous$4 := special$plusInts(anonymous$3, dom$RuntimeType$intToRef(1)) - ret$19 := special$plusInts(anonymous$4, dom$RuntimeType$intToRef(1)) - goto label$ret$19 - label label$ret$19 - anonymous$18 := ret$19 - ret$18 := anonymous$18 - goto label$ret$18 - label label$ret$18 - anonymous$17 := ret$18 - ret$17 := anonymous$17 - goto label$ret$17 - label label$ret$17 - anonymous$16 := ret$17 - ret$16 := anonymous$16 - goto label$ret$16 - label label$ret$16 - anonymous$15 := ret$16 - ret$15 := anonymous$15 - goto label$ret$15 - label label$ret$15 - anonymous$14 := ret$15 - ret$14 := anonymous$14 - goto label$ret$14 - label label$ret$14 - anonymous$13 := ret$14 - ret$13 := anonymous$13 - goto label$ret$13 - label label$ret$13 - local15$result := ret$13 - ret$12 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local15$result) == - 3) - goto label$ret$12 - label label$ret$12 - ret$11 := ret$12 - goto label$ret$11 - label label$ret$11 - anonymous$12 := ret$11 - ret$10 := anonymous$12 - goto label$ret$10 - label label$ret$10 - anonymous$11 := ret$10 - ret$0 := anonymous$11 + var a$11: Ref + var r$10: Ref + var a$12: Ref + var r$11: Ref + var r$12: Ref + var l15$result: Ref + var r$13: Ref + var a$2: Ref + var a$13: Ref + var r$14: Ref + var a$14: Ref + var r$15: Ref + var a$15: Ref + var r$16: Ref + var a$3: Ref + var a$16: Ref + var r$17: Ref + var a$17: Ref + var r$18: Ref + var a$4: Ref + var a$18: Ref + var r$19: Ref + a$2 := DF$RT$intToRef(1) + a$3 := sp$plusInts(a$2, DF$RT$intToRef(1)) + a$4 := sp$plusInts(a$3, DF$RT$intToRef(1)) + r$19 := sp$plusInts(a$4, DF$RT$intToRef(1)) + goto lbl$ret$19 + label lbl$ret$19 + a$18 := r$19 + r$18 := a$18 + goto lbl$ret$18 + label lbl$ret$18 + a$17 := r$18 + r$17 := a$17 + goto lbl$ret$17 + label lbl$ret$17 + a$16 := r$17 + r$16 := a$16 + goto lbl$ret$16 + label lbl$ret$16 + a$15 := r$16 + r$15 := a$15 + goto lbl$ret$15 + label lbl$ret$15 + a$14 := r$15 + r$14 := a$14 + goto lbl$ret$14 + label lbl$ret$14 + a$13 := r$14 + r$13 := a$13 + goto lbl$ret$13 + label lbl$ret$13 + l15$result := r$13 + r$12 := DF$RT$boolToRef(DF$RT$intFromRef(l15$result) == 3) + goto lbl$ret$12 + label lbl$ret$12 + r$11 := r$12 + goto lbl$ret$11 + label lbl$ret$11 + a$12 := r$11 + r$10 := a$12 + goto lbl$ret$10 + label lbl$ret$10 + a$11 := r$10 + r$0 := a$11 } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } /custom_run_functions.kt:(3305,3320): info: Generated Viper text for testCustomClass: -field public$backing_field_member: Ref +field bf$public$member: Ref -method class_CustomClass$constructor$fun_take$$return$T_class_global$class_CustomClass() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_CustomClass()) - ensures acc(T_class_global$class_CustomClass(ret), wildcard) - ensures acc(Unique$T_class_global$class_CustomClass(ret), write) +method con$c$CustomClass$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$CustomClass()) + ensures acc(T$class_c$g$CustomClass(ret), wildcard) + ensures acc(U$T$class_c$g$CustomClass(ret), write) -method global$fun_testCustomClass$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$testCustomClass$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var local0$custom: Ref - var anonymous$0: Ref - var ret$1: Ref - var anonymous$1: Ref - var ret$2: Ref - var anonymous$2: Ref - var ret$3: Ref - var anonymous$3: Ref - var ret$4: Ref - local0$custom := class_CustomClass$constructor$fun_take$$return$T_class_global$class_CustomClass() - unfold acc(T_class_global$class_CustomClass(local0$custom), wildcard) - ret$2 := local0$custom.public$backing_field_member - goto label$ret$2 - label label$ret$2 - anonymous$1 := ret$2 - ret$1 := anonymous$1 - goto label$ret$1 - label label$ret$1 - anonymous$0 := ret$1 - unfold acc(T_class_global$class_CustomClass(local0$custom), wildcard) - ret$4 := local0$custom.public$backing_field_member - goto label$ret$4 - label label$ret$4 - anonymous$3 := ret$4 - ret$3 := anonymous$3 - goto label$ret$3 - label label$ret$3 - anonymous$2 := ret$3 - ret$0 := dom$RuntimeType$boolToRef(anonymous$0 == anonymous$2) - goto label$ret$0 - label label$ret$0 + var l0$custom: Ref + var a$0: Ref + var r$1: Ref + var a$1: Ref + var r$2: Ref + var a$2: Ref + var r$3: Ref + var a$3: Ref + var r$4: Ref + l0$custom := con$c$CustomClass$() + unfold acc(T$class_c$g$CustomClass(l0$custom), wildcard) + r$2 := l0$custom.bf$public$member + goto lbl$ret$2 + label lbl$ret$2 + a$1 := r$2 + r$1 := a$1 + goto lbl$ret$1 + label lbl$ret$1 + a$0 := r$1 + unfold acc(T$class_c$g$CustomClass(l0$custom), wildcard) + r$4 := l0$custom.bf$public$member + goto lbl$ret$4 + label lbl$ret$4 + a$3 := r$4 + r$3 := a$3 + goto lbl$ret$3 + label lbl$ret$3 + a$2 := r$3 + r$0 := DF$RT$boolToRef(a$0 == a$2) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/inline_correctness.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/inline_correctness.fir.diag.txt index 2bdb847a61272b..1d136719e9f030 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/inline_correctness.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/inline_correctness.fir.diag.txt @@ -1,159 +1,153 @@ /inline_correctness.kt:(241,254): info: Generated Viper text for simple_return: -method global$fun_simple_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$simple_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - ret$2 := dom$RuntimeType$boolToRef(false) - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + r$2 := DF$RT$boolToRef(false) + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /inline_correctness.kt:(380,394): info: Generated Viper text for unnamed_return: -method global$fun_unnamed_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$unnamed_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - ret$2 := dom$RuntimeType$boolToRef(true) - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + r$2 := DF$RT$boolToRef(true) + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /inline_correctness.kt:(551,569): info: Generated Viper text for named_local_return: -method global$fun_named_local_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$named_local_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - ret$2 := dom$RuntimeType$boolToRef(false) - goto label$ret$2 - ret$2 := dom$RuntimeType$boolToRef(true) - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + r$2 := DF$RT$boolToRef(false) + goto lbl$ret$2 + r$2 := DF$RT$boolToRef(true) + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /inline_correctness.kt:(731,752): info: Generated Viper text for named_nonlocal_return: -method global$fun_named_nonlocal_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$named_nonlocal_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - ret$2 := dom$RuntimeType$boolToRef(true) - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + r$2 := DF$RT$boolToRef(true) + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /inline_correctness.kt:(931,953): info: Generated Viper text for double_nonlocal_return: -method global$fun_double_nonlocal_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$double_nonlocal_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - var local2$x: Ref - var ret$3: Ref - var anonymous$1: Ref - var ret$4: Ref - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - ret$4 := dom$RuntimeType$boolToRef(false) - goto label$ret$4 - label label$ret$4 - anonymous$1 := ret$4 - ret$3 := special$notBool(anonymous$1) - goto label$ret$3 - label label$ret$3 - local2$x := ret$3 - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - ret$2 := local2$x - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + var l2$x: Ref + var r$3: Ref + var a$1: Ref + var r$4: Ref + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + r$4 := DF$RT$boolToRef(false) + goto lbl$ret$4 + label lbl$ret$4 + a$1 := r$4 + r$3 := sp$notBool(a$1) + goto lbl$ret$3 + label lbl$ret$3 + l2$x := r$3 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + r$2 := l2$x + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /inline_correctness.kt:(1304,1332): info: Generated Viper text for named_double_nonlocal_return: -method global$fun_named_double_nonlocal_return$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$named_double_nonlocal_return$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var ret$1: Ref - var anonymous$0: Ref - var ret$2: Ref - var ret$3: Ref - var ret$4: Ref - ret$2 := dom$RuntimeType$boolToRef(false) - goto label$ret$2 - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$4 - ret$3 := ret$4 - goto label$ret$3 - label label$ret$3 - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - ret$2 := dom$RuntimeType$boolToRef(true) - goto label$ret$2 - label label$ret$2 - anonymous$0 := ret$2 - ret$1 := special$notBool(anonymous$0) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var a$0: Ref + var r$2: Ref + var r$3: Ref + var r$4: Ref + r$2 := DF$RT$boolToRef(false) + goto lbl$ret$2 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$4 + r$3 := r$4 + goto lbl$ret$3 + label lbl$ret$3 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + r$2 := DF$RT$boolToRef(true) + goto lbl$ret$2 + label lbl$ret$2 + a$0 := r$2 + r$1 := sp$notBool(a$0) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/is_type_contract.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/is_type_contract.fir.diag.txt index 7a20aa69906fdb..4490d468499063 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/is_type_contract.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/is_type_contract.fir.diag.txt @@ -1,110 +1,101 @@ /is_type_contract.kt:(157,165): info: Generated Viper text for isString: -field public$backing_field_length: Ref +field bf$public$length: Ref -method global$fun_isString$fun_take$NT_Any$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_pkg$kotlin$global$class_String()) +method f$g$isString$TF$Any(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> + DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$pkg_kotlin$g$String()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), - dom$RuntimeType$T_class_pkg$kotlin$global$class_String())) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$pkg_kotlin$g$String())) + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref) /is_type_contract.kt:(509,517): info: Generated Viper text for isString: -field public$backing_field_length: Ref +field bf$public$length: Ref -method global$fun_isString$fun_take$T_Any$return$T_Boolean(local$obj: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$T_class_pkg$kotlin$global$class_String()) +method f$g$isString$TF$T$Any(p$obj: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> + DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$pkg_kotlin$g$String()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$anyType()) - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), - dom$RuntimeType$T_class_pkg$kotlin$global$class_String())) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$anyType()) + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$pkg_kotlin$g$String())) + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref) /is_type_contract.kt:(675,692): info: Generated Viper text for subtypeTransitive: -method global$fun_subtypeTransitive$fun_take$T_Unit$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$subtypeTransitive$TF$T$Unit(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) ensures true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) + DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$unitType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$unitType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /is_type_contract.kt:(870,891): info: Generated Viper text for constructorReturnType: -field public$backing_field_bar: Ref +field bf$public$bar: Ref -method class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Foo()) - ensures acc(T_class_global$class_Foo(ret), wildcard) - ensures acc(Unique$T_class_global$class_Foo(ret), write) +method con$c$Foo$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Foo()) + ensures acc(T$class_c$g$Foo(ret), wildcard) + ensures acc(U$T$class_c$g$Foo(ret), write) -method global$fun_constructorReturnType$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$constructorReturnType$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var anonymous$0: Ref - anonymous$0 := class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), - dom$RuntimeType$T_class_global$class_Foo())) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + a$0 := con$c$Foo$() + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$T$class_c$g$Foo())) + goto lbl$ret$0 + label lbl$ret$0 } /is_type_contract.kt:(1016,1032): info: Generated Viper text for subtypeSuperType: -field public$backing_field_bar: Ref +field bf$public$bar: Ref -method global$fun_subtypeSuperType$fun_take$T_class_global$class_Bar$return$T_Unit(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$subtypeSuperType$TF$T$class_c$g$Bar(p$bar: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) ensures true ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Foo()) + DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Foo()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /is_type_contract.kt:(1149,1160): info: Generated Viper text for typeOfField: -field public$backing_field_bar: Ref +field bf$public$bar: Ref -method global$fun_typeOfField$fun_take$T_class_global$class_Foo$return$T_Boolean(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$typeOfField$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - unfold acc(T_class_global$class_Foo(local$foo), wildcard) - anonymous$0 := local$foo.public$backing_field_bar - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$T_class_global$class_Bar())) { - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + unfold acc(T$class_c$g$Foo(p$foo), wildcard) + a$0 := p$foo.bf$public$bar + if (DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$T$class_c$g$Bar())) { + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/list.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/list.fir.diag.txt index 9327ee543a747d..bc4be09f919463 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/list.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/list.fir.diag.txt @@ -1,257 +1,243 @@ /list.kt:(77,88): info: Generated Viper text for declaration: -field special$size: Ref +field sp$size: Ref -method global$fun_declaration$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$declaration$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$l1: Ref - var local0$l2: Ref - var local0$l3: Ref - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + var l0$l1: Ref + var l0$l2: Ref + var l0$l3: Ref + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /list.kt:(187,201): info: Generated Viper text for initialization: -field special$size: Ref - -method global$fun_initialization$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Unit(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +field sp$size: Ref + +method f$g$initialization$TF$T$class_c$pkg_kotlin_collections$g$List(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$myList: Ref - var local0$myEmptyList: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$l), wildcard) - ret$0 := dom$RuntimeType$unitValue() - local0$myList := local$l - local0$myEmptyList := pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - label label$ret$0 + var l0$myList: Ref + var l0$myEmptyList: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$l), wildcard) + r$0 := DF$RT$unitValue() + l0$myList := p$l + l0$myEmptyList := f$pkg_kotlin_collections$g$emptyList$TF$() + label lbl$ret$0 } -method pkg$kotlin$collections$global$fun_emptyList$fun_take$$return$T_class_pkg$kotlin$collections$global$class_List() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - ensures acc(ret.special$size, write) - ensures dom$RuntimeType$intFromRef(ret.special$size) >= 0 - ensures acc(T_class_pkg$kotlin$collections$global$class_List(ret), wildcard) - ensures dom$RuntimeType$intFromRef(ret.special$size) == 0 +method f$pkg_kotlin_collections$g$emptyList$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + ensures acc(ret.sp$size, write) + ensures DF$RT$intFromRef(ret.sp$size) >= 0 + ensures acc(T$class_c$pkg_kotlin_collections$g$List(ret), wildcard) + ensures DF$RT$intFromRef(ret.sp$size) == 0 /list.kt:(297,304): info: Generated Viper text for add_get: -field special$size: Ref - -method global$fun_add_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$return$T_Unit(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +field sp$size: Ref + +method f$g$add_get$TF$T$class_c$pkg_kotlin_collections$g$MutableList(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var local0$n: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_MutableList()) - inhale acc(T_class_pkg$kotlin$collections$global$class_MutableList(local$l), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := pkg$kotlin$collections$class_MutableList$fun_add$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Boolean(local$l, - dom$RuntimeType$intToRef(1)) - local0$n := pkg$kotlin$collections$class_MutableList$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Int(local$l, - dom$RuntimeType$intToRef(0)) - label label$ret$0 + var a$0: Ref + var l0$n: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$MutableList()) + inhale acc(T$class_c$pkg_kotlin_collections$g$MutableList(p$l), wildcard) + r$0 := DF$RT$unitValue() + a$0 := f$pkg_kotlin_collections$c$MutableList$add$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(p$l, + DF$RT$intToRef(1)) + l0$n := f$pkg_kotlin_collections$c$MutableList$get$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(p$l, + DF$RT$intToRef(0)) + label lbl$ret$0 } -method pkg$kotlin$collections$class_MutableList$fun_add$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Boolean(this: Ref, - local$element: Ref) +method f$pkg_kotlin_collections$c$MutableList$add$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(this: Ref, + p$element: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + 1 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + 1 -method pkg$kotlin$collections$class_MutableList$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$MutableList$get$TF$T$class_c$pkg_kotlin_collections$g$MutableList$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) /list.kt:(379,391): info: Generated Viper text for last_or_null: -field special$size: Ref - -method global$fun_last_or_null$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$NT_Int(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +field sp$size: Ref + +method f$g$last_or_null$TF$T$class_c$pkg_kotlin_collections$g$List(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - var local0$size: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$l), wildcard) - local0$size := local$l.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$size), dom$RuntimeType$intType()) - if (!(dom$RuntimeType$intFromRef(local0$size) == 0)) { - var anonymous$0: Ref - anonymous$0 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$l, - special$minusInts(local0$size, dom$RuntimeType$intToRef(1))) - ret$0 := anonymous$0 - goto label$ret$0 + var l0$size: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$l), wildcard) + l0$size := p$l.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$size), DF$RT$intType()) + if (!(DF$RT$intFromRef(l0$size) == 0)) { + var a$0: Ref + a$0 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$l, + sp$minusInts(l0$size, DF$RT$intToRef(1))) + r$0 := a$0 + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 + r$0 := DF$RT$nullValue() + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) /list.kt:(545,553): info: Generated Viper text for is_empty: -field special$size: Ref - -method global$fun_is_empty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Int(local$l: Ref) - returns (ret$0: Ref) - requires acc(local$l.special$size, write) - requires dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures acc(local$l.special$size, write) - ensures dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +field sp$size: Ref + +method f$g$is_empty$TF$T$class_c$pkg_kotlin_collections$g$List(p$l: Ref) + returns (r$0: Ref) + requires acc(p$l.sp$size, write) + requires DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures acc(p$l.sp$size, write) + ensures DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List()) - inhale acc(T_class_pkg$kotlin$collections$global$class_List(local$l), wildcard) - anonymous$0 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$l) - if (!dom$RuntimeType$boolFromRef(anonymous$0)) { - ret$0 := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$l, - dom$RuntimeType$intToRef(0)) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$T$class_c$pkg_kotlin_collections$g$List()) + inhale acc(T$class_c$pkg_kotlin_collections$g$List(p$l), wildcard) + a$0 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$l) + if (!DF$RT$boolFromRef(a$0)) { + r$0 := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$l, + DF$RT$intToRef(0)) } else { - ret$0 := dom$RuntimeType$intToRef(1)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(1)} + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - - -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + + +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 /list.kt:(670,683): info: Generated Viper text for nullable_list: -field special$size: Ref - -method global$fun_nullable_list$fun_take$NT_class_pkg$kotlin$collections$global$class_List$return$T_Unit(local$l: Ref) - returns (ret$0: Ref) - requires local$l != dom$RuntimeType$nullValue() ==> - acc(local$l.special$size, write) - requires local$l != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures local$l != dom$RuntimeType$nullValue() ==> - acc(local$l.special$size, write) - ensures local$l != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$intFromRef(local$l.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +field sp$size: Ref + +method f$g$nullable_list$TF$class_c$pkg_kotlin_collections$g$List(p$l: Ref) + returns (r$0: Ref) + requires p$l != DF$RT$nullValue() ==> acc(p$l.sp$size, write) + requires p$l != DF$RT$nullValue() ==> DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures p$l != DF$RT$nullValue() ==> acc(p$l.sp$size, write) + ensures p$l != DF$RT$nullValue() ==> DF$RT$intFromRef(p$l.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$l), dom$RuntimeType$nullable(dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_List())) - inhale local$l != dom$RuntimeType$nullValue() ==> - acc(T_class_pkg$kotlin$collections$global$class_List(local$l), wildcard) - ret$0 := dom$RuntimeType$unitValue() - if (!(local$l == dom$RuntimeType$nullValue())) { - var anonymous$1: Ref - anonymous$1 := pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(local$l) - anonymous$0 := special$notBool(anonymous$1) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$l), DF$RT$nullable(DF$RT$T$class_c$pkg_kotlin_collections$g$List())) + inhale p$l != DF$RT$nullValue() ==> + acc(T$class_c$pkg_kotlin_collections$g$List(p$l), wildcard) + r$0 := DF$RT$unitValue() + if (!(p$l == DF$RT$nullValue())) { + var a$1: Ref + a$1 := f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(p$l) + a$0 := sp$notBool(a$1) } else { - anonymous$0 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - var local2$x: Ref - var anonymous$2: Ref - anonymous$2 := local$l.special$size - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - local2$x := pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(local$l, - special$minusInts(anonymous$2, dom$RuntimeType$intToRef(1))) + a$0 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$0)) { + var l2$x: Ref + var a$2: Ref + a$2 := p$l.sp$size + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + l2$x := f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(p$l, + sp$minusInts(a$2, DF$RT$intToRef(1))) } - label label$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_List$fun_get$fun_take$T_class_pkg$kotlin$collections$global$class_List$T_Int$return$T_Int(this: Ref, - local$index: Ref) +method f$pkg_kotlin_collections$c$List$get$TF$T$class_c$pkg_kotlin_collections$g$List$T$Int(this: Ref, + p$index: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - requires dom$RuntimeType$intFromRef(local$index) >= 0 - requires dom$RuntimeType$intFromRef(this.special$size) > - dom$RuntimeType$intFromRef(local$index) - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - - -method pkg$kotlin$collections$class_List$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_List$return$T_Boolean(this: Ref) + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + requires DF$RT$intFromRef(p$index) >= 0 + requires DF$RT$intFromRef(this.sp$size) > DF$RT$intFromRef(p$index) + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + + +method f$pkg_kotlin_collections$c$List$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$List(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/multiple_interfaces.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/multiple_interfaces.fir.diag.txt index 9939d1eb67db07..5d51b6f3c32d66 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/multiple_interfaces.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/multiple_interfaces.fir.diag.txt @@ -1,229 +1,216 @@ /multiple_interfaces.kt:(826,831): info: Generated Viper text for take1: -method global$fun_take1$fun_take$T_class_global$class_InterfaceWithImplementation1$return$T_Unit(local$obj: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$take1$TF$T$class_c$g$InterfaceWithImplementation1(p$obj: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$T_class_global$class_InterfaceWithImplementation1()) - inhale acc(T_class_global$class_InterfaceWithImplementation1(local$obj), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$1 := public$property_getter_field(local$obj) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$g$InterfaceWithImplementation1()) + inhale acc(T$class_c$g$InterfaceWithImplementation1(p$obj), wildcard) + r$0 := DF$RT$unitValue() + a$1 := pg$public$field(p$obj) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) /multiple_interfaces.kt:(890,895): info: Generated Viper text for take2: -method global$fun_take2$fun_take$T_class_global$class_InterfaceWithoutImplementation2$return$T_Unit(local$obj: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$take2$TF$T$class_c$g$InterfaceWithoutImplementation2(p$obj: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$T_class_global$class_InterfaceWithoutImplementation2()) - inhale acc(T_class_global$class_InterfaceWithoutImplementation2(local$obj), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$1 := public$property_getter_field(local$obj) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$g$InterfaceWithoutImplementation2()) + inhale acc(T$class_c$g$InterfaceWithoutImplementation2(p$obj), wildcard) + r$0 := DF$RT$unitValue() + a$1 := pg$public$field(p$obj) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) /multiple_interfaces.kt:(957,962): info: Generated Viper text for take3: -field public$backing_field_field: Ref +field bf$public$field: Ref -method global$fun_take3$fun_take$T_class_global$class_AbstractWithFinalImplementation3$return$T_Unit(local$obj: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$take3$TF$T$class_c$g$AbstractWithFinalImplementation3(p$obj: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$T_class_global$class_AbstractWithFinalImplementation3()) - inhale acc(T_class_global$class_AbstractWithFinalImplementation3(local$obj), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$g$AbstractWithFinalImplementation3()) + inhale acc(T$class_c$g$AbstractWithFinalImplementation3(p$obj), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /multiple_interfaces.kt:(1025,1030): info: Generated Viper text for take4: -method global$fun_take4$fun_take$T_class_global$class_AbstractWithOpenImplementation4$return$T_Unit(local$obj: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$take4$TF$T$class_c$g$AbstractWithOpenImplementation4(p$obj: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$obj), dom$RuntimeType$T_class_global$class_AbstractWithOpenImplementation4()) - inhale acc(T_class_global$class_AbstractWithOpenImplementation4(local$obj), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$1 := public$property_getter_field(local$obj) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$obj), DF$RT$T$class_c$g$AbstractWithOpenImplementation4()) + inhale acc(T$class_c$g$AbstractWithOpenImplementation4(p$obj), wildcard) + r$0 := DF$RT$unitValue() + a$1 := pg$public$field(p$obj) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) /multiple_interfaces.kt:(1728,1739): info: Generated Viper text for createImpls: -field public$backing_field_field: Ref +field bf$public$field: Ref -method class_Impl12$constructor$fun_take$$return$T_class_global$class_Impl12() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl12()) - ensures acc(T_class_global$class_Impl12(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl12(ret), write) +method con$c$Impl12$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl12()) + ensures acc(T$class_c$g$Impl12(ret), wildcard) + ensures acc(U$T$class_c$g$Impl12(ret), write) -method class_Impl14$constructor$fun_take$$return$T_class_global$class_Impl14() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl14()) - ensures acc(T_class_global$class_Impl14(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl14(ret), write) +method con$c$Impl14$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl14()) + ensures acc(T$class_c$g$Impl14(ret), wildcard) + ensures acc(U$T$class_c$g$Impl14(ret), write) -method class_Impl23$constructor$fun_take$$return$T_class_global$class_Impl23() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl23()) - ensures acc(T_class_global$class_Impl23(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl23(ret), write) +method con$c$Impl23$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl23()) + ensures acc(T$class_c$g$Impl23(ret), wildcard) + ensures acc(U$T$class_c$g$Impl23(ret), write) -method class_Impl24$constructor$fun_take$$return$T_class_global$class_Impl24() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl24()) - ensures acc(T_class_global$class_Impl24(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl24(ret), write) +method con$c$Impl24$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl24()) + ensures acc(T$class_c$g$Impl24(ret), wildcard) + ensures acc(U$T$class_c$g$Impl24(ret), write) -method class_Impl3$constructor$fun_take$$return$T_class_global$class_Impl3() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl3()) - ensures acc(T_class_global$class_Impl3(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl3(ret), write) +method con$c$Impl3$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl3()) + ensures acc(T$class_c$g$Impl3(ret), wildcard) + ensures acc(U$T$class_c$g$Impl3(ret), write) -method global$fun_create6$fun_take$$return$T_class_global$class_InheritingInterfaceWithoutImplementation6() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_InheritingInterfaceWithoutImplementation6()) - ensures acc(T_class_global$class_InheritingInterfaceWithoutImplementation6(ret), wildcard) +method f$g$create6$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$InheritingInterfaceWithoutImplementation6()) + ensures acc(T$class_c$g$InheritingInterfaceWithoutImplementation6(ret), wildcard) -method global$fun_createImpls$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> false +method f$g$createImpls$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> false { - var local0$impl12: Ref - var local0$start12: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var local0$impl23: Ref - var local0$start23: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var anonymous$5: Ref - var local0$impl3: Ref - var local0$start3: Ref - var anonymous$6: Ref - var anonymous$7: Ref - var local0$impl24: Ref - var local0$start24: Ref - var anonymous$8: Ref - var anonymous$9: Ref - var anonymous$10: Ref - var anonymous$11: Ref - var local0$impl14: Ref - var local0$start14: Ref - var anonymous$12: Ref - var anonymous$13: Ref - var anonymous$14: Ref - var local0$impl6: Ref - var local0$start6: Ref - var anonymous$15: Ref - var anonymous$16: Ref - var anonymous$17: Ref - local0$impl12 := class_Impl12$constructor$fun_take$$return$T_class_global$class_Impl12() - unfold acc(T_class_global$class_Impl12(local0$impl12), wildcard) - anonymous$0 := local0$impl12.public$backing_field_field - local0$start12 := special$minusInts(special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) - anonymous$1 := global$fun_take1$fun_take$T_class_global$class_InterfaceWithImplementation1$return$T_Unit(local0$impl12) - anonymous$2 := global$fun_take2$fun_take$T_class_global$class_InterfaceWithoutImplementation2$return$T_Unit(local0$impl12) - local0$impl23 := class_Impl23$constructor$fun_take$$return$T_class_global$class_Impl23() - unfold acc(T_class_global$class_Impl23(local0$impl23), wildcard) - unfold acc(T_class_global$class_AbstractWithFinalImplementation3(local0$impl23), wildcard) - anonymous$3 := local0$impl23.public$backing_field_field - local0$start23 := special$minusInts(special$plusInts(anonymous$3, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) - anonymous$4 := global$fun_take2$fun_take$T_class_global$class_InterfaceWithoutImplementation2$return$T_Unit(local0$impl23) - anonymous$5 := global$fun_take3$fun_take$T_class_global$class_AbstractWithFinalImplementation3$return$T_Unit(local0$impl23) - local0$impl3 := class_Impl3$constructor$fun_take$$return$T_class_global$class_Impl3() - unfold acc(T_class_global$class_Impl3(local0$impl3), wildcard) - unfold acc(T_class_global$class_AbstractWithFinalImplementation3(local0$impl3), wildcard) - anonymous$6 := local0$impl3.public$backing_field_field - local0$start3 := special$minusInts(special$plusInts(anonymous$6, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) - anonymous$7 := global$fun_take3$fun_take$T_class_global$class_AbstractWithFinalImplementation3$return$T_Unit(local0$impl3) - local0$impl24 := class_Impl24$constructor$fun_take$$return$T_class_global$class_Impl24() - anonymous$9 := public$property_getter_field(local0$impl24) - anonymous$8 := anonymous$9 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$8), dom$RuntimeType$intType()) - local0$start24 := special$minusInts(special$plusInts(anonymous$8, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) - anonymous$10 := global$fun_take2$fun_take$T_class_global$class_InterfaceWithoutImplementation2$return$T_Unit(local0$impl24) - anonymous$11 := global$fun_take4$fun_take$T_class_global$class_AbstractWithOpenImplementation4$return$T_Unit(local0$impl24) - local0$impl14 := class_Impl14$constructor$fun_take$$return$T_class_global$class_Impl14() - unfold acc(T_class_global$class_Impl14(local0$impl14), wildcard) - anonymous$12 := local0$impl14.public$backing_field_field - local0$start14 := special$minusInts(special$plusInts(anonymous$12, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) - anonymous$13 := global$fun_take1$fun_take$T_class_global$class_InterfaceWithImplementation1$return$T_Unit(local0$impl14) - anonymous$14 := global$fun_take4$fun_take$T_class_global$class_AbstractWithOpenImplementation4$return$T_Unit(local0$impl14) - local0$impl6 := global$fun_create6$fun_take$$return$T_class_global$class_InheritingInterfaceWithoutImplementation6() - anonymous$16 := public$property_getter_field(local0$impl6) - anonymous$15 := anonymous$16 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$15), dom$RuntimeType$intType()) - local0$start6 := special$minusInts(special$plusInts(anonymous$15, dom$RuntimeType$intToRef(1)), - dom$RuntimeType$intToRef(1)) + var l0$impl12: Ref + var l0$start12: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + var l0$impl23: Ref + var l0$start23: Ref + var a$3: Ref + var a$4: Ref + var a$5: Ref + var l0$impl3: Ref + var l0$start3: Ref + var a$6: Ref + var a$7: Ref + var l0$impl24: Ref + var l0$start24: Ref + var a$8: Ref + var a$9: Ref + var a$10: Ref + var a$11: Ref + var l0$impl14: Ref + var l0$start14: Ref + var a$12: Ref + var a$13: Ref + var a$14: Ref + var l0$impl6: Ref + var l0$start6: Ref + var a$15: Ref + var a$16: Ref + var a$17: Ref + l0$impl12 := con$c$Impl12$() + unfold acc(T$class_c$g$Impl12(l0$impl12), wildcard) + a$0 := l0$impl12.bf$public$field + l0$start12 := sp$minusInts(sp$plusInts(a$0, DF$RT$intToRef(1)), DF$RT$intToRef(1)) + a$1 := f$g$take1$TF$T$class_c$g$InterfaceWithImplementation1(l0$impl12) + a$2 := f$g$take2$TF$T$class_c$g$InterfaceWithoutImplementation2(l0$impl12) + l0$impl23 := con$c$Impl23$() + unfold acc(T$class_c$g$Impl23(l0$impl23), wildcard) + unfold acc(T$class_c$g$AbstractWithFinalImplementation3(l0$impl23), wildcard) + a$3 := l0$impl23.bf$public$field + l0$start23 := sp$minusInts(sp$plusInts(a$3, DF$RT$intToRef(1)), DF$RT$intToRef(1)) + a$4 := f$g$take2$TF$T$class_c$g$InterfaceWithoutImplementation2(l0$impl23) + a$5 := f$g$take3$TF$T$class_c$g$AbstractWithFinalImplementation3(l0$impl23) + l0$impl3 := con$c$Impl3$() + unfold acc(T$class_c$g$Impl3(l0$impl3), wildcard) + unfold acc(T$class_c$g$AbstractWithFinalImplementation3(l0$impl3), wildcard) + a$6 := l0$impl3.bf$public$field + l0$start3 := sp$minusInts(sp$plusInts(a$6, DF$RT$intToRef(1)), DF$RT$intToRef(1)) + a$7 := f$g$take3$TF$T$class_c$g$AbstractWithFinalImplementation3(l0$impl3) + l0$impl24 := con$c$Impl24$() + a$9 := pg$public$field(l0$impl24) + a$8 := a$9 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$8), DF$RT$intType()) + l0$start24 := sp$minusInts(sp$plusInts(a$8, DF$RT$intToRef(1)), DF$RT$intToRef(1)) + a$10 := f$g$take2$TF$T$class_c$g$InterfaceWithoutImplementation2(l0$impl24) + a$11 := f$g$take4$TF$T$class_c$g$AbstractWithOpenImplementation4(l0$impl24) + l0$impl14 := con$c$Impl14$() + unfold acc(T$class_c$g$Impl14(l0$impl14), wildcard) + a$12 := l0$impl14.bf$public$field + l0$start14 := sp$minusInts(sp$plusInts(a$12, DF$RT$intToRef(1)), DF$RT$intToRef(1)) + a$13 := f$g$take1$TF$T$class_c$g$InterfaceWithImplementation1(l0$impl14) + a$14 := f$g$take4$TF$T$class_c$g$AbstractWithOpenImplementation4(l0$impl14) + l0$impl6 := f$g$create6$TF$() + a$16 := pg$public$field(l0$impl6) + a$15 := a$16 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$15), DF$RT$intType()) + l0$start6 := sp$minusInts(sp$plusInts(a$15, DF$RT$intToRef(1)), DF$RT$intToRef(1)) if (true) { - var anonymous$18: Ref - unfold acc(T_class_global$class_Impl14(local0$impl14), wildcard) - anonymous$18 := local0$impl14.public$backing_field_field - anonymous$17 := dom$RuntimeType$boolToRef(dom$RuntimeType$intFromRef(local0$start14) == - dom$RuntimeType$intFromRef(anonymous$18)) + var a$18: Ref + unfold acc(T$class_c$g$Impl14(l0$impl14), wildcard) + a$18 := l0$impl14.bf$public$field + a$17 := DF$RT$boolToRef(DF$RT$intFromRef(l0$start14) == + DF$RT$intFromRef(a$18)) } else { - anonymous$17 := dom$RuntimeType$boolToRef(false)} - if (dom$RuntimeType$boolFromRef(anonymous$17)) { - ret$0 := dom$RuntimeType$boolToRef(true) + a$17 := DF$RT$boolToRef(false)} + if (DF$RT$boolFromRef(a$17)) { + r$0 := DF$RT$boolToRef(true) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_take1$fun_take$T_class_global$class_InterfaceWithImplementation1$return$T_Unit(local$obj: Ref) +method f$g$take1$TF$T$class_c$g$InterfaceWithImplementation1(p$obj: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_take2$fun_take$T_class_global$class_InterfaceWithoutImplementation2$return$T_Unit(local$obj: Ref) +method f$g$take2$TF$T$class_c$g$InterfaceWithoutImplementation2(p$obj: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_take3$fun_take$T_class_global$class_AbstractWithFinalImplementation3$return$T_Unit(local$obj: Ref) +method f$g$take3$TF$T$class_c$g$AbstractWithFinalImplementation3(p$obj: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_take4$fun_take$T_class_global$class_AbstractWithOpenImplementation4$return$T_Unit(local$obj: Ref) +method f$g$take4$TF$T$class_c$g$AbstractWithOpenImplementation4(p$obj: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/nullability.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/nullability.fir.diag.txt index 88b209b963be40..52f93f138ca276 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/nullability.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/nullability.fir.diag.txt @@ -1,9 +1,8 @@ /nullability.kt:(24,35): info: Generated Viper text for return_null: -method global$fun_return_null$fun_take$$return$NT_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$return_null$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue() + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/override_properties_types.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/override_properties_types.fir.diag.txt index fdb8f03930a7ce..6449aa6e0816dd 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/override_properties_types.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/override_properties_types.fir.diag.txt @@ -1,69 +1,59 @@ /override_properties_types.kt:(520,530): info: Generated Viper text for extractInt: -field public$backing_field_field: Ref +field bf$public$field: Ref -method global$fun_extractInt$fun_take$T_class_global$class_Base$T_Boolean$return$NT_Int(local$base: Ref, - local$returnNull: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 == dom$RuntimeType$nullValue() ==> - dom$RuntimeType$boolFromRef(local$returnNull) +method f$g$extractInt$TF$T$class_c$g$Base$T$Boolean(p$base: Ref, p$returnNull: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 == DF$RT$nullValue() ==> DF$RT$boolFromRef(p$returnNull) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$base), dom$RuntimeType$T_class_global$class_Base()) - inhale acc(T_class_global$class_Base(local$base), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$returnNull), - dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$returnNull)) { - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$nullValue() - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$base), DF$RT$T$class_c$g$Base()) + inhale acc(T$class_c$g$Base(p$base), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$returnNull), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$returnNull)) { + var a$0: Ref + a$0 := DF$RT$nullValue() + r$0 := a$0 } else { - var anonymous$1: Ref - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$base), dom$RuntimeType$T_class_global$class_OpenClassOpenFieldVarDerived())) { - var anonymous$2: Ref - var anonymous$3: Ref - anonymous$3 := local$base - inhale acc(T_class_global$class_OpenClassOpenFieldVarDerived(anonymous$3), wildcard) - anonymous$2 := public$property_getter_field(anonymous$3) - anonymous$1 := anonymous$2 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), - dom$RuntimeType$intType()) - } elseif (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$base), - dom$RuntimeType$T_class_global$class_FinalClassOpenFieldVarDerived())) { - var anonymous$4: Ref - anonymous$4 := local$base - inhale acc(T_class_global$class_FinalClassOpenFieldVarDerived(anonymous$4), wildcard) - inhale acc(anonymous$4.public$backing_field_field, write) - anonymous$1 := anonymous$4.public$backing_field_field - exhale acc(anonymous$4.public$backing_field_field, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), - dom$RuntimeType$intType()) - } elseif (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$base), - dom$RuntimeType$T_class_global$class_FinalClassFinalFieldValDerived())) { - var anonymous$5: Ref - anonymous$5 := local$base - inhale acc(T_class_global$class_FinalClassFinalFieldValDerived(anonymous$5), wildcard) - unfold acc(T_class_global$class_FinalClassFinalFieldValDerived(anonymous$5), wildcard) - anonymous$1 := anonymous$5.public$backing_field_field - } elseif (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$base), - dom$RuntimeType$T_class_global$class_OpenClassFinalFieldVarDerived())) { - var anonymous$6: Ref - anonymous$6 := local$base - inhale acc(T_class_global$class_OpenClassFinalFieldVarDerived(anonymous$6), wildcard) - inhale acc(anonymous$6.public$backing_field_field, write) - anonymous$1 := anonymous$6.public$backing_field_field - exhale acc(anonymous$6.public$backing_field_field, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), - dom$RuntimeType$intType()) + var a$1: Ref + if (DF$RT$isSubtype(DF$RT$typeOf(p$base), DF$RT$T$class_c$g$OpenClassOpenFieldVarDerived())) { + var a$2: Ref + var a$3: Ref + a$3 := p$base + inhale acc(T$class_c$g$OpenClassOpenFieldVarDerived(a$3), wildcard) + a$2 := pg$public$field(a$3) + a$1 := a$2 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + } elseif (DF$RT$isSubtype(DF$RT$typeOf(p$base), DF$RT$T$class_c$g$FinalClassOpenFieldVarDerived())) { + var a$4: Ref + a$4 := p$base + inhale acc(T$class_c$g$FinalClassOpenFieldVarDerived(a$4), wildcard) + inhale acc(a$4.bf$public$field, write) + a$1 := a$4.bf$public$field + exhale acc(a$4.bf$public$field, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + } elseif (DF$RT$isSubtype(DF$RT$typeOf(p$base), DF$RT$T$class_c$g$FinalClassFinalFieldValDerived())) { + var a$5: Ref + a$5 := p$base + inhale acc(T$class_c$g$FinalClassFinalFieldValDerived(a$5), wildcard) + unfold acc(T$class_c$g$FinalClassFinalFieldValDerived(a$5), wildcard) + a$1 := a$5.bf$public$field + } elseif (DF$RT$isSubtype(DF$RT$typeOf(p$base), DF$RT$T$class_c$g$OpenClassFinalFieldVarDerived())) { + var a$6: Ref + a$6 := p$base + inhale acc(T$class_c$g$OpenClassFinalFieldVarDerived(a$6), wildcard) + inhale acc(a$6.bf$public$field, write) + a$1 := a$6.bf$public$field + exhale acc(a$6.bf$public$field, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) } else { - anonymous$1 := dom$RuntimeType$intToRef(0)} - ret$0 := anonymous$1 + a$1 := DF$RT$intToRef(0)} + r$0 := a$1 } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) -method public$property_setter_field(this: Ref, value: Ref) - returns (ret: Ref) +method ps$public$field(this: Ref, value: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/private_properties.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/private_properties.fir.diag.txt index 8c9a5e3e4e44d5..280c0a38ada550 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/private_properties.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/private_properties.fir.diag.txt @@ -1,105 +1,96 @@ /private_properties.kt:(195,210): info: Generated Viper text for getBooleanField: -method class_A$fun_getBooleanField$fun_take$T_class_global$class_A$return$T_Boolean(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$c$A$getBooleanField$TF$T$class_c$g$A(this: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_A()) - inhale acc(T_class_global$class_A(this), wildcard) - anonymous$0 := class_A_private$property_getter_field(this) - ret$0 := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$A()) + inhale acc(T$class_c$g$A(this), wildcard) + a$0 := pg$c$A_private$field(this) + r$0 := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + goto lbl$ret$0 + label lbl$ret$0 } -method class_A_private$property_getter_field(this: Ref) returns (ret: Ref) +method pg$c$A_private$field(this: Ref) returns (ret: Ref) -method class_A_private$property_setter_field(this: Ref, value: Ref) - returns (ret: Ref) +method ps$c$A_private$field(this: Ref, value: Ref) returns (ret: Ref) /private_properties.kt:(289,303): info: Generated Viper text for getStringField: -field class_B_private$backing_field_field: Ref +field bf$c$B_private$field: Ref -field public$backing_field_length: Ref +field bf$public$length: Ref -method class_A_private$property_getter_field(this: Ref) returns (ret: Ref) - - -method class_A_private$property_setter_field(this: Ref, value: Ref) - returns (ret: Ref) - - -method class_B$fun_getStringField$fun_take$T_class_global$class_B$return$T_class_pkg$kotlin$global$class_String(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_pkg$kotlin$global$class_String()) - ensures acc(T_class_pkg$kotlin$global$class_String(ret$0), wildcard) +method f$c$B$getStringField$TF$T$class_c$g$B(this: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$pkg_kotlin$g$String()) + ensures acc(T$class_c$pkg_kotlin$g$String(r$0), wildcard) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_B()) - inhale acc(T_class_global$class_B(this), wildcard) - unfold acc(T_class_global$class_B(this), wildcard) - ret$0 := this.class_B_private$backing_field_field - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$B()) + inhale acc(T$class_c$g$B(this), wildcard) + unfold acc(T$class_c$g$B(this), wildcard) + r$0 := this.bf$c$B_private$field + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$c$A_private$field(this: Ref) returns (ret: Ref) -/private_properties.kt:(471,484): info: Generated Viper text for extractPublic: -field class_B_private$backing_field_field: Ref +method pg$public$length(this: Ref) returns (ret: Ref) -field public$backing_field_field: Ref -field public$backing_field_length: Ref +method ps$c$A_private$field(this: Ref, value: Ref) returns (ret: Ref) -method class_A_private$property_getter_field(this: Ref) returns (ret: Ref) +/private_properties.kt:(471,484): info: Generated Viper text for extractPublic: +field bf$c$B_private$field: Ref -method class_A_private$property_setter_field(this: Ref, value: Ref) - returns (ret: Ref) +field bf$public$field: Ref +field bf$public$length: Ref -method class_C$constructor$fun_take$$return$T_class_global$class_C() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_C()) - ensures acc(T_class_global$class_C(ret), wildcard) - ensures acc(Unique$T_class_global$class_C(ret), write) +method con$c$C$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$C()) + ensures acc(T$class_c$g$C(ret), wildcard) + ensures acc(U$T$class_c$g$C(ret), write) -method class_D$constructor$fun_take$$return$T_class_global$class_D() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_D()) - ensures acc(T_class_global$class_D(ret), wildcard) - ensures acc(Unique$T_class_global$class_D(ret), write) +method con$c$D$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$D()) + ensures acc(T$class_c$g$D(ret), wildcard) + ensures acc(U$T$class_c$g$D(ret), write) -method global$fun_extractPublic$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> false +method f$g$extractPublic$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> false { - var anonymous$0: Ref - var anonymous$1: Ref - anonymous$1 := class_C$constructor$fun_take$$return$T_class_global$class_C() - inhale acc(anonymous$1.public$backing_field_field, write) - anonymous$0 := anonymous$1.public$backing_field_field - exhale acc(anonymous$1.public$backing_field_field, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType())) { - var anonymous$2: Ref - var anonymous$3: Ref - anonymous$3 := class_D$constructor$fun_take$$return$T_class_global$class_D() - unfold acc(T_class_global$class_D(anonymous$3), wildcard) - anonymous$2 := anonymous$3.public$backing_field_field - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), - dom$RuntimeType$intType())) + var a$0: Ref + var a$1: Ref + a$1 := con$c$C$() + inhale acc(a$1.bf$public$field, write) + a$0 := a$1.bf$public$field + exhale acc(a$1.bf$public$field, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + if (DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType())) { + var a$2: Ref + var a$3: Ref + a$3 := con$c$D$() + unfold acc(T$class_c$g$D(a$3), wildcard) + a$2 := a$3.bf$public$field + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType())) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$c$A_private$field(this: Ref) returns (ret: Ref) + + +method pg$public$length(this: Ref) returns (ret: Ref) + + +method ps$c$A_private$field(this: Ref, value: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/returns_booleans.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/returns_booleans.fir.diag.txt index b7948d52b94f4d..799dee1fb8bb1c 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/returns_booleans.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/returns_booleans.fir.diag.txt @@ -1,141 +1,126 @@ /returns_booleans.kt:(121,133): info: Generated Viper text for returns_true: -method global$fun_returns_true$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$returns_true$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) ensures true - ensures dom$RuntimeType$boolFromRef(ret$0) == true + ensures DF$RT$boolFromRef(r$0) == true { - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(268,281): info: Generated Viper text for returns_false: -method global$fun_returns_false$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$returns_false$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) ensures true - ensures dom$RuntimeType$boolFromRef(ret$0) == false + ensures DF$RT$boolFromRef(r$0) == false { - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(418,435): info: Generated Viper text for conditional_basic: -method global$fun_conditional_basic$fun_take$T_Boolean$return$T_Boolean(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> true - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - dom$RuntimeType$boolFromRef(local$b) +method f$g$conditional_basic$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> true + ensures DF$RT$boolFromRef(r$0) == false ==> DF$RT$boolFromRef(p$b) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(612,636): info: Generated Viper text for binary_logic_expressions: -method global$fun_binary_logic_expressions$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$a: Ref, - local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - dom$RuntimeType$boolFromRef(local$b) && false - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - (true || dom$RuntimeType$boolFromRef(local$a)) && - (dom$RuntimeType$boolFromRef(local$b) || true) +method f$g$binary_logic_expressions$TF$T$Boolean$T$Boolean(p$a: Ref, p$b: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> + DF$RT$boolFromRef(p$b) && false + ensures DF$RT$boolFromRef(r$0) == true ==> + (true || DF$RT$boolFromRef(p$a)) && (DF$RT$boolFromRef(p$b) || true) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$boolToRef(true) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$boolToRef(true) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(855,866): info: Generated Viper text for logical_not: -method global$fun_logical_not$fun_take$T_Boolean$return$T_Boolean(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true ==> - !dom$RuntimeType$boolFromRef(local$b) && - dom$RuntimeType$boolFromRef(local$b) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - dom$RuntimeType$boolFromRef(local$b) || - !dom$RuntimeType$boolFromRef(local$b) +method f$g$logical_not$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true ==> + !DF$RT$boolFromRef(p$b) && DF$RT$boolFromRef(p$b) + ensures DF$RT$boolFromRef(r$0) == false ==> + DF$RT$boolFromRef(p$b) || !DF$RT$boolFromRef(p$b) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(1052,1075): info: Generated Viper text for call_fun_with_contracts: -method global$fun_binary_logic_expressions$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$a: Ref, - local$b: Ref) +method f$g$binary_logic_expressions$TF$T$Boolean$T$Boolean(p$a: Ref, p$b: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret) == false ==> - dom$RuntimeType$boolFromRef(local$b) && false - ensures dom$RuntimeType$boolFromRef(ret) == true ==> - (true || dom$RuntimeType$boolFromRef(local$a)) && - (dom$RuntimeType$boolFromRef(local$b) || true) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$boolFromRef(ret) == false ==> + DF$RT$boolFromRef(p$b) && false + ensures DF$RT$boolFromRef(ret) == true ==> + (true || DF$RT$boolFromRef(p$a)) && (DF$RT$boolFromRef(p$b) || true) -method global$fun_call_fun_with_contracts$fun_take$T_Boolean$return$T_Boolean(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == true +method f$g$call_fun_with_contracts$TF$T$Boolean(p$b: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == true { - var local0$a: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - local0$a := global$fun_binary_logic_expressions$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$b, - local$b) - ret$0 := local0$a - goto label$ret$0 - label label$ret$0 + var l0$a: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + l0$a := f$g$binary_logic_expressions$TF$T$Boolean$T$Boolean(p$b, p$b) + r$0 := l0$a + goto lbl$ret$0 + label lbl$ret$0 } /returns_booleans.kt:(1467,1480): info: Generated Viper text for isNullOrEmpty: -field special$size: Ref +field sp$size: Ref -method global$fun_isNullOrEmpty$fun_take$NT_class_pkg$kotlin$collections$global$class_Collection$return$T_Boolean(local$collection: Ref) - returns (ret$0: Ref) - requires local$collection != dom$RuntimeType$nullValue() ==> - acc(local$collection.special$size, write) - requires local$collection != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$intFromRef(local$collection.special$size) >= 0 - ensures local$collection != dom$RuntimeType$nullValue() ==> - acc(local$collection.special$size, write) - ensures local$collection != dom$RuntimeType$nullValue() ==> - dom$RuntimeType$intFromRef(local$collection.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(ret$0) == false ==> - local$collection != dom$RuntimeType$nullValue() +method f$g$isNullOrEmpty$TF$class_c$pkg_kotlin_collections$g$Collection(p$collection: Ref) + returns (r$0: Ref) + requires p$collection != DF$RT$nullValue() ==> + acc(p$collection.sp$size, write) + requires p$collection != DF$RT$nullValue() ==> + DF$RT$intFromRef(p$collection.sp$size) >= 0 + ensures p$collection != DF$RT$nullValue() ==> + acc(p$collection.sp$size, write) + ensures p$collection != DF$RT$nullValue() ==> + DF$RT$intFromRef(p$collection.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + ensures DF$RT$boolFromRef(r$0) == false ==> + p$collection != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$collection), - dom$RuntimeType$nullable(dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_Collection())) - inhale local$collection != dom$RuntimeType$nullValue() ==> - acc(T_class_pkg$kotlin$collections$global$class_Collection(local$collection), wildcard) - if (local$collection == dom$RuntimeType$nullValue()) { - ret$0 := dom$RuntimeType$boolToRef(true) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$collection), DF$RT$nullable(DF$RT$T$class_c$pkg_kotlin_collections$g$Collection())) + inhale p$collection != DF$RT$nullValue() ==> + acc(T$class_c$pkg_kotlin_collections$g$Collection(p$collection), wildcard) + if (p$collection == DF$RT$nullValue()) { + r$0 := DF$RT$boolToRef(true) } else { - ret$0 := pkg$kotlin$collections$class_Collection$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_Collection$return$T_Boolean(local$collection)} - goto label$ret$0 - label label$ret$0 + r$0 := f$pkg_kotlin_collections$c$Collection$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$Collection(p$collection)} + goto lbl$ret$0 + label lbl$ret$0 } -method pkg$kotlin$collections$class_Collection$fun_isEmpty$fun_take$T_class_pkg$kotlin$collections$global$class_Collection$return$T_Boolean(this: Ref) +method f$pkg_kotlin_collections$c$Collection$isEmpty$TF$T$class_c$pkg_kotlin_collections$g$Collection(this: Ref) returns (ret: Ref) - requires acc(this.special$size, write) - requires dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures acc(this.special$size, write) - ensures dom$RuntimeType$intFromRef(this.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$intFromRef(this.special$size) == - old(dom$RuntimeType$intFromRef(this.special$size)) - ensures dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) == 0 - ensures !dom$RuntimeType$boolFromRef(ret) ==> - dom$RuntimeType$intFromRef(this.special$size) > 0 + requires acc(this.sp$size, write) + requires DF$RT$intFromRef(this.sp$size) >= 0 + ensures acc(this.sp$size, write) + ensures DF$RT$intFromRef(this.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) + ensures DF$RT$intFromRef(this.sp$size) == + old(DF$RT$intFromRef(this.sp$size)) + ensures DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) == 0 + ensures !DF$RT$boolFromRef(ret) ==> DF$RT$intFromRef(this.sp$size) > 0 diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/returns_null.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/returns_null.fir.diag.txt index 9d3136ec0255a0..108e9ed4d1c829 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/returns_null.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/returns_null.fir.diag.txt @@ -1,83 +1,73 @@ /returns_null.kt:(121,140): info: Generated Viper text for simple_returns_null: -method global$fun_simple_returns_null$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 == dom$RuntimeType$nullValue() - ensures ret$0 != dom$RuntimeType$nullValue() ==> false +method f$g$simple_returns_null$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 == DF$RT$nullValue() + ensures r$0 != DF$RT$nullValue() ==> false { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$nullValue() + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(300,320): info: Generated Viper text for returns_null_implies: -method global$fun_returns_null_implies$fun_take$NT_Boolean$return$NT_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$boolType())) - ensures ret$0 == dom$RuntimeType$nullValue() ==> - local$x == dom$RuntimeType$nullValue() - ensures ret$0 != dom$RuntimeType$nullValue() ==> - local$x != dom$RuntimeType$nullValue() +method f$g$returns_null_implies$TF$Boolean(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$boolType())) + ensures r$0 == DF$RT$nullValue() ==> p$x == DF$RT$nullValue() + ensures r$0 != DF$RT$nullValue() ==> p$x != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$boolType())) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$boolType())) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(511,531): info: Generated Viper text for returns_null_with_if: -method global$fun_returns_null_with_if$fun_take$NT_Int$NT_Int$NT_Int$return$NT_Int(local$x: Ref, - local$y: Ref, local$z: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ensures ret$0 == dom$RuntimeType$nullValue() ==> - local$x == dom$RuntimeType$nullValue() && - local$y == dom$RuntimeType$nullValue() || - local$z == dom$RuntimeType$nullValue() - ensures ret$0 != dom$RuntimeType$nullValue() ==> - local$x != dom$RuntimeType$nullValue() || - local$y != dom$RuntimeType$nullValue() +method f$g$returns_null_with_if$TF$Int$Int$Int(p$x: Ref, p$y: Ref, p$z: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) + ensures r$0 == DF$RT$nullValue() ==> + p$x == DF$RT$nullValue() && p$y == DF$RT$nullValue() || + p$z == DF$RT$nullValue() + ensures r$0 != DF$RT$nullValue() ==> + p$x != DF$RT$nullValue() || p$y != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$z), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - if (local$x == dom$RuntimeType$nullValue()) { - ret$0 := local$y - goto label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$nullable(DF$RT$intType())) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$z), DF$RT$nullable(DF$RT$intType())) + if (p$x == DF$RT$nullValue()) { + r$0 := p$y + goto lbl$ret$0 } else { - ret$0 := local$z - goto label$ret$0 + r$0 := p$z + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } /returns_null.kt:(833,862): info: Generated Viper text for non_nullable_returns_not_null: -method global$fun_non_nullable_returns_not_null$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - ensures ret$0 != dom$RuntimeType$nullValue() +method f$g$non_nullable_returns_not_null$TF$T$Int(p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + ensures r$0 != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(981,1010): info: Generated Viper text for non_nullable_compared_to_null: -method global$fun_non_nullable_compared_to_null$fun_take$T_Int$T_Int$return$T_Int(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - ensures true ==> - local$y == dom$RuntimeType$nullValue() || - local$x != dom$RuntimeType$nullValue() +method f$g$non_nullable_compared_to_null$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + ensures true ==> p$y == DF$RT$nullValue() || p$x != DF$RT$nullValue() { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /returns_null.kt:(1076,1085): warning: Condition is always 'false'. diff --git a/plugins/formal-verification/testData/diagnostics/good_contracts/simple.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/good_contracts/simple.fir.diag.txt index 8b57b8e95945e2..66efab860e7ccd 100644 --- a/plugins/formal-verification/testData/diagnostics/good_contracts/simple.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/good_contracts/simple.fir.diag.txt @@ -1,18 +1,16 @@ /simple.kt:(84,100): info: Generated Viper text for without_contract: -method global$fun_without_contract$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$without_contract$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /simple.kt:(148,161): info: Generated Viper text for with_contract: -method global$fun_with_contract$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$with_contract$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) ensures true { - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + r$0 := DF$RT$unitValue() + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/basic.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/basic.fir.diag.txt index 93f1142468997a..68e445815fc729 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/basic.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/basic.fir.diag.txt @@ -1,72 +1,67 @@ /basic.kt:(23,33): info: Generated Viper text for returnUnit: -method global$fun_returnUnit$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$returnUnit$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /basic.kt:(43,52): info: Generated Viper text for returnInt: -method global$fun_returnInt$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$returnInt$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + label lbl$ret$0 } /basic.kt:(77,94): info: Generated Viper text for takeIntReturnUnit: -method global$fun_takeIntReturnUnit$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$takeIntReturnUnit$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /basic.kt:(140,156): info: Generated Viper text for takeIntReturnInt: -method global$fun_takeIntReturnInt$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$takeIntReturnInt$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /basic.kt:(187,207): info: Generated Viper text for takeIntReturnIntExpr: -method global$fun_takeIntReturnIntExpr$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$takeIntReturnIntExpr$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /basic.kt:(229,247): info: Generated Viper text for withIntDeclaration: -method global$fun_withIntDeclaration$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$withIntDeclaration$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - local0$x := dom$RuntimeType$intToRef(0) - ret$0 := local0$x - goto label$ret$0 - label label$ret$0 + var l0$x: Ref + l0$x := DF$RT$intToRef(0) + r$0 := l0$x + goto lbl$ret$0 + label lbl$ret$0 } /basic.kt:(290,303): info: Generated Viper text for intAssignment: -method global$fun_intAssignment$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$intAssignment$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$x := dom$RuntimeType$intToRef(0) - local0$x := dom$RuntimeType$intToRef(1) - label label$ret$0 + var l0$x: Ref + r$0 := DF$RT$unitValue() + l0$x := DF$RT$intToRef(0) + l0$x := DF$RT$intToRef(1) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/field_getters.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/field_getters.fir.diag.txt index f5e91b2962f9d3..dfc64aac8297ca 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/field_getters.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/field_getters.fir.diag.txt @@ -1,119 +1,119 @@ /field_getters.kt:(70,94): info: Generated Viper text for testPrimitiveFieldGetter: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -method global$fun_testPrimitiveFieldGetter$fun_take$T_class_global$class_PrimitiveFields$return$T_Unit(local$pf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testPrimitiveFieldGetter$TF$T$class_c$g$PrimitiveFields(p$pf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$a: Ref - var local0$b: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pf), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - inhale acc(T_class_global$class_PrimitiveFields(local$pf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - unfold acc(T_class_global$class_PrimitiveFields(local$pf), wildcard) - local0$a := local$pf.public$backing_field_a - inhale acc(local$pf.public$backing_field_b, write) - local0$b := local$pf.public$backing_field_b - exhale acc(local$pf.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$b), dom$RuntimeType$intType()) - label label$ret$0 + var l0$a: Ref + var l0$b: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pf), DF$RT$T$class_c$g$PrimitiveFields()) + inhale acc(T$class_c$g$PrimitiveFields(p$pf), wildcard) + r$0 := DF$RT$unitValue() + unfold acc(T$class_c$g$PrimitiveFields(p$pf), wildcard) + l0$a := p$pf.bf$public$a + inhale acc(p$pf.bf$public$b, write) + l0$b := p$pf.bf$public$b + exhale acc(p$pf.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$b), DF$RT$intType()) + label lbl$ret$0 } /field_getters.kt:(230,254): info: Generated Viper text for testReferenceFieldGetter: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_f: Ref +field bf$public$f: Ref -field public$backing_field_g: Ref +field bf$public$g: Ref -method global$fun_testReferenceFieldGetter$fun_take$T_class_global$class_ReferenceFields$return$T_Unit(local$rf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testReferenceFieldGetter$TF$T$class_c$g$ReferenceFields(p$rf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$f: Ref - var local0$g: Ref - var local0$fa: Ref - var local0$fb: Ref - var local0$ga: Ref - var local0$gb: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rf), dom$RuntimeType$T_class_global$class_ReferenceFields()) - inhale acc(T_class_global$class_ReferenceFields(local$rf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - unfold acc(T_class_global$class_ReferenceFields(local$rf), wildcard) - local0$f := local$rf.public$backing_field_f - inhale acc(local$rf.public$backing_field_g, write) - local0$g := local$rf.public$backing_field_g - exhale acc(local$rf.public$backing_field_g, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$g), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - inhale acc(T_class_global$class_PrimitiveFields(local0$g), wildcard) - unfold acc(T_class_global$class_PrimitiveFields(local0$f), wildcard) - local0$fa := local0$f.public$backing_field_a - inhale acc(local0$f.public$backing_field_b, write) - local0$fb := local0$f.public$backing_field_b - exhale acc(local0$f.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$fb), dom$RuntimeType$intType()) - unfold acc(T_class_global$class_PrimitiveFields(local0$g), wildcard) - local0$ga := local0$g.public$backing_field_a - inhale acc(local0$g.public$backing_field_b, write) - local0$gb := local0$g.public$backing_field_b - exhale acc(local0$g.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$gb), dom$RuntimeType$intType()) - label label$ret$0 + var l0$f: Ref + var l0$g: Ref + var l0$fa: Ref + var l0$fb: Ref + var l0$ga: Ref + var l0$gb: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rf), DF$RT$T$class_c$g$ReferenceFields()) + inhale acc(T$class_c$g$ReferenceFields(p$rf), wildcard) + r$0 := DF$RT$unitValue() + unfold acc(T$class_c$g$ReferenceFields(p$rf), wildcard) + l0$f := p$rf.bf$public$f + inhale acc(p$rf.bf$public$g, write) + l0$g := p$rf.bf$public$g + exhale acc(p$rf.bf$public$g, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$g), DF$RT$T$class_c$g$PrimitiveFields()) + inhale acc(T$class_c$g$PrimitiveFields(l0$g), wildcard) + unfold acc(T$class_c$g$PrimitiveFields(l0$f), wildcard) + l0$fa := l0$f.bf$public$a + inhale acc(l0$f.bf$public$b, write) + l0$fb := l0$f.bf$public$b + exhale acc(l0$f.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$fb), DF$RT$intType()) + unfold acc(T$class_c$g$PrimitiveFields(l0$g), wildcard) + l0$ga := l0$g.bf$public$a + inhale acc(l0$g.bf$public$b, write) + l0$gb := l0$g.bf$public$b + exhale acc(l0$g.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$gb), DF$RT$intType()) + label lbl$ret$0 } /field_getters.kt:(387,411): info: Generated Viper text for testCascadingFieldGetter: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_f: Ref +field bf$public$f: Ref -field public$backing_field_g: Ref +field bf$public$g: Ref -method global$fun_testCascadingFieldGetter$fun_take$T_class_global$class_ReferenceFields$return$T_Unit(local$rf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testCascadingFieldGetter$TF$T$class_c$g$ReferenceFields(p$rf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$fa: Ref - var anonymous$0: Ref - var local0$fb: Ref - var anonymous$1: Ref - var local0$ga: Ref - var anonymous$2: Ref - var local0$gb: Ref - var anonymous$3: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rf), dom$RuntimeType$T_class_global$class_ReferenceFields()) - inhale acc(T_class_global$class_ReferenceFields(local$rf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - unfold acc(T_class_global$class_ReferenceFields(local$rf), wildcard) - anonymous$0 := local$rf.public$backing_field_f - unfold acc(T_class_global$class_PrimitiveFields(anonymous$0), wildcard) - local0$fa := anonymous$0.public$backing_field_a - unfold acc(T_class_global$class_ReferenceFields(local$rf), wildcard) - anonymous$1 := local$rf.public$backing_field_f - inhale acc(anonymous$1.public$backing_field_b, write) - local0$fb := anonymous$1.public$backing_field_b - exhale acc(anonymous$1.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$fb), dom$RuntimeType$intType()) - inhale acc(local$rf.public$backing_field_g, write) - anonymous$2 := local$rf.public$backing_field_g - exhale acc(local$rf.public$backing_field_g, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - inhale acc(T_class_global$class_PrimitiveFields(anonymous$2), wildcard) - unfold acc(T_class_global$class_PrimitiveFields(anonymous$2), wildcard) - local0$ga := anonymous$2.public$backing_field_a - inhale acc(local$rf.public$backing_field_g, write) - anonymous$3 := local$rf.public$backing_field_g - exhale acc(local$rf.public$backing_field_g, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$3), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - inhale acc(T_class_global$class_PrimitiveFields(anonymous$3), wildcard) - inhale acc(anonymous$3.public$backing_field_b, write) - local0$gb := anonymous$3.public$backing_field_b - exhale acc(anonymous$3.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$gb), dom$RuntimeType$intType()) - label label$ret$0 + var l0$fa: Ref + var a$0: Ref + var l0$fb: Ref + var a$1: Ref + var l0$ga: Ref + var a$2: Ref + var l0$gb: Ref + var a$3: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rf), DF$RT$T$class_c$g$ReferenceFields()) + inhale acc(T$class_c$g$ReferenceFields(p$rf), wildcard) + r$0 := DF$RT$unitValue() + unfold acc(T$class_c$g$ReferenceFields(p$rf), wildcard) + a$0 := p$rf.bf$public$f + unfold acc(T$class_c$g$PrimitiveFields(a$0), wildcard) + l0$fa := a$0.bf$public$a + unfold acc(T$class_c$g$ReferenceFields(p$rf), wildcard) + a$1 := p$rf.bf$public$f + inhale acc(a$1.bf$public$b, write) + l0$fb := a$1.bf$public$b + exhale acc(a$1.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$fb), DF$RT$intType()) + inhale acc(p$rf.bf$public$g, write) + a$2 := p$rf.bf$public$g + exhale acc(p$rf.bf$public$g, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$T$class_c$g$PrimitiveFields()) + inhale acc(T$class_c$g$PrimitiveFields(a$2), wildcard) + unfold acc(T$class_c$g$PrimitiveFields(a$2), wildcard) + l0$ga := a$2.bf$public$a + inhale acc(p$rf.bf$public$g, write) + a$3 := p$rf.bf$public$g + exhale acc(p$rf.bf$public$g, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$3), DF$RT$T$class_c$g$PrimitiveFields()) + inhale acc(T$class_c$g$PrimitiveFields(a$3), wildcard) + inhale acc(a$3.bf$public$b, write) + l0$gb := a$3.bf$public$b + exhale acc(a$3.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$gb), DF$RT$intType()) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance.fir.diag.txt index 3b7160a8f00ebc..278adc041f1e1a 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance.fir.diag.txt @@ -1,184 +1,177 @@ /inheritance.kt:(93,97): info: Generated Viper text for getY: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -method class_Foo$fun_getY$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$c$Foo$getY$TF$T$class_c$g$Foo(this: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(this), wildcard) - unfold acc(T_class_global$class_Foo(this), wildcard) - ret$0 := this.public$backing_field_y - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(this), wildcard) + unfold acc(T$class_c$g$Foo(this), wildcard) + r$0 := this.bf$public$y + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(190,193): info: Generated Viper text for sum: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method class_Bar$fun_sum$fun_take$T_class_global$class_Bar$return$T_Int(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$c$Bar$sum$TF$T$class_c$g$Bar(this: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(this), wildcard) - unfold acc(T_class_global$class_Bar(this), wildcard) - unfold acc(T_class_global$class_Foo(this), wildcard) - anonymous$0 := this.public$backing_field_x - unfold acc(T_class_global$class_Bar(this), wildcard) - anonymous$1 := this.public$backing_field_z - ret$0 := special$plusInts(anonymous$0, anonymous$1) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(this), wildcard) + unfold acc(T$class_c$g$Bar(this), wildcard) + unfold acc(T$class_c$g$Foo(this), wildcard) + a$0 := this.bf$public$x + unfold acc(T$class_c$g$Bar(this), wildcard) + a$1 := this.bf$public$z + r$0 := sp$plusInts(a$0, a$1) + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(236,251): info: Generated Viper text for callSuperMethod: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method class_Foo$fun_getY$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$c$Foo$getY$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_callSuperMethod$fun_take$T_class_global$class_Bar$return$T_Int(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$callSuperMethod$TF$T$class_c$g$Bar(p$bar: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - ret$0 := class_Foo$fun_getY$fun_take$T_class_global$class_Foo$return$T_Int(local$bar) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + r$0 := f$c$Foo$getY$TF$T$class_c$g$Foo(p$bar) + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(298,314): info: Generated Viper text for accessSuperField: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_accessSuperField$fun_take$T_class_global$class_Bar$return$T_Boolean(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$accessSuperField$TF$T$class_c$g$Bar(p$bar: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - inhale acc(local$bar.public$backing_field_b, write) - ret$0 := local$bar.public$backing_field_b - exhale acc(local$bar.public$backing_field_b, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + inhale acc(p$bar.bf$public$b, write) + r$0 := p$bar.bf$public$b + exhale acc(p$bar.bf$public$b, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(360,374): info: Generated Viper text for accessNewField: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_accessNewField$fun_take$T_class_global$class_Bar$return$T_Int(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$accessNewField$TF$T$class_c$g$Bar(p$bar: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - unfold acc(T_class_global$class_Bar(local$bar), wildcard) - ret$0 := local$bar.public$backing_field_z - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + unfold acc(T$class_c$g$Bar(p$bar), wildcard) + r$0 := p$bar.bf$public$z + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(416,429): info: Generated Viper text for callNewMethod: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method class_Bar$fun_sum$fun_take$T_class_global$class_Bar$return$T_Int(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$c$Bar$sum$TF$T$class_c$g$Bar(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_callNewMethod$fun_take$T_class_global$class_Bar$return$T_Int(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$callNewMethod$TF$T$class_c$g$Bar(p$bar: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - ret$0 := class_Bar$fun_sum$fun_take$T_class_global$class_Bar$return$T_Int(local$bar) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + r$0 := f$c$Bar$sum$TF$T$class_c$g$Bar(p$bar) + goto lbl$ret$0 + label lbl$ret$0 } /inheritance.kt:(475,488): info: Generated Viper text for setSuperField: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_setSuperField$fun_take$T_class_global$class_Bar$return$T_Unit(local$bar: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$setSuperField$TF$T$class_c$g$Bar(p$bar: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$bar), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$bar), wildcard) - ret$0 := dom$RuntimeType$unitValue() - inhale acc(local$bar.public$backing_field_b, write) - local$bar.public$backing_field_b := dom$RuntimeType$boolToRef(true) - exhale acc(local$bar.public$backing_field_b, write) - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$bar), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$bar), wildcard) + r$0 := DF$RT$unitValue() + inhale acc(p$bar.bf$public$b, write) + p$bar.bf$public$b := DF$RT$boolToRef(true) + exhale acc(p$bar.bf$public$b, write) + label lbl$ret$0 } /inheritance.kt:(525,546): info: Generated Viper text for accessSuperSuperField: -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -method global$fun_accessSuperSuperField$fun_take$T_class_global$class_Baz$return$T_Int(local$baz: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$accessSuperSuperField$TF$T$class_c$g$Baz(p$baz: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$baz), dom$RuntimeType$T_class_global$class_Baz()) - inhale acc(T_class_global$class_Baz(local$baz), wildcard) - unfold acc(T_class_global$class_Baz(local$baz), wildcard) - unfold acc(T_class_global$class_Bar(local$baz), wildcard) - unfold acc(T_class_global$class_Foo(local$baz), wildcard) - ret$0 := local$baz.public$backing_field_x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$baz), DF$RT$T$class_c$g$Baz()) + inhale acc(T$class_c$g$Baz(p$baz), wildcard) + unfold acc(T$class_c$g$Baz(p$baz), wildcard) + unfold acc(T$class_c$g$Bar(p$baz), wildcard) + unfold acc(T$class_c$g$Foo(p$baz), wildcard) + r$0 := p$baz.bf$public$x + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance_fields.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance_fields.fir.diag.txt index 929cb569f7f39a..eda0dd0eac6ce2 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance_fields.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/inheritance_fields.fir.diag.txt @@ -1,121 +1,112 @@ /inheritance_fields.kt:(227,234): info: Generated Viper text for createB: -field public$backing_field_fieldNotOverride: Ref +field bf$public$fieldNotOverride: Ref -method class_B$constructor$fun_take$T_class_global$class_FieldB$return$T_class_global$class_B(local$fieldOverride: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_B()) - ensures acc(T_class_global$class_B(ret), wildcard) - ensures acc(Unique$T_class_global$class_B(ret), write) +method con$c$B$T$class_c$g$FieldB(p$fieldOverride: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$B()) + ensures acc(T$class_c$g$B(ret), wildcard) + ensures acc(U$T$class_c$g$B(ret), write) -method class_FieldB$constructor$fun_take$$return$T_class_global$class_FieldB() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_FieldB()) - ensures acc(T_class_global$class_FieldB(ret), wildcard) - ensures acc(Unique$T_class_global$class_FieldB(ret), write) +method con$c$FieldB$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$FieldB()) + ensures acc(T$class_c$g$FieldB(ret), wildcard) + ensures acc(U$T$class_c$g$FieldB(ret), write) -method global$fun_createB$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$createB$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$fieldB: Ref - var local0$b: Ref - var local0$fieldOverride: Ref - var anonymous$0: Ref - var local0$fieldNotOverride: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$fieldB := class_FieldB$constructor$fun_take$$return$T_class_global$class_FieldB() - local0$b := class_B$constructor$fun_take$T_class_global$class_FieldB$return$T_class_global$class_B(local0$fieldB) - anonymous$0 := public$property_getter_fieldOverride(local0$b) - local0$fieldOverride := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$fieldOverride), - dom$RuntimeType$T_class_global$class_FieldB()) - inhale acc(T_class_global$class_FieldB(local0$fieldOverride), wildcard) - unfold acc(T_class_global$class_B(local0$b), wildcard) - unfold acc(T_class_global$class_A(local0$b), wildcard) - local0$fieldNotOverride := local0$b.public$backing_field_fieldNotOverride - label label$ret$0 + var l0$fieldB: Ref + var l0$b: Ref + var l0$fieldOverride: Ref + var a$0: Ref + var l0$fieldNotOverride: Ref + r$0 := DF$RT$unitValue() + l0$fieldB := con$c$FieldB$() + l0$b := con$c$B$T$class_c$g$FieldB(l0$fieldB) + a$0 := pg$public$fieldOverride(l0$b) + l0$fieldOverride := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$fieldOverride), DF$RT$T$class_c$g$FieldB()) + inhale acc(T$class_c$g$FieldB(l0$fieldOverride), wildcard) + unfold acc(T$class_c$g$B(l0$b), wildcard) + unfold acc(T$class_c$g$A(l0$b), wildcard) + l0$fieldNotOverride := l0$b.bf$public$fieldNotOverride + label lbl$ret$0 } -method public$property_getter_fieldOverride(this: Ref) returns (ret: Ref) +method pg$public$fieldOverride(this: Ref) returns (ret: Ref) /inheritance_fields.kt:(699,715): info: Generated Viper text for createBFsAndNoBF: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_FirstBackingFieldClass$constructor$fun_take$$return$T_class_global$class_FirstBackingFieldClass() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_FirstBackingFieldClass()) - ensures acc(T_class_global$class_FirstBackingFieldClass(ret), wildcard) - ensures acc(Unique$T_class_global$class_FirstBackingFieldClass(ret), write) +method con$c$FirstBackingFieldClass$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$FirstBackingFieldClass()) + ensures acc(T$class_c$g$FirstBackingFieldClass(ret), wildcard) + ensures acc(U$T$class_c$g$FirstBackingFieldClass(ret), write) -method class_NoBackingFieldClass$constructor$fun_take$$return$T_class_global$class_NoBackingFieldClass() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_NoBackingFieldClass()) - ensures acc(T_class_global$class_NoBackingFieldClass(ret), wildcard) - ensures acc(Unique$T_class_global$class_NoBackingFieldClass(ret), write) +method con$c$NoBackingFieldClass$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$NoBackingFieldClass()) + ensures acc(T$class_c$g$NoBackingFieldClass(ret), wildcard) + ensures acc(U$T$class_c$g$NoBackingFieldClass(ret), write) -method class_SecondBackingFieldClass$constructor$fun_take$T_Int$return$T_class_global$class_SecondBackingFieldClass(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_SecondBackingFieldClass()) - ensures acc(T_class_global$class_SecondBackingFieldClass(ret), wildcard) - ensures acc(Unique$T_class_global$class_SecondBackingFieldClass(ret), write) - ensures (unfolding acc(T_class_global$class_SecondBackingFieldClass(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_x) == - dom$RuntimeType$intFromRef(local$x)) +method con$c$SecondBackingFieldClass$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$SecondBackingFieldClass()) + ensures acc(T$class_c$g$SecondBackingFieldClass(ret), wildcard) + ensures acc(U$T$class_c$g$SecondBackingFieldClass(ret), write) + ensures (unfolding acc(T$class_c$g$SecondBackingFieldClass(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$x) == DF$RT$intFromRef(p$x)) -method global$fun_createBFsAndNoBF$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$createBFsAndNoBF$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$fbf: Ref - var local0$fbfx: Ref - var anonymous$0: Ref - var local0$nbf: Ref - var local0$nbfx: Ref - var anonymous$1: Ref - var local0$sbf: Ref - var local0$sbfx: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$fbf := class_FirstBackingFieldClass$constructor$fun_take$$return$T_class_global$class_FirstBackingFieldClass() - anonymous$0 := public$property_getter_x(local0$fbf) - local0$fbfx := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$fbfx), dom$RuntimeType$intType()) - local0$nbf := class_NoBackingFieldClass$constructor$fun_take$$return$T_class_global$class_NoBackingFieldClass() - anonymous$1 := public$property_getter_x(local0$nbf) - local0$nbfx := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$nbfx), dom$RuntimeType$intType()) - local0$sbf := class_SecondBackingFieldClass$constructor$fun_take$T_Int$return$T_class_global$class_SecondBackingFieldClass(dom$RuntimeType$intToRef(10)) - unfold acc(T_class_global$class_SecondBackingFieldClass(local0$sbf), wildcard) - local0$sbfx := local0$sbf.public$backing_field_x - label label$ret$0 + var l0$fbf: Ref + var l0$fbfx: Ref + var a$0: Ref + var l0$nbf: Ref + var l0$nbfx: Ref + var a$1: Ref + var l0$sbf: Ref + var l0$sbfx: Ref + r$0 := DF$RT$unitValue() + l0$fbf := con$c$FirstBackingFieldClass$() + a$0 := pg$public$x(l0$fbf) + l0$fbfx := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$fbfx), DF$RT$intType()) + l0$nbf := con$c$NoBackingFieldClass$() + a$1 := pg$public$x(l0$nbf) + l0$nbfx := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$nbfx), DF$RT$intType()) + l0$sbf := con$c$SecondBackingFieldClass$T$Int(DF$RT$intToRef(10)) + unfold acc(T$class_c$g$SecondBackingFieldClass(l0$sbf), wildcard) + l0$sbfx := l0$sbf.bf$public$x + label lbl$ret$0 } -method public$property_getter_x(this: Ref) returns (ret: Ref) +method pg$public$x(this: Ref) returns (ret: Ref) /inheritance_fields.kt:(1038,1045): info: Generated Viper text for createY: -field public$backing_field_a: Ref +field bf$public$a: Ref -method class_Y$constructor$fun_take$T_Int$return$T_class_global$class_Y(local$a: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Y()) - ensures acc(T_class_global$class_Y(ret), wildcard) - ensures acc(Unique$T_class_global$class_Y(ret), write) +method con$c$Y$T$Int(p$a: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Y()) + ensures acc(T$class_c$g$Y(ret), wildcard) + ensures acc(U$T$class_c$g$Y(ret), write) -method global$fun_createY$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$createY$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$y: Ref - var local0$ya: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$y := class_Y$constructor$fun_take$T_Int$return$T_class_global$class_Y(dom$RuntimeType$intToRef(10)) - unfold acc(T_class_global$class_Y(local0$y), wildcard) - unfold acc(T_class_global$class_X(local0$y), wildcard) - local0$ya := local0$y.public$backing_field_a - label label$ret$0 + var l0$y: Ref + var l0$ya: Ref + r$0 := DF$RT$unitValue() + l0$y := con$c$Y$T$Int(DF$RT$intToRef(10)) + unfold acc(T$class_c$g$Y(l0$y), wildcard) + unfold acc(T$class_c$g$X(l0$y), wildcard) + l0$ya := l0$y.bf$public$a + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/interface.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/interface.fir.diag.txt index 921f9816dd9906..0bdaba42ec1b36 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/interface.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/interface.fir.diag.txt @@ -1,61 +1,57 @@ /interface.kt:(84,98): info: Generated Viper text for testProperties: -method global$fun_testProperties$fun_take$T_class_global$class_Foo$return$T_Unit(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testProperties$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var local0$x: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := public$property_setter_varProp(local$foo, dom$RuntimeType$intToRef(0)) - anonymous$2 := public$property_getter_varProp(local$foo) - anonymous$1 := anonymous$2 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$intType()) - anonymous$4 := public$property_getter_valProp(local$foo) - anonymous$3 := anonymous$4 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$3), dom$RuntimeType$intType()) - local0$x := special$plusInts(anonymous$1, anonymous$3) - label label$ret$0 + var a$0: Ref + var l0$x: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := DF$RT$unitValue() + a$0 := ps$public$varProp(p$foo, DF$RT$intToRef(0)) + a$2 := pg$public$varProp(p$foo) + a$1 := a$2 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + a$4 := pg$public$valProp(p$foo) + a$3 := a$4 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$3), DF$RT$intType()) + l0$x := sp$plusInts(a$1, a$3) + label lbl$ret$0 } -method public$property_getter_valProp(this: Ref) returns (ret: Ref) +method pg$public$valProp(this: Ref) returns (ret: Ref) -method public$property_getter_varProp(this: Ref) returns (ret: Ref) +method pg$public$varProp(this: Ref) returns (ret: Ref) -method public$property_setter_varProp(this: Ref, value: Ref) - returns (ret: Ref) +method ps$public$varProp(this: Ref, value: Ref) returns (ret: Ref) /interface.kt:(348,358): info: Generated Viper text for createImpl: -field public$backing_field_number: Ref +field bf$public$number: Ref -method class_Impl$constructor$fun_take$T_Int$return$T_class_global$class_Impl(local$number: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Impl()) - ensures acc(T_class_global$class_Impl(ret), wildcard) - ensures acc(Unique$T_class_global$class_Impl(ret), write) - ensures (unfolding acc(T_class_global$class_Impl(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_number) == - dom$RuntimeType$intFromRef(local$number)) +method con$c$Impl$T$Int(p$number: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Impl()) + ensures acc(T$class_c$g$Impl(ret), wildcard) + ensures acc(U$T$class_c$g$Impl(ret), write) + ensures (unfolding acc(T$class_c$g$Impl(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$number) == DF$RT$intFromRef(p$number)) -method global$fun_createImpl$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$createImpl$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$impl: Ref - var local0$implField: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$impl := class_Impl$constructor$fun_take$T_Int$return$T_class_global$class_Impl(dom$RuntimeType$intToRef(-1)) - unfold acc(T_class_global$class_Impl(local0$impl), wildcard) - local0$implField := local0$impl.public$backing_field_number - label label$ret$0 + var l0$impl: Ref + var l0$implField: Ref + r$0 := DF$RT$unitValue() + l0$impl := con$c$Impl$T$Int(DF$RT$intToRef(-1)) + unfold acc(T$class_c$g$Impl(l0$impl), wildcard) + l0$implField := l0$impl.bf$public$number + label lbl$ret$0 } -method public$property_getter_number(this: Ref) returns (ret: Ref) +method pg$public$number(this: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/member_functions.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/member_functions.fir.diag.txt index cf895b28835f31..cd62628285a1ac 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/member_functions.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/member_functions.fir.diag.txt @@ -1,77 +1,72 @@ /member_functions.kt:(51,60): info: Generated Viper text for memberFun: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$c$Foo$memberFun$TF$T$class_c$g$Foo(this: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(this), wildcard) - unfold acc(T_class_global$class_Foo(this), wildcard) - ret$0 := this.public$backing_field_x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(this), wildcard) + unfold acc(T$class_c$g$Foo(this), wildcard) + r$0 := this.bf$public$x + goto lbl$ret$0 + label lbl$ret$0 } /member_functions.kt:(102,115): info: Generated Viper text for callMemberFun: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_callMemberFun$fun_take$T_class_global$class_Foo$return$T_Unit(this: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$c$Foo$callMemberFun$TF$T$class_c$g$Foo(this: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(this), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(this) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(this), wildcard) + r$0 := DF$RT$unitValue() + a$0 := f$c$Foo$memberFun$TF$T$class_c$g$Foo(this) + label lbl$ret$0 } -method class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$c$Foo$memberFun$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) /member_functions.kt:(155,166): info: Generated Viper text for siblingCall: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$c$Foo$memberFun$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method class_Foo$fun_siblingCall$fun_take$T_class_global$class_Foo$T_class_global$class_Foo$return$T_Unit(this: Ref, - local$other: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$c$Foo$siblingCall$TF$T$class_c$g$Foo$T$class_c$g$Foo(this: Ref, p$other: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(this), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$other), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$other), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(local$other) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(this), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$other), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$other), wildcard) + r$0 := DF$RT$unitValue() + a$0 := f$c$Foo$memberFun$TF$T$class_c$g$Foo(p$other) + label lbl$ret$0 } /member_functions.kt:(220,238): info: Generated Viper text for outerMemberFunCall: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$c$Foo$memberFun$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_outerMemberFunCall$fun_take$T_class_global$class_Foo$return$T_Unit(local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$outerMemberFunCall$TF$T$class_c$g$Foo(p$f: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$f), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := class_Foo$fun_memberFun$fun_take$T_class_global$class_Foo$return$T_Int(local$f) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$f), wildcard) + r$0 := DF$RT$unitValue() + a$0 := f$c$Foo$memberFun$TF$T$class_c$g$Foo(p$f) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/multiple_interfaces.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/multiple_interfaces.fir.diag.txt index 5428dfe0af2aed..5dd7bd7ecee248 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/multiple_interfaces.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/multiple_interfaces.fir.diag.txt @@ -1,69 +1,65 @@ /multiple_interfaces.kt:(162,173): info: Generated Viper text for testDiamond: -method class_D$constructor$fun_take$$return$T_class_global$class_D() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_D()) - ensures acc(T_class_global$class_D(ret), wildcard) - ensures acc(Unique$T_class_global$class_D(ret), write) +method con$c$D$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$D()) + ensures acc(T$class_c$g$D(ret), wildcard) + ensures acc(U$T$class_c$g$D(ret), write) -method global$fun_testDiamond$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$testDiamond$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var anonymous$1: Ref - anonymous$1 := class_D$constructor$fun_take$$return$T_class_global$class_D() - anonymous$0 := public$property_getter_field(anonymous$1) - ret$0 := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + a$1 := con$c$D$() + a$0 := pg$public$field(a$1) + r$0 := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) /multiple_interfaces.kt:(405,415): info: Generated Viper text for testVarVal: -method class_G$constructor$fun_take$$return$T_class_global$class_G() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_G()) - ensures acc(T_class_global$class_G(ret), wildcard) - ensures acc(Unique$T_class_global$class_G(ret), write) +method con$c$G$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$G()) + ensures acc(T$class_c$g$G(ret), wildcard) + ensures acc(U$T$class_c$g$G(ret), write) -method class_I$constructor$fun_take$$return$T_class_global$class_I() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_I()) - ensures acc(T_class_global$class_I(ret), wildcard) - ensures acc(Unique$T_class_global$class_I(ret), write) +method con$c$I$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$I()) + ensures acc(T$class_c$g$I(ret), wildcard) + ensures acc(U$T$class_c$g$I(ret), write) -method global$fun_testVarVal$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testVarVal$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$g: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var local0$i: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var anonymous$5: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$g := class_G$constructor$fun_take$$return$T_class_global$class_G() - anonymous$1 := public$property_getter_field(local0$g) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$intType()) - anonymous$2 := public$property_setter_field(local0$g, dom$RuntimeType$intToRef(1)) - local0$i := class_I$constructor$fun_take$$return$T_class_global$class_I() - anonymous$4 := public$property_getter_field(local0$i) - anonymous$3 := anonymous$4 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$3), dom$RuntimeType$intType()) - anonymous$5 := public$property_setter_field(local0$i, dom$RuntimeType$intToRef(1)) - label label$ret$0 + var l0$g: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + var l0$i: Ref + var a$3: Ref + var a$4: Ref + var a$5: Ref + r$0 := DF$RT$unitValue() + l0$g := con$c$G$() + a$1 := pg$public$field(l0$g) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$intType()) + a$2 := ps$public$field(l0$g, DF$RT$intToRef(1)) + l0$i := con$c$I$() + a$4 := pg$public$field(l0$i) + a$3 := a$4 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$3), DF$RT$intType()) + a$5 := ps$public$field(l0$i, DF$RT$intToRef(1)) + label lbl$ret$0 } -method public$property_getter_field(this: Ref) returns (ret: Ref) +method pg$public$field(this: Ref) returns (ret: Ref) -method public$property_setter_field(this: Ref, value: Ref) - returns (ret: Ref) +method ps$public$field(this: Ref, value: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates.fir.diag.txt index a854f66db69cb9..87fc1d5f5dbb19 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates.fir.diag.txt @@ -1,193 +1,181 @@ /predicates.kt:(203,213): info: Generated Viper text for useClasses: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_next: Ref +field bf$public$next: Ref -field public$backing_field_pf: Ref +field bf$public$pf: Ref -predicate T_class_global$class_Baz(special$class$predicate$subject: Ref) { +predicate T$class_c$g$Baz(this: Ref) { true } -predicate T_class_global$class_PrimitiveFields(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$PrimitiveFields(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_Recursive(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_next, wildcard) && - (special$class$predicate$subject.public$backing_field_next != - dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Recursive(special$class$predicate$subject.public$backing_field_next), wildcard)) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_next), - dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Recursive())) +predicate T$class_c$g$Recursive(this: Ref) { + acc(this.bf$public$next, wildcard) && + (this.bf$public$next != DF$RT$nullValue() ==> + acc(T$class_c$g$Recursive(this.bf$public$next), wildcard)) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$next), DF$RT$nullable(DF$RT$T$class_c$g$Recursive())) } -predicate T_class_global$class_ReferenceField(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_pf, wildcard) && - acc(T_class_global$class_PrimitiveFields(special$class$predicate$subject.public$backing_field_pf), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_pf), - dom$RuntimeType$T_class_global$class_PrimitiveFields()) && - acc(T_class_global$class_Baz(special$class$predicate$subject), wildcard) +predicate T$class_c$g$ReferenceField(this: Ref) { + acc(this.bf$public$pf, wildcard) && + acc(T$class_c$g$PrimitiveFields(this.bf$public$pf), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$pf), DF$RT$T$class_c$g$PrimitiveFields()) && + acc(T$class_c$g$Baz(this), wildcard) } -predicate Unique$T_class_global$class_Baz(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$Baz(this: Ref) { true } -predicate Unique$T_class_global$class_PrimitiveFields(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) && - acc(special$class$predicate$subject.public$backing_field_b, write) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$PrimitiveFields(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) && + acc(this.bf$public$b, write) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) } -predicate Unique$T_class_global$class_Recursive(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_next, wildcard) && - (special$class$predicate$subject.public$backing_field_next != - dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Recursive(special$class$predicate$subject.public$backing_field_next), wildcard)) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_next), - dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Recursive())) +predicate U$T$class_c$g$Recursive(this: Ref) { + acc(this.bf$public$next, wildcard) && + (this.bf$public$next != DF$RT$nullValue() ==> + acc(T$class_c$g$Recursive(this.bf$public$next), wildcard)) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$next), DF$RT$nullable(DF$RT$T$class_c$g$Recursive())) } -predicate Unique$T_class_global$class_ReferenceField(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_pf, wildcard) && - acc(T_class_global$class_PrimitiveFields(special$class$predicate$subject.public$backing_field_pf), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_pf), - dom$RuntimeType$T_class_global$class_PrimitiveFields()) && - acc(Unique$T_class_global$class_Baz(special$class$predicate$subject), write) +predicate U$T$class_c$g$ReferenceField(this: Ref) { + acc(this.bf$public$pf, wildcard) && + acc(T$class_c$g$PrimitiveFields(this.bf$public$pf), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$pf), DF$RT$T$class_c$g$PrimitiveFields()) && + acc(U$T$class_c$g$Baz(this), write) } -method global$fun_useClasses$fun_take$T_class_global$class_ReferenceField$T_class_global$class_Recursive$return$T_Unit(local$rf: Ref, - local$rec: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$useClasses$TF$T$class_c$g$ReferenceField$T$class_c$g$Recursive(p$rf: Ref, + p$rec: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rf), dom$RuntimeType$T_class_global$class_ReferenceField()) - inhale acc(T_class_global$class_ReferenceField(local$rf), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rec), dom$RuntimeType$T_class_global$class_Recursive()) - inhale acc(T_class_global$class_Recursive(local$rec), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rf), DF$RT$T$class_c$g$ReferenceField()) + inhale acc(T$class_c$g$ReferenceField(p$rf), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rec), DF$RT$T$class_c$g$Recursive()) + inhale acc(T$class_c$g$Recursive(p$rec), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /predicates.kt:(354,374): info: Generated Viper text for threeLayersHierarchy: -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$x, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(T$class_c$g$A(this), wildcard) } -predicate T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(T_class_global$class_B(special$class$predicate$subject), wildcard) +predicate T$class_c$g$C(this: Ref) { + acc(T$class_c$g$B(this), wildcard) } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$intType()) && - acc(special$class$predicate$subject.public$backing_field_y, write) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_y), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$x, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$intType()) && + acc(this.bf$public$y, write) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$y), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(U$T$class_c$g$A(this), write) } -predicate Unique$T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(Unique$T_class_global$class_B(special$class$predicate$subject), write) +predicate U$T$class_c$g$C(this: Ref) { + acc(U$T$class_c$g$B(this), write) } -method global$fun_threeLayersHierarchy$fun_take$T_class_global$class_C$return$T_Unit(local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$threeLayersHierarchy$TF$T$class_c$g$C(p$c: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$T_class_global$class_C()) - inhale acc(T_class_global$class_C(local$c), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$T$class_c$g$C()) + inhale acc(T$class_c$g$C(p$c), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /predicates.kt:(390,403): info: Generated Viper text for listHierarchy: -field special$size: Ref +field sp$size: Ref -predicate T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject: Ref) { - acc(T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject), wildcard) +predicate T$class_c$pkg_kotlin_collections$g$Collection(this: Ref) { + acc(T$class_c$pkg_kotlin_collections$g$Iterable(this), wildcard) } -predicate T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject: Ref) { +predicate T$class_c$pkg_kotlin_collections$g$Iterable(this: Ref) { true } -predicate T_class_pkg$kotlin$collections$global$class_List(special$class$predicate$subject: Ref) { - acc(T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject), wildcard) +predicate T$class_c$pkg_kotlin_collections$g$List(this: Ref) { + acc(T$class_c$pkg_kotlin_collections$g$Collection(this), wildcard) } -predicate T_class_pkg$kotlin$collections$global$class_MutableCollection(special$class$predicate$subject: Ref) { - acc(T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject), wildcard) && - acc(T_class_pkg$kotlin$collections$global$class_MutableIterable(special$class$predicate$subject), wildcard) +predicate T$class_c$pkg_kotlin_collections$g$MutableCollection(this: Ref) { + acc(T$class_c$pkg_kotlin_collections$g$Collection(this), wildcard) && + acc(T$class_c$pkg_kotlin_collections$g$MutableIterable(this), wildcard) } -predicate T_class_pkg$kotlin$collections$global$class_MutableIterable(special$class$predicate$subject: Ref) { - acc(T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject), wildcard) +predicate T$class_c$pkg_kotlin_collections$g$MutableIterable(this: Ref) { + acc(T$class_c$pkg_kotlin_collections$g$Iterable(this), wildcard) } -predicate T_class_pkg$kotlin$collections$global$class_MutableList(special$class$predicate$subject: Ref) { - acc(T_class_pkg$kotlin$collections$global$class_List(special$class$predicate$subject), wildcard) && - acc(T_class_pkg$kotlin$collections$global$class_MutableCollection(special$class$predicate$subject), wildcard) +predicate T$class_c$pkg_kotlin_collections$g$MutableList(this: Ref) { + acc(T$class_c$pkg_kotlin_collections$g$List(this), wildcard) && + acc(T$class_c$pkg_kotlin_collections$g$MutableCollection(this), wildcard) } -predicate Unique$T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject: Ref) { - acc(Unique$T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject), write) +predicate U$T$class_c$pkg_kotlin_collections$g$Collection(this: Ref) { + acc(U$T$class_c$pkg_kotlin_collections$g$Iterable(this), write) } -predicate Unique$T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject: Ref) { +predicate U$T$class_c$pkg_kotlin_collections$g$Iterable(this: Ref) { true } -predicate Unique$T_class_pkg$kotlin$collections$global$class_List(special$class$predicate$subject: Ref) { - acc(Unique$T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject), write) +predicate U$T$class_c$pkg_kotlin_collections$g$List(this: Ref) { + acc(U$T$class_c$pkg_kotlin_collections$g$Collection(this), write) } -predicate Unique$T_class_pkg$kotlin$collections$global$class_MutableCollection(special$class$predicate$subject: Ref) { - acc(Unique$T_class_pkg$kotlin$collections$global$class_Collection(special$class$predicate$subject), write) && - acc(Unique$T_class_pkg$kotlin$collections$global$class_MutableIterable(special$class$predicate$subject), write) +predicate U$T$class_c$pkg_kotlin_collections$g$MutableCollection(this: Ref) { + acc(U$T$class_c$pkg_kotlin_collections$g$Collection(this), write) && + acc(U$T$class_c$pkg_kotlin_collections$g$MutableIterable(this), write) } -predicate Unique$T_class_pkg$kotlin$collections$global$class_MutableIterable(special$class$predicate$subject: Ref) { - acc(Unique$T_class_pkg$kotlin$collections$global$class_Iterable(special$class$predicate$subject), write) +predicate U$T$class_c$pkg_kotlin_collections$g$MutableIterable(this: Ref) { + acc(U$T$class_c$pkg_kotlin_collections$g$Iterable(this), write) } -predicate Unique$T_class_pkg$kotlin$collections$global$class_MutableList(special$class$predicate$subject: Ref) { - acc(Unique$T_class_pkg$kotlin$collections$global$class_List(special$class$predicate$subject), write) && - acc(Unique$T_class_pkg$kotlin$collections$global$class_MutableCollection(special$class$predicate$subject), write) +predicate U$T$class_c$pkg_kotlin_collections$g$MutableList(this: Ref) { + acc(U$T$class_c$pkg_kotlin_collections$g$List(this), write) && + acc(U$T$class_c$pkg_kotlin_collections$g$MutableCollection(this), write) } -method global$fun_listHierarchy$fun_take$T_class_pkg$kotlin$collections$global$class_MutableList$return$T_Unit(local$xs: Ref) - returns (ret$0: Ref) - requires acc(local$xs.special$size, write) - requires dom$RuntimeType$intFromRef(local$xs.special$size) >= 0 - ensures acc(local$xs.special$size, write) - ensures dom$RuntimeType$intFromRef(local$xs.special$size) >= 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$listHierarchy$TF$T$class_c$pkg_kotlin_collections$g$MutableList(p$xs: Ref) + returns (r$0: Ref) + requires acc(p$xs.sp$size, write) + requires DF$RT$intFromRef(p$xs.sp$size) >= 0 + ensures acc(p$xs.sp$size, write) + ensures DF$RT$intFromRef(p$xs.sp$size) >= 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$xs), dom$RuntimeType$T_class_pkg$kotlin$collections$global$class_MutableList()) - inhale acc(T_class_pkg$kotlin$collections$global$class_MutableList(local$xs), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$xs), DF$RT$T$class_c$pkg_kotlin_collections$g$MutableList()) + inhale acc(T$class_c$pkg_kotlin_collections$g$MutableList(p$xs), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates_access.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates_access.fir.diag.txt index d7b185b2eb95c1..e5ab260ac52645 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates_access.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/predicates_access.fir.diag.txt @@ -1,350 +1,315 @@ /predicates_access.kt:(249,272): info: Generated Viper text for accessSuperTypeProperty: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(T$class_c$g$A(this), wildcard) } -predicate T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_x), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$T_class_global$class_A()) && - acc(T_class_global$class_D(special$class$predicate$subject), wildcard) && - acc(T_class_global$class_B(special$class$predicate$subject), wildcard) +predicate T$class_c$g$C(this: Ref) { + acc(this.bf$public$x, wildcard) && + acc(T$class_c$g$A(this.bf$public$x), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$T$class_c$g$A()) && + acc(T$class_c$g$D(this), wildcard) && + acc(T$class_c$g$B(this), wildcard) } -predicate T_class_global$class_D(special$class$predicate$subject: Ref) { +predicate T$class_c$g$D(this: Ref) { true } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(U$T$class_c$g$A(this), write) } -predicate Unique$T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_x), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$T_class_global$class_A()) && - acc(special$class$predicate$subject.public$backing_field_y, write) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_y), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_y), - dom$RuntimeType$T_class_global$class_A()) && - acc(Unique$T_class_global$class_D(special$class$predicate$subject), write) && - acc(Unique$T_class_global$class_B(special$class$predicate$subject), write) +predicate U$T$class_c$g$C(this: Ref) { + acc(this.bf$public$x, wildcard) && + acc(T$class_c$g$A(this.bf$public$x), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$T$class_c$g$A()) && + acc(this.bf$public$y, write) && + acc(T$class_c$g$A(this.bf$public$y), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$y), DF$RT$T$class_c$g$A()) && + acc(U$T$class_c$g$D(this), write) && + acc(U$T$class_c$g$B(this), write) } -predicate Unique$T_class_global$class_D(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$D(this: Ref) { true } -method global$fun_accessSuperTypeProperty$fun_take$T_class_global$class_C$return$T_Unit(local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessSuperTypeProperty$TF$T$class_c$g$C(p$c: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$temp: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$T_class_global$class_C()) - inhale acc(T_class_global$class_C(local$c), wildcard) - ret$0 := dom$RuntimeType$unitValue() - unfold acc(T_class_global$class_C(local$c), wildcard) - unfold acc(T_class_global$class_B(local$c), wildcard) - unfold acc(T_class_global$class_A(local$c), wildcard) - local0$temp := local$c.public$backing_field_a - label label$ret$0 + var l0$temp: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$T$class_c$g$C()) + inhale acc(T$class_c$g$C(p$c), wildcard) + r$0 := DF$RT$unitValue() + unfold acc(T$class_c$g$C(p$c), wildcard) + unfold acc(T$class_c$g$B(p$c), wildcard) + unfold acc(T$class_c$g$A(p$c), wildcard) + l0$temp := p$c.bf$public$a + label lbl$ret$0 } -method public$property_getter_d(this: Ref) returns (ret: Ref) +method pg$public$d(this: Ref) returns (ret: Ref) /predicates_access.kt:(306,318): info: Generated Viper text for accessNested: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(T$class_c$g$A(this), wildcard) } -predicate T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_x), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$T_class_global$class_A()) && - acc(T_class_global$class_D(special$class$predicate$subject), wildcard) && - acc(T_class_global$class_B(special$class$predicate$subject), wildcard) +predicate T$class_c$g$C(this: Ref) { + acc(this.bf$public$x, wildcard) && + acc(T$class_c$g$A(this.bf$public$x), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$T$class_c$g$A()) && + acc(T$class_c$g$D(this), wildcard) && + acc(T$class_c$g$B(this), wildcard) } -predicate T_class_global$class_D(special$class$predicate$subject: Ref) { +predicate T$class_c$g$D(this: Ref) { true } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(U$T$class_c$g$A(this), write) } -predicate Unique$T_class_global$class_C(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_x), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$T_class_global$class_A()) && - acc(special$class$predicate$subject.public$backing_field_y, write) && - acc(T_class_global$class_A(special$class$predicate$subject.public$backing_field_y), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_y), - dom$RuntimeType$T_class_global$class_A()) && - acc(Unique$T_class_global$class_D(special$class$predicate$subject), write) && - acc(Unique$T_class_global$class_B(special$class$predicate$subject), write) +predicate U$T$class_c$g$C(this: Ref) { + acc(this.bf$public$x, wildcard) && + acc(T$class_c$g$A(this.bf$public$x), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$T$class_c$g$A()) && + acc(this.bf$public$y, write) && + acc(T$class_c$g$A(this.bf$public$y), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$y), DF$RT$T$class_c$g$A()) && + acc(U$T$class_c$g$D(this), write) && + acc(U$T$class_c$g$B(this), write) } -predicate Unique$T_class_global$class_D(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$D(this: Ref) { true } -method global$fun_accessNested$fun_take$T_class_global$class_C$return$T_Unit(local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessNested$TF$T$class_c$g$C(p$c: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$temp: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$T_class_global$class_C()) - inhale acc(T_class_global$class_C(local$c), wildcard) - ret$0 := dom$RuntimeType$unitValue() - unfold acc(T_class_global$class_C(local$c), wildcard) - anonymous$0 := local$c.public$backing_field_x - unfold acc(T_class_global$class_A(anonymous$0), wildcard) - local0$temp := anonymous$0.public$backing_field_a - label label$ret$0 + var l0$temp: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$T$class_c$g$C()) + inhale acc(T$class_c$g$C(p$c), wildcard) + r$0 := DF$RT$unitValue() + unfold acc(T$class_c$g$C(p$c), wildcard) + a$0 := p$c.bf$public$x + unfold acc(T$class_c$g$A(a$0), wildcard) + l0$temp := a$0.bf$public$a + label lbl$ret$0 } -method public$property_getter_d(this: Ref) returns (ret: Ref) +method pg$public$d(this: Ref) returns (ret: Ref) /predicates_access.kt:(354,368): info: Generated Viper text for accessNullable: -field public$backing_field_a: Ref +field bf$public$a: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -method global$fun_accessNullable$fun_take$NT_class_global$class_A$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessNullable$TF$class_c$g$A(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$n: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_A())) - inhale local$x != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_A(local$x), wildcard) - ret$0 := dom$RuntimeType$unitValue() - if (!(local$x == dom$RuntimeType$nullValue())) { - unfold acc(T_class_global$class_A(local$x), wildcard) - local0$n := local$x.public$backing_field_a + var l0$n: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$T$class_c$g$A())) + inhale p$x != DF$RT$nullValue() ==> acc(T$class_c$g$A(p$x), wildcard) + r$0 := DF$RT$unitValue() + if (!(p$x == DF$RT$nullValue())) { + unfold acc(T$class_c$g$A(p$x), wildcard) + l0$n := p$x.bf$public$a } - label label$ret$0 + label lbl$ret$0 } /predicates_access.kt:(442,452): info: Generated Viper text for accessCast: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(T$class_c$g$A(this), wildcard) } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(U$T$class_c$g$A(this), write) } -method global$fun_accessCast$fun_take$T_class_global$class_A$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessCast$TF$T$class_c$g$A(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$n: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_A()) - inhale acc(T_class_global$class_A(local$x), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := local$x - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$T_class_global$class_B()) - inhale acc(T_class_global$class_B(anonymous$0), wildcard) - unfold acc(T_class_global$class_B(anonymous$0), wildcard) - local0$n := anonymous$0.public$backing_field_b - label label$ret$0 + var l0$n: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$A()) + inhale acc(T$class_c$g$A(p$x), wildcard) + r$0 := DF$RT$unitValue() + a$0 := p$x + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$T$class_c$g$B()) + inhale acc(T$class_c$g$B(a$0), wildcard) + unfold acc(T$class_c$g$B(a$0), wildcard) + l0$n := a$0.bf$public$b + label lbl$ret$0 } /predicates_access.kt:(501,515): info: Generated Viper text for accessSafeCast: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(T$class_c$g$A(this), wildcard) } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(U$T$class_c$g$A(this), write) } -method global$fun_accessSafeCast$fun_take$T_class_global$class_A$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessSafeCast$TF$T$class_c$g$A(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$n: Ref - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_A()) - inhale acc(T_class_global$class_A(local$x), wildcard) - ret$0 := dom$RuntimeType$unitValue() - local0$n := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_B())) { - local0$y := local$x + var l0$n: Ref + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$A()) + inhale acc(T$class_c$g$A(p$x), wildcard) + r$0 := DF$RT$unitValue() + l0$n := DF$RT$intToRef(0) + if (DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$B())) { + l0$y := p$x } else { - local0$y := dom$RuntimeType$nullValue()} - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$y), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_B())) - inhale local0$y != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_B(local0$y), wildcard) - if (!(local0$y == dom$RuntimeType$nullValue())) { - unfold acc(T_class_global$class_B(local0$y), wildcard) - local0$n := local0$y.public$backing_field_b + l0$y := DF$RT$nullValue()} + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$y), DF$RT$nullable(DF$RT$T$class_c$g$B())) + inhale l0$y != DF$RT$nullValue() ==> acc(T$class_c$g$B(l0$y), wildcard) + if (!(l0$y == DF$RT$nullValue())) { + unfold acc(T$class_c$g$B(l0$y), wildcard) + l0$n := l0$y.bf$public$b } - label label$ret$0 + label lbl$ret$0 } /predicates_access.kt:(612,627): info: Generated Viper text for accessSmartCast: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -predicate T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(T_class_global$class_A(special$class$predicate$subject), wildcard) +predicate T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(T$class_c$g$A(this), wildcard) } -predicate Unique$T_class_global$class_A(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_a, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_a), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$A(this: Ref) { + acc(this.bf$public$a, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$a), DF$RT$intType()) } -predicate Unique$T_class_global$class_B(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_b, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_b), - dom$RuntimeType$intType()) && - acc(Unique$T_class_global$class_A(special$class$predicate$subject), write) +predicate U$T$class_c$g$B(this: Ref) { + acc(this.bf$public$b, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$b), DF$RT$intType()) && + acc(U$T$class_c$g$A(this), write) } -method global$fun_accessSmartCast$fun_take$T_class_global$class_A$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$accessSmartCast$TF$T$class_c$g$A(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$n: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_A()) - inhale acc(T_class_global$class_A(local$x), wildcard) - ret$0 := dom$RuntimeType$unitValue() - local0$n := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_B())) { - var anonymous$0: Ref - anonymous$0 := local$x - inhale acc(T_class_global$class_B(anonymous$0), wildcard) - unfold acc(T_class_global$class_B(anonymous$0), wildcard) - local0$n := anonymous$0.public$backing_field_b + var l0$n: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$A()) + inhale acc(T$class_c$g$A(p$x), wildcard) + r$0 := DF$RT$unitValue() + l0$n := DF$RT$intToRef(0) + if (DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$B())) { + var a$0: Ref + a$0 := p$x + inhale acc(T$class_c$g$B(a$0), wildcard) + unfold acc(T$class_c$g$B(a$0), wildcard) + l0$n := a$0.bf$public$b } - label label$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/primary_constructors.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/primary_constructors.fir.diag.txt index 7f182585c32672..2499d7c49a7c34 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/primary_constructors.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/primary_constructors.fir.diag.txt @@ -1,75 +1,65 @@ /primary_constructors.kt:(70,91): info: Generated Viper text for createPrimitiveFields: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_b: Ref +field bf$public$b: Ref -method class_PrimitiveFields$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_PrimitiveFields(local$a: Ref, - local$b: Ref) +method con$c$PrimitiveFields$T$Int$T$Int(p$a: Ref, p$b: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - ensures acc(T_class_global$class_PrimitiveFields(ret), wildcard) - ensures acc(Unique$T_class_global$class_PrimitiveFields(ret), write) - ensures (unfolding acc(T_class_global$class_PrimitiveFields(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_a) == - dom$RuntimeType$intFromRef(local$a) && - dom$RuntimeType$intFromRef(ret.public$backing_field_b) == - dom$RuntimeType$intFromRef(local$b)) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$PrimitiveFields()) + ensures acc(T$class_c$g$PrimitiveFields(ret), wildcard) + ensures acc(U$T$class_c$g$PrimitiveFields(ret), write) + ensures (unfolding acc(T$class_c$g$PrimitiveFields(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$a) == DF$RT$intFromRef(p$a) && + DF$RT$intFromRef(ret.bf$public$b) == DF$RT$intFromRef(p$b)) -method global$fun_createPrimitiveFields$fun_take$$return$T_class_global$class_PrimitiveFields() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_PrimitiveFields()) - ensures acc(T_class_global$class_PrimitiveFields(ret$0), wildcard) +method f$g$createPrimitiveFields$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$PrimitiveFields()) + ensures acc(T$class_c$g$PrimitiveFields(r$0), wildcard) { - ret$0 := class_PrimitiveFields$constructor$fun_take$T_Int$T_Int$return$T_class_global$class_PrimitiveFields(dom$RuntimeType$intToRef(10), - dom$RuntimeType$intToRef(20)) - goto label$ret$0 - label label$ret$0 + r$0 := con$c$PrimitiveFields$T$Int$T$Int(DF$RT$intToRef(10), DF$RT$intToRef(20)) + goto lbl$ret$0 + label lbl$ret$0 } /primary_constructors.kt:(178,193): info: Generated Viper text for createRecursive: -field public$backing_field_a: Ref +field bf$public$a: Ref -method class_Recursive$constructor$fun_take$NT_class_global$class_Recursive$return$T_class_global$class_Recursive(local$a: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Recursive()) - ensures acc(T_class_global$class_Recursive(ret), wildcard) - ensures acc(Unique$T_class_global$class_Recursive(ret), write) - ensures (unfolding acc(T_class_global$class_Recursive(ret), wildcard) in - ret.public$backing_field_a == local$a) +method con$c$Recursive$class_c$g$Recursive(p$a: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Recursive()) + ensures acc(T$class_c$g$Recursive(ret), wildcard) + ensures acc(U$T$class_c$g$Recursive(ret), write) + ensures (unfolding acc(T$class_c$g$Recursive(ret), wildcard) in + ret.bf$public$a == p$a) -method global$fun_createRecursive$fun_take$$return$T_class_global$class_Recursive() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Recursive()) - ensures acc(T_class_global$class_Recursive(ret$0), wildcard) +method f$g$createRecursive$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Recursive()) + ensures acc(T$class_c$g$Recursive(r$0), wildcard) { - ret$0 := class_Recursive$constructor$fun_take$NT_class_global$class_Recursive$return$T_class_global$class_Recursive(dom$RuntimeType$nullValue()) - goto label$ret$0 - label label$ret$0 + r$0 := con$c$Recursive$class_c$g$Recursive(DF$RT$nullValue()) + goto lbl$ret$0 + label lbl$ret$0 } /primary_constructors.kt:(279,296): info: Generated Viper text for createFieldInBody: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_c: Ref +field bf$public$c: Ref -method class_FieldInBody$constructor$fun_take$T_Int$return$T_class_global$class_FieldInBody(local$c: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_FieldInBody()) - ensures acc(T_class_global$class_FieldInBody(ret), wildcard) - ensures acc(Unique$T_class_global$class_FieldInBody(ret), write) - ensures (unfolding acc(T_class_global$class_FieldInBody(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_c) == - dom$RuntimeType$intFromRef(local$c)) +method con$c$FieldInBody$T$Int(p$c: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$FieldInBody()) + ensures acc(T$class_c$g$FieldInBody(ret), wildcard) + ensures acc(U$T$class_c$g$FieldInBody(ret), write) + ensures (unfolding acc(T$class_c$g$FieldInBody(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$c) == DF$RT$intFromRef(p$c)) -method global$fun_createFieldInBody$fun_take$$return$T_class_global$class_FieldInBody() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_FieldInBody()) - ensures acc(T_class_global$class_FieldInBody(ret$0), wildcard) +method f$g$createFieldInBody$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$FieldInBody()) + ensures acc(T$class_c$g$FieldInBody(r$0), wildcard) { - ret$0 := class_FieldInBody$constructor$fun_take$T_Int$return$T_class_global$class_FieldInBody(dom$RuntimeType$intToRef(10)) - goto label$ret$0 - label label$ret$0 + r$0 := con$c$FieldInBody$T$Int(DF$RT$intToRef(10)) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/property_getters.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/property_getters.fir.diag.txt index b864c030e669c5..3658fda379ae6a 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/property_getters.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/property_getters.fir.diag.txt @@ -1,73 +1,72 @@ /property_getters.kt:(102,129): info: Generated Viper text for testPrimitivePropertyGetter: -method global$fun_testPrimitivePropertyGetter$fun_take$T_class_global$class_PrimitiveProperty$return$T_Int(local$pp: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$testPrimitivePropertyGetter$TF$T$class_c$g$PrimitiveProperty(p$pp: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pp), dom$RuntimeType$T_class_global$class_PrimitiveProperty()) - inhale acc(T_class_global$class_PrimitiveProperty(local$pp), wildcard) - anonymous$0 := public$property_getter_nProp(local$pp) - ret$0 := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pp), DF$RT$T$class_c$g$PrimitiveProperty()) + inhale acc(T$class_c$g$PrimitiveProperty(p$pp), wildcard) + a$0 := pg$public$nProp(p$pp) + r$0 := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_nProp(this: Ref) returns (ret: Ref) +method pg$public$nProp(this: Ref) returns (ret: Ref) /property_getters.kt:(286,313): info: Generated Viper text for testReferencePropertyGetter: -method global$fun_testReferencePropertyGetter$fun_take$T_class_global$class_ReferenceProperty$return$T_Unit(local$rp: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testReferencePropertyGetter$TF$T$class_c$g$ReferenceProperty(p$rp: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$pp: Ref - var anonymous$0: Ref - var local0$ppn: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rp), dom$RuntimeType$T_class_global$class_ReferenceProperty()) - inhale acc(T_class_global$class_ReferenceProperty(local$rp), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := public$property_getter_rProp(local$rp) - local0$pp := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$pp), dom$RuntimeType$T_class_global$class_PrimitiveProperty()) - inhale acc(T_class_global$class_PrimitiveProperty(local0$pp), wildcard) - anonymous$1 := public$property_getter_nProp(local0$pp) - local0$ppn := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$ppn), dom$RuntimeType$intType()) - label label$ret$0 + var l0$pp: Ref + var a$0: Ref + var l0$ppn: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rp), DF$RT$T$class_c$g$ReferenceProperty()) + inhale acc(T$class_c$g$ReferenceProperty(p$rp), wildcard) + r$0 := DF$RT$unitValue() + a$0 := pg$public$rProp(p$rp) + l0$pp := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$pp), DF$RT$T$class_c$g$PrimitiveProperty()) + inhale acc(T$class_c$g$PrimitiveProperty(l0$pp), wildcard) + a$1 := pg$public$nProp(l0$pp) + l0$ppn := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$ppn), DF$RT$intType()) + label lbl$ret$0 } -method public$property_getter_nProp(this: Ref) returns (ret: Ref) +method pg$public$nProp(this: Ref) returns (ret: Ref) -method public$property_getter_rProp(this: Ref) returns (ret: Ref) +method pg$public$rProp(this: Ref) returns (ret: Ref) /property_getters.kt:(391,418): info: Generated Viper text for testCascadingPropertyGetter: -method global$fun_testCascadingPropertyGetter$fun_take$T_class_global$class_ReferenceProperty$return$T_Unit(local$rp: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testCascadingPropertyGetter$TF$T$class_c$g$ReferenceProperty(p$rp: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$ppn: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rp), dom$RuntimeType$T_class_global$class_ReferenceProperty()) - inhale acc(T_class_global$class_ReferenceProperty(local$rp), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$2 := public$property_getter_rProp(local$rp) - anonymous$1 := anonymous$2 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$T_class_global$class_PrimitiveProperty()) - inhale acc(T_class_global$class_PrimitiveProperty(anonymous$1), wildcard) - anonymous$0 := public$property_getter_nProp(anonymous$1) - local0$ppn := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$ppn), dom$RuntimeType$intType()) - label label$ret$0 + var l0$ppn: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rp), DF$RT$T$class_c$g$ReferenceProperty()) + inhale acc(T$class_c$g$ReferenceProperty(p$rp), wildcard) + r$0 := DF$RT$unitValue() + a$2 := pg$public$rProp(p$rp) + a$1 := a$2 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$T$class_c$g$PrimitiveProperty()) + inhale acc(T$class_c$g$PrimitiveProperty(a$1), wildcard) + a$0 := pg$public$nProp(a$1) + l0$ppn := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$ppn), DF$RT$intType()) + label lbl$ret$0 } -method public$property_getter_nProp(this: Ref) returns (ret: Ref) +method pg$public$nProp(this: Ref) returns (ret: Ref) -method public$property_getter_rProp(this: Ref) returns (ret: Ref) - +method pg$public$rProp(this: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/secondary_constructors.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/secondary_constructors.fir.diag.txt index 3d1047ace9255c..16c39d18251137 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/secondary_constructors.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/secondary_constructors.fir.diag.txt @@ -1,60 +1,53 @@ /secondary_constructors.kt:(249,271): info: Generated Viper text for onlySecondConstructors: -field public$backing_field_a: Ref +field bf$public$a: Ref -method class_NoPrimaryConstructor$constructor$fun_take$T_Boolean$return$T_class_global$class_NoPrimaryConstructor(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_NoPrimaryConstructor()) - ensures acc(T_class_global$class_NoPrimaryConstructor(ret), wildcard) - ensures acc(Unique$T_class_global$class_NoPrimaryConstructor(ret), write) +method con$c$NoPrimaryConstructor$T$Boolean(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$NoPrimaryConstructor()) + ensures acc(T$class_c$g$NoPrimaryConstructor(ret), wildcard) + ensures acc(U$T$class_c$g$NoPrimaryConstructor(ret), write) -method class_NoPrimaryConstructor$constructor$fun_take$T_Int$return$T_class_global$class_NoPrimaryConstructor(local$n: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_NoPrimaryConstructor()) - ensures acc(T_class_global$class_NoPrimaryConstructor(ret), wildcard) - ensures acc(Unique$T_class_global$class_NoPrimaryConstructor(ret), write) +method con$c$NoPrimaryConstructor$T$Int(p$n: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$NoPrimaryConstructor()) + ensures acc(T$class_c$g$NoPrimaryConstructor(ret), wildcard) + ensures acc(U$T$class_c$g$NoPrimaryConstructor(ret), write) -method global$fun_onlySecondConstructors$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$onlySecondConstructors$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$npc1: Ref - var local0$npc2: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$npc1 := class_NoPrimaryConstructor$constructor$fun_take$T_Boolean$return$T_class_global$class_NoPrimaryConstructor(dom$RuntimeType$boolToRef(true)) - local0$npc2 := class_NoPrimaryConstructor$constructor$fun_take$T_Int$return$T_class_global$class_NoPrimaryConstructor(dom$RuntimeType$intToRef(42)) - label label$ret$0 + var l0$npc1: Ref + var l0$npc2: Ref + r$0 := DF$RT$unitValue() + l0$npc1 := con$c$NoPrimaryConstructor$T$Boolean(DF$RT$boolToRef(true)) + l0$npc2 := con$c$NoPrimaryConstructor$T$Int(DF$RT$intToRef(42)) + label lbl$ret$0 } /secondary_constructors.kt:(365,392): info: Generated Viper text for primaryAndSecondConstructor: -field public$backing_field_a: Ref +field bf$public$a: Ref -method class_BothConstructors$constructor$fun_take$T_Boolean$return$T_class_global$class_BothConstructors(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_BothConstructors()) - ensures acc(T_class_global$class_BothConstructors(ret), wildcard) - ensures acc(Unique$T_class_global$class_BothConstructors(ret), write) +method con$c$BothConstructors$T$Boolean(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$BothConstructors()) + ensures acc(T$class_c$g$BothConstructors(ret), wildcard) + ensures acc(U$T$class_c$g$BothConstructors(ret), write) -method class_BothConstructors$constructor$fun_take$T_Int$return$T_class_global$class_BothConstructors(local$a: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_BothConstructors()) - ensures acc(T_class_global$class_BothConstructors(ret), wildcard) - ensures acc(Unique$T_class_global$class_BothConstructors(ret), write) - ensures (unfolding acc(T_class_global$class_BothConstructors(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_a) == - dom$RuntimeType$intFromRef(local$a)) +method con$c$BothConstructors$T$Int(p$a: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$BothConstructors()) + ensures acc(T$class_c$g$BothConstructors(ret), wildcard) + ensures acc(U$T$class_c$g$BothConstructors(ret), write) + ensures (unfolding acc(T$class_c$g$BothConstructors(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$a) == DF$RT$intFromRef(p$a)) -method global$fun_primaryAndSecondConstructor$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$primaryAndSecondConstructor$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$bc1: Ref - var local0$bc2: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$bc1 := class_BothConstructors$constructor$fun_take$T_Boolean$return$T_class_global$class_BothConstructors(dom$RuntimeType$boolToRef(false)) - local0$bc2 := class_BothConstructors$constructor$fun_take$T_Int$return$T_class_global$class_BothConstructors(dom$RuntimeType$intToRef(42)) - label label$ret$0 + var l0$bc1: Ref + var l0$bc2: Ref + r$0 := DF$RT$unitValue() + l0$bc1 := con$c$BothConstructors$T$Boolean(DF$RT$boolToRef(false)) + l0$bc2 := con$c$BothConstructors$T$Int(DF$RT$intToRef(42)) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/setters.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/setters.fir.diag.txt index 387dfee1610073..cf0bcc950c7836 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/setters.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/setters.fir.diag.txt @@ -1,98 +1,92 @@ /setters.kt:(103,127): info: Generated Viper text for testPrimitiveFieldSetter: -field public$backing_field_a: Ref +field bf$public$a: Ref -method global$fun_testPrimitiveFieldSetter$fun_take$T_class_global$class_PrimitiveField$return$T_Unit(local$pf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testPrimitiveFieldSetter$TF$T$class_c$g$PrimitiveField(p$pf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pf), dom$RuntimeType$T_class_global$class_PrimitiveField()) - inhale acc(T_class_global$class_PrimitiveField(local$pf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - inhale acc(local$pf.public$backing_field_a, write) - local$pf.public$backing_field_a := dom$RuntimeType$intToRef(0) - exhale acc(local$pf.public$backing_field_a, write) - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pf), DF$RT$T$class_c$g$PrimitiveField()) + inhale acc(T$class_c$g$PrimitiveField(p$pf), wildcard) + r$0 := DF$RT$unitValue() + inhale acc(p$pf.bf$public$a, write) + p$pf.bf$public$a := DF$RT$intToRef(0) + exhale acc(p$pf.bf$public$a, write) + label lbl$ret$0 } /setters.kt:(170,194): info: Generated Viper text for testReferenceFieldSetter: -field public$backing_field_a: Ref +field bf$public$a: Ref -field public$backing_field_pf: Ref +field bf$public$pf: Ref -method class_PrimitiveField$constructor$fun_take$T_Int$return$T_class_global$class_PrimitiveField(local$a: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_PrimitiveField()) - ensures acc(T_class_global$class_PrimitiveField(ret), wildcard) - ensures acc(Unique$T_class_global$class_PrimitiveField(ret), write) +method con$c$PrimitiveField$T$Int(p$a: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$PrimitiveField()) + ensures acc(T$class_c$g$PrimitiveField(ret), wildcard) + ensures acc(U$T$class_c$g$PrimitiveField(ret), write) -method global$fun_testReferenceFieldSetter$fun_take$T_class_global$class_ReferenceField$return$T_Unit(local$rf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testReferenceFieldSetter$TF$T$class_c$g$ReferenceField(p$rf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rf), dom$RuntimeType$T_class_global$class_ReferenceField()) - inhale acc(T_class_global$class_ReferenceField(local$rf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := class_PrimitiveField$constructor$fun_take$T_Int$return$T_class_global$class_PrimitiveField(dom$RuntimeType$intToRef(0)) - inhale acc(local$rf.public$backing_field_pf, write) - local$rf.public$backing_field_pf := anonymous$0 - exhale acc(local$rf.public$backing_field_pf, write) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rf), DF$RT$T$class_c$g$ReferenceField()) + inhale acc(T$class_c$g$ReferenceField(p$rf), wildcard) + r$0 := DF$RT$unitValue() + a$0 := con$c$PrimitiveField$T$Int(DF$RT$intToRef(0)) + inhale acc(p$rf.bf$public$pf, write) + p$rf.bf$public$pf := a$0 + exhale acc(p$rf.bf$public$pf, write) + label lbl$ret$0 } /setters.kt:(427,454): info: Generated Viper text for testPrimitivePropertySetter: -method global$fun_testPrimitivePropertySetter$fun_take$T_class_global$class_PrimitiveProperty$return$T_Unit(local$pp: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testPrimitivePropertySetter$TF$T$class_c$g$PrimitiveProperty(p$pp: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pp), dom$RuntimeType$T_class_global$class_PrimitiveProperty()) - inhale acc(T_class_global$class_PrimitiveProperty(local$pp), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := public$property_setter_aProp(local$pp, dom$RuntimeType$intToRef(0)) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pp), DF$RT$T$class_c$g$PrimitiveProperty()) + inhale acc(T$class_c$g$PrimitiveProperty(p$pp), wildcard) + r$0 := DF$RT$unitValue() + a$0 := ps$public$aProp(p$pp, DF$RT$intToRef(0)) + label lbl$ret$0 } -method public$property_getter_aProp(this: Ref) returns (ret: Ref) +method pg$public$aProp(this: Ref) returns (ret: Ref) -method public$property_setter_aProp(this: Ref, value: Ref) - returns (ret: Ref) +method ps$public$aProp(this: Ref, value: Ref) returns (ret: Ref) /setters.kt:(504,531): info: Generated Viper text for testReferencePropertySetter: -method class_PrimitiveProperty$constructor$fun_take$$return$T_class_global$class_PrimitiveProperty() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_PrimitiveProperty()) - ensures acc(T_class_global$class_PrimitiveProperty(ret), wildcard) - ensures acc(Unique$T_class_global$class_PrimitiveProperty(ret), write) +method con$c$PrimitiveProperty$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$PrimitiveProperty()) + ensures acc(T$class_c$g$PrimitiveProperty(ret), wildcard) + ensures acc(U$T$class_c$g$PrimitiveProperty(ret), write) -method global$fun_testReferencePropertySetter$fun_take$T_class_global$class_ReferenceProperty$return$T_Unit(local$rp: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testReferencePropertySetter$TF$T$class_c$g$ReferenceProperty(p$rp: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rp), dom$RuntimeType$T_class_global$class_ReferenceProperty()) - inhale acc(T_class_global$class_ReferenceProperty(local$rp), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$1 := class_PrimitiveProperty$constructor$fun_take$$return$T_class_global$class_PrimitiveProperty() - anonymous$0 := public$property_setter_ppProp(local$rp, anonymous$1) - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rp), DF$RT$T$class_c$g$ReferenceProperty()) + inhale acc(T$class_c$g$ReferenceProperty(p$rp), wildcard) + r$0 := DF$RT$unitValue() + a$1 := con$c$PrimitiveProperty$() + a$0 := ps$public$ppProp(p$rp, a$1) + label lbl$ret$0 } -method public$property_getter_aProp(this: Ref) returns (ret: Ref) +method pg$public$aProp(this: Ref) returns (ret: Ref) -method public$property_getter_ppProp(this: Ref) returns (ret: Ref) +method pg$public$ppProp(this: Ref) returns (ret: Ref) -method public$property_setter_aProp(this: Ref, value: Ref) - returns (ret: Ref) +method ps$public$aProp(this: Ref, value: Ref) returns (ret: Ref) -method public$property_setter_ppProp(this: Ref, value: Ref) - returns (ret: Ref) - +method ps$public$ppProp(this: Ref, value: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/subtyping.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/subtyping.fir.diag.txt index 2ae8e6642ba26f..4a3d93d922c2be 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/subtyping.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/subtyping.fir.diag.txt @@ -1,53 +1,47 @@ /subtyping.kt:(80,89): info: Generated Viper text for smartCast: -method global$fun_smartCast$fun_take$NT_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$smartCast$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - if (local$x == dom$RuntimeType$nullValue()) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + if (p$x == DF$RT$nullValue()) { + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 } else { - ret$0 := local$x - goto label$ret$0 + r$0 := p$x + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } /subtyping.kt:(187,202): info: Generated Viper text for returnSubtyping: -method global$fun_returnSubtyping$fun_take$$return$NT_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$returnSubtyping$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + label lbl$ret$0 } /subtyping.kt:(233,252): info: Generated Viper text for assignmentSubtyping: -method global$fun_assignmentSubtyping$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$assignmentSubtyping$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$x := dom$RuntimeType$boolToRef(false) - local0$x := dom$RuntimeType$boolToRef(true) - label label$ret$0 + var l0$x: Ref + r$0 := DF$RT$unitValue() + l0$x := DF$RT$boolToRef(false) + l0$x := DF$RT$boolToRef(true) + label lbl$ret$0 } /subtyping.kt:(358,384): info: Generated Viper text for functionParameterSubtyping: -method global$fun_functionParameterSubtyping$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$functionParameterSubtyping$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$fun_nullableParameter$fun_take$NT_Boolean$return$T_Unit(dom$RuntimeType$boolToRef(false)) - label label$ret$0 + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := f$g$nullableParameter$TF$Boolean(DF$RT$boolToRef(false)) + label lbl$ret$0 } -method global$fun_nullableParameter$fun_take$NT_Boolean$return$T_Unit(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) - +method f$g$nullableParameter$TF$Boolean(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/unique_predicates.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/unique_predicates.fir.diag.txt index 712ccd10835fbc..c869918aeaf458 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/classes/unique_predicates.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/classes/unique_predicates.fir.diag.txt @@ -1,199 +1,183 @@ /unique_predicates.kt:(269,283): info: Generated Viper text for unique_foo_arg: -field public$backing_field_w: Ref +field bf$public$w: Ref -field public$backing_field_x: Ref +field bf$public$x: Ref -field public$backing_field_y: Ref +field bf$public$y: Ref -field public$backing_field_z: Ref +field bf$public$z: Ref -predicate T_class_global$class_Foo(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_w, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_w), - dom$RuntimeType$intType()) && - acc(special$class$predicate$subject.public$backing_field_y, wildcard) && - acc(T_class_global$class_T(special$class$predicate$subject.public$backing_field_y), wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_y), - dom$RuntimeType$T_class_global$class_T()) && - acc(T_class_global$class_S(special$class$predicate$subject), wildcard) +predicate T$class_c$g$Foo(this: Ref) { + acc(this.bf$public$w, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$w), DF$RT$intType()) && + acc(this.bf$public$y, wildcard) && + acc(T$class_c$g$T(this.bf$public$y), wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$y), DF$RT$T$class_c$g$T()) && + acc(T$class_c$g$S(this), wildcard) } -predicate T_class_global$class_S(special$class$predicate$subject: Ref) { +predicate T$class_c$g$S(this: Ref) { true } -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_Foo(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_w, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_w), - dom$RuntimeType$intType()) && - acc(special$class$predicate$subject.public$backing_field_x, write) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$intType()) && - acc(special$class$predicate$subject.public$backing_field_y, wildcard) && - acc(T_class_global$class_T(special$class$predicate$subject.public$backing_field_y), wildcard) && - acc(Unique$T_class_global$class_T(special$class$predicate$subject.public$backing_field_y), write) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_y), - dom$RuntimeType$T_class_global$class_T()) && - acc(special$class$predicate$subject.public$backing_field_z, write) && - acc(T_class_global$class_T(special$class$predicate$subject.public$backing_field_z), wildcard) && - acc(Unique$T_class_global$class_T(special$class$predicate$subject.public$backing_field_z), write) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_z), - dom$RuntimeType$T_class_global$class_T()) && - acc(Unique$T_class_global$class_S(special$class$predicate$subject), write) +predicate U$T$class_c$g$Foo(this: Ref) { + acc(this.bf$public$w, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$w), DF$RT$intType()) && + acc(this.bf$public$x, write) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$intType()) && + acc(this.bf$public$y, wildcard) && + acc(T$class_c$g$T(this.bf$public$y), wildcard) && + acc(U$T$class_c$g$T(this.bf$public$y), write) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$y), DF$RT$T$class_c$g$T()) && + acc(this.bf$public$z, write) && + acc(T$class_c$g$T(this.bf$public$z), wildcard) && + acc(U$T$class_c$g$T(this.bf$public$z), write) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$z), DF$RT$T$class_c$g$T()) && + acc(U$T$class_c$g$S(this), write) } -predicate Unique$T_class_global$class_S(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$S(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_unique_foo_arg$fun_take$T_class_global$class_Foo$return$T_Unit(local$foo: Ref) - returns (ret$0: Ref) - requires acc(Unique$T_class_global$class_Foo(local$foo), write) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$unique_foo_arg$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + requires acc(U$T$class_c$g$Foo(p$foo), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /unique_predicates.kt:(310,329): info: Generated Viper text for nullable_unique_arg: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_nullable_unique_arg$fun_take$NT_class_global$class_T$return$T_Unit(local$t: Ref) - returns (ret$0: Ref) - requires local$t != dom$RuntimeType$nullValue() ==> - acc(Unique$T_class_global$class_T(local$t), write) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$nullable_unique_arg$TF$class_c$g$T(p$t: Ref) returns (r$0: Ref) + requires p$t != DF$RT$nullValue() ==> acc(U$T$class_c$g$T(p$t), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$t), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_T())) - inhale local$t != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_T(local$t), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$t), DF$RT$nullable(DF$RT$T$class_c$g$T())) + inhale p$t != DF$RT$nullValue() ==> acc(T$class_c$g$T(p$t), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /unique_predicates.kt:(353,372): info: Generated Viper text for borrowed_unique_arg: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_borrowed_unique_arg$fun_take$T_class_global$class_T$return$T_Unit(local$t: Ref) - returns (ret$0: Ref) - requires acc(Unique$T_class_global$class_T(local$t), write) - ensures acc(Unique$T_class_global$class_T(local$t), write) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$borrowed_unique_arg$TF$T$class_c$g$T(p$t: Ref) + returns (r$0: Ref) + requires acc(U$T$class_c$g$T(p$t), write) + ensures acc(U$T$class_c$g$T(p$t), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$t), dom$RuntimeType$T_class_global$class_T()) - inhale acc(T_class_global$class_T(local$t), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$t), DF$RT$T$class_c$g$T()) + inhale acc(T$class_c$g$T(p$t), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /unique_predicates.kt:(424,439): info: Generated Viper text for unique_receiver: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_unique_receiver$fun_take$T_class_global$class_T$return$T_Unit(this: Ref) - returns (ret$0: Ref) - requires acc(Unique$T_class_global$class_T(this), write) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$unique_receiver$TF$T$class_c$g$T(this: Ref) returns (r$0: Ref) + requires acc(U$T$class_c$g$T(this), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_T()) - inhale acc(T_class_global$class_T(this), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$T()) + inhale acc(T$class_c$g$T(this), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /unique_predicates.kt:(488,512): info: Generated Viper text for borrowed_unique_receiver: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_borrowed_unique_receiver$fun_take$T_class_global$class_T$return$T_Unit(this: Ref) - returns (ret$0: Ref) - requires acc(Unique$T_class_global$class_T(this), write) - ensures acc(Unique$T_class_global$class_T(this), write) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$borrowed_unique_receiver$TF$T$class_c$g$T(this: Ref) + returns (r$0: Ref) + requires acc(U$T$class_c$g$T(this), write) + ensures acc(U$T$class_c$g$T(this), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_T()) - inhale acc(T_class_global$class_T(this), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$T()) + inhale acc(T$class_c$g$T(this), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /unique_predicates.kt:(531,544): info: Generated Viper text for unique_result: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method class_T$constructor$fun_take$$return$T_class_global$class_T() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_T()) - ensures acc(T_class_global$class_T(ret), wildcard) - ensures acc(Unique$T_class_global$class_T(ret), write) +method con$c$T$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$T()) + ensures acc(T$class_c$g$T(ret), wildcard) + ensures acc(U$T$class_c$g$T(ret), write) -method global$fun_unique_result$fun_take$$return$T_class_global$class_T() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_T()) - ensures acc(T_class_global$class_T(ret$0), wildcard) - ensures acc(Unique$T_class_global$class_T(ret$0), write) +method f$g$unique_result$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$T()) + ensures acc(T$class_c$g$T(r$0), wildcard) + ensures acc(U$T$class_c$g$T(r$0), write) { - ret$0 := class_T$constructor$fun_take$$return$T_class_global$class_T() - goto label$ret$0 - label label$ret$0 + r$0 := con$c$T$() + goto lbl$ret$0 + label lbl$ret$0 } /unique_predicates.kt:(579,601): info: Generated Viper text for unique_nullable_result: -predicate T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate T$class_c$g$T(this: Ref) { true } -predicate Unique$T_class_global$class_T(special$class$predicate$subject: Ref) { +predicate U$T$class_c$g$T(this: Ref) { true } -method global$fun_unique_nullable_result$fun_take$$return$NT_class_global$class_T() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_T())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_T(ret$0), wildcard) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(Unique$T_class_global$class_T(ret$0), write) +method f$g$unique_nullable_result$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$T())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$T(r$0), wildcard) + ensures r$0 != DF$RT$nullValue() ==> acc(U$T$class_c$g$T(r$0), write) { - ret$0 := dom$RuntimeType$nullValue() - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue() + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/exp_side_effects.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/exp_side_effects.fir.diag.txt index 3d2a5663769091..12f8ce89bc10de 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/exp_side_effects.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/exp_side_effects.fir.diag.txt @@ -1,37 +1,36 @@ /exp_side_effects.kt:(185,189): info: Generated Viper text for test: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_getFoo$fun_take$$return$T_class_global$class_Foo() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Foo()) - ensures acc(T_class_global$class_Foo(ret), wildcard) +method f$g$getFoo$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Foo()) + ensures acc(T$class_c$g$Foo(ret), wildcard) -method global$fun_sideEffect$fun_take$$return$T_Int() returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$sideEffect$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_test$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$test$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var local0$y: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$fun_getFoo$fun_take$$return$T_class_global$class_Foo() - anonymous$1 := global$fun_sideEffect$fun_take$$return$T_Int() - inhale acc(anonymous$0.public$backing_field_x, write) - anonymous$0.public$backing_field_x := anonymous$1 - exhale acc(anonymous$0.public$backing_field_x, write) - anonymous$3 := global$fun_getFoo$fun_take$$return$T_class_global$class_Foo() - inhale acc(anonymous$3.public$backing_field_x, write) - anonymous$2 := anonymous$3.public$backing_field_x - exhale acc(anonymous$3.public$backing_field_x, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$4 := global$fun_sideEffect$fun_take$$return$T_Int() - local0$y := special$plusInts(anonymous$2, anonymous$4) - label label$ret$0 + var a$0: Ref + var a$1: Ref + var l0$y: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + r$0 := DF$RT$unitValue() + a$0 := f$g$getFoo$TF$() + a$1 := f$g$sideEffect$TF$() + inhale acc(a$0.bf$public$x, write) + a$0.bf$public$x := a$1 + exhale acc(a$0.bf$public$x, write) + a$3 := f$g$getFoo$TF$() + inhale acc(a$3.bf$public$x, write) + a$2 := a$3.bf$public$x + exhale acc(a$3.bf$public$x, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$4 := f$g$sideEffect$TF$() + l0$y := sp$plusInts(a$2, a$4) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/function_call.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/function_call.fir.diag.txt index 7b5b4235019d65..a72501c1c53513 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/function_call.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/function_call.fir.diag.txt @@ -1,37 +1,33 @@ /function_call.kt:(118,130): info: Generated Viper text for functionCall: -method global$fun_f$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$f$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_functionCall$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$functionCall$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$fun_f$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(0)) - anonymous$1 := global$fun_f$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(0)) - label label$ret$0 + var a$0: Ref + var a$1: Ref + r$0 := DF$RT$unitValue() + a$0 := f$g$f$TF$T$Int(DF$RT$intToRef(0)) + a$1 := f$g$f$TF$T$Int(DF$RT$intToRef(0)) + label lbl$ret$0 } /function_call.kt:(160,178): info: Generated Viper text for functionCallNested: -method global$fun_f$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$f$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_functionCallNested$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$functionCallNested$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$2 := global$fun_f$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(0)) - anonymous$1 := global$fun_f$fun_take$T_Int$return$T_Int(anonymous$2) - anonymous$0 := global$fun_f$fun_take$T_Int$return$T_Int(anonymous$1) - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + r$0 := DF$RT$unitValue() + a$2 := f$g$f$TF$T$Int(DF$RT$intToRef(0)) + a$1 := f$g$f$TF$T$Int(a$2) + a$0 := f$g$f$TF$T$Int(a$1) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/if.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/if.fir.diag.txt index 82fadae25e32f8..553c6697a5e10c 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/if.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/if.fir.diag.txt @@ -1,57 +1,54 @@ /if.kt:(23,31): info: Generated Viper text for simpleIf: -method global$fun_simpleIf$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$simpleIf$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { if (true) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } /if.kt:(116,129): info: Generated Viper text for ifOnParameter: -method global$fun_ifOnParameter$fun_take$T_Boolean$return$T_Int(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$ifOnParameter$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$b)) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$b)) { + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } /if.kt:(221,235): info: Generated Viper text for ifAsExpression: -method global$fun_ifAsExpression$fun_take$$return$T_Boolean() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$ifAsExpression$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local0$b: Ref - local0$b := dom$RuntimeType$boolToRef(false) - if (dom$RuntimeType$boolFromRef(local0$b)) { - var anonymous$0: Ref - anonymous$0 := global$fun_simpleIf$fun_take$$return$T_Int() - ret$0 := dom$RuntimeType$boolToRef(false) + var l0$b: Ref + l0$b := DF$RT$boolToRef(false) + if (DF$RT$boolFromRef(l0$b)) { + var a$0: Ref + a$0 := f$g$simpleIf$TF$() + r$0 := DF$RT$boolToRef(false) } else { - var anonymous$1: Ref - anonymous$1 := global$fun_ifOnParameter$fun_take$T_Boolean$return$T_Int(local0$b) - ret$0 := dom$RuntimeType$boolToRef(true) + var a$1: Ref + a$1 := f$g$ifOnParameter$TF$T$Boolean(l0$b) + r$0 := DF$RT$boolToRef(true) } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_ifOnParameter$fun_take$T_Boolean$return$T_Int(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$ifOnParameter$TF$T$Boolean(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_simpleIf$fun_take$$return$T_Int() returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$simpleIf$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop.fir.diag.txt index c2c89974c855c3..3779bcd3d85c58 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop.fir.diag.txt @@ -1,45 +1,42 @@ /loop.kt:(23,32): info: Generated Viper text for whileLoop: -method global$fun_whileLoop$fun_take$T_Boolean$return$T_Boolean(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$whileLoop$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var local1$a: Ref - var local1$c: Ref - local1$a := dom$RuntimeType$intToRef(1) - local1$c := dom$RuntimeType$intToRef(2) - anonymous$0 := local$b + var l1$a: Ref + var l1$c: Ref + l1$a := DF$RT$intToRef(1) + l1$c := DF$RT$intToRef(2) + a$0 := p$b } - label label$break$0 - ret$0 := dom$RuntimeType$boolToRef(false) - goto label$ret$0 - label label$ret$0 + label lbl$break$0 + r$0 := DF$RT$boolToRef(false) + goto lbl$ret$0 + label lbl$ret$0 } /loop.kt:(138,160): info: Generated Viper text for whileFunctionCondition: -method global$fun_whileFunctionCondition$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$whileFunctionCondition$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := global$fun_whileLoop$fun_take$T_Boolean$return$T_Boolean(dom$RuntimeType$boolToRef(true)) - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := f$g$whileLoop$TF$T$Boolean(DF$RT$boolToRef(true)) + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - anonymous$0 := global$fun_whileLoop$fun_take$T_Boolean$return$T_Boolean(dom$RuntimeType$boolToRef(true)) + a$0 := f$g$whileLoop$TF$T$Boolean(DF$RT$boolToRef(true)) } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } -method global$fun_whileLoop$fun_take$T_Boolean$return$T_Boolean(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) +method f$g$whileLoop$TF$T$Boolean(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop_invariants.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop_invariants.fir.diag.txt index 19f5a45726ef13..e82e27a4d3a02f 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop_invariants.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/loop_invariants.fir.diag.txt @@ -1,93 +1,87 @@ /loop_invariants.kt:(146,168): info: Generated Viper text for dynamicLambdaInvariant: -method global$fun_dynamicLambdaInvariant$fun_take$fun_take$$return$T_Int$return$T_Unit(local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$dynamicLambdaInvariant$TF$TF$(p$f: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$functionType()) - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$functionType()) + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := f$g$returnsBoolean$TF$() + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - var anonymous$2: Ref - anonymous$2 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() + var a$1: Ref + var a$2: Ref + a$2 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$0 := f$g$returnsBoolean$TF$() } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } -method global$fun_returnsBoolean$fun_take$$return$T_Boolean() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) +method f$g$returnsBoolean$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) /loop_invariants.kt:(241,259): info: Generated Viper text for functionAssignment: -method global$fun_functionAssignment$fun_take$fun_take$$return$T_Int$return$T_Unit(local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$functionAssignment$TF$TF$(p$f: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$g: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$functionType()) - ret$0 := dom$RuntimeType$unitValue() - local0$g := local$f - label label$continue$0 - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var l0$g: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$functionType()) + r$0 := DF$RT$unitValue() + l0$g := p$f + label lbl$continue$0 + a$0 := f$g$returnsBoolean$TF$() + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - var anonymous$2: Ref - anonymous$2 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() + var a$1: Ref + var a$2: Ref + a$2 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$0 := f$g$returnsBoolean$TF$() } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } -method global$fun_returnsBoolean$fun_take$$return$T_Boolean() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) +method f$g$returnsBoolean$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) /loop_invariants.kt:(346,375): info: Generated Viper text for conditionalFunctionAssignment: -method global$fun_conditionalFunctionAssignment$fun_take$T_Boolean$fun_take$$return$T_Int$fun_take$$return$T_Int$return$T_Unit(local$b: Ref, - local$f: Ref, local$h: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$conditionalFunctionAssignment$TF$T$Boolean$TF$$TF$(p$b: Ref, p$f: Ref, + p$h: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$g: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$functionType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$h), dom$RuntimeType$functionType()) - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(local$b)) { - local0$g := local$f + var l0$g: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$functionType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$h), DF$RT$functionType()) + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(p$b)) { + l0$g := p$f } else { - local0$g := local$h} - label label$continue$0 - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + l0$g := p$h} + label lbl$continue$0 + a$0 := f$g$returnsBoolean$TF$() + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - var anonymous$2: Ref - anonymous$2 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$0 := global$fun_returnsBoolean$fun_take$$return$T_Boolean() + var a$1: Ref + var a$2: Ref + a$2 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$0 := f$g$returnsBoolean$TF$() } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } -method global$fun_returnsBoolean$fun_take$$return$T_Boolean() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) - +method f$g$returnsBoolean$TF$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/non-local-returns.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/non-local-returns.fir.diag.txt index 608955debfd42c..e052b61e819ed1 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/non-local-returns.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/non-local-returns.fir.diag.txt @@ -1,114 +1,111 @@ /non-local-returns.kt:(155,167): info: Generated Viper text for simpleReturn: -method global$fun_simpleReturn$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$simpleReturn$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 - ret$2 := anonymous$0 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + a$0 := DF$RT$intToRef(0) + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 + r$2 := a$0 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /non-local-returns.kt:(238,252): info: Generated Viper text for returnAtInline: -method global$fun_returnAtInline$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$returnAtInline$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := dom$RuntimeType$intToRef(1) - goto label$ret$2 - ret$2 := anonymous$0 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + a$0 := DF$RT$intToRef(0) + r$2 := DF$RT$intToRef(1) + goto lbl$ret$2 + r$2 := a$0 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /non-local-returns.kt:(330,342): info: Generated Viper text for doubleInvoke: -method global$fun_doubleInvoke$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$doubleInvoke$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var ret$3: Ref - var ret$4: Ref - var anonymous$1: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - anonymous$1 := dom$RuntimeType$intToRef(0) - ret$4 := dom$RuntimeType$intToRef(1) - goto label$ret$4 - ret$4 := anonymous$1 - goto label$ret$4 - label label$ret$4 - ret$3 := ret$4 - goto label$ret$3 - label label$ret$3 - ret$2 := dom$RuntimeType$intToRef(2) - goto label$ret$2 - ret$2 := anonymous$0 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + var r$3: Ref + var r$4: Ref + var a$1: Ref + a$0 := DF$RT$intToRef(0) + a$1 := DF$RT$intToRef(0) + r$4 := DF$RT$intToRef(1) + goto lbl$ret$4 + r$4 := a$1 + goto lbl$ret$4 + label lbl$ret$4 + r$3 := r$4 + goto lbl$ret$3 + label lbl$ret$3 + r$2 := DF$RT$intToRef(2) + goto lbl$ret$2 + r$2 := a$0 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /non-local-returns.kt:(567,573): info: Generated Viper text for nested: -method global$fun_nested$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$nested$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var ret$3: Ref - var ret$4: Ref - var anonymous$1: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - anonymous$1 := dom$RuntimeType$intToRef(1) - ret$4 := dom$RuntimeType$intToRef(2) - goto label$ret$4 - ret$2 := dom$RuntimeType$intToRef(3) - goto label$ret$2 - ret$0 := dom$RuntimeType$intToRef(4) - goto label$ret$0 - ret$4 := anonymous$1 - goto label$ret$4 - label label$ret$4 - ret$3 := ret$4 - goto label$ret$3 - label label$ret$3 - ret$2 := dom$RuntimeType$intToRef(5) - goto label$ret$2 - ret$2 := anonymous$0 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + var r$3: Ref + var r$4: Ref + var a$1: Ref + a$0 := DF$RT$intToRef(0) + a$1 := DF$RT$intToRef(1) + r$4 := DF$RT$intToRef(2) + goto lbl$ret$4 + r$2 := DF$RT$intToRef(3) + goto lbl$ret$2 + r$0 := DF$RT$intToRef(4) + goto lbl$ret$0 + r$4 := a$1 + goto lbl$ret$4 + label lbl$ret$4 + r$3 := r$4 + goto lbl$ret$3 + label lbl$ret$3 + r$2 := DF$RT$intToRef(5) + goto lbl$ret$2 + r$2 := a$0 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/recursion.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/recursion.fir.diag.txt index 167c2ddf3b62e6..52d0f6b756c5ca 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/recursion.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/recursion.fir.diag.txt @@ -1,9 +1,9 @@ /recursion.kt:(23,32): info: Generated Viper text for recursive: -method global$fun_recursive$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$recursive$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - ret$0 := dom$RuntimeType$unitValue() - ret$0 := global$fun_recursive$fun_take$$return$T_Unit() - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$unitValue() + r$0 := f$g$recursive$TF$() + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/return_break_continue.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/return_break_continue.fir.diag.txt index 2dc31177fd3c9c..1445d363b56dad 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/return_break_continue.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/return_break_continue.fir.diag.txt @@ -1,227 +1,220 @@ /return_break_continue.kt:(23,33): info: Generated Viper text for testReturn: -method global$fun_testReturn$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$testReturn$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 + label lbl$ret$0 } /return_break_continue.kt:(76,90): info: Generated Viper text for returnFromLoop: -method global$fun_returnFromLoop$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$returnFromLoop$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - label label$continue$0 - anonymous$0 := dom$RuntimeType$boolToRef(true) - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) + var a$0: Ref + label lbl$continue$0 + a$0 := DF$RT$boolToRef(true) + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - anonymous$0 := dom$RuntimeType$boolToRef(true) + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + a$0 := DF$RT$boolToRef(true) } - label label$break$0 - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 - label label$ret$0 + label lbl$break$0 + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 + label lbl$ret$0 } /return_break_continue.kt:(162,172): info: Generated Viper text for whileBreak: -method global$fun_whileBreak$fun_take$T_Boolean$return$T_Int(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$whileBreak$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$i: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - local0$i := dom$RuntimeType$intToRef(0) - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) + var l0$i: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + l0$i := DF$RT$intToRef(0) + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - local0$i := dom$RuntimeType$intToRef(1) - goto label$break$0 - anonymous$0 := local$b + l0$i := DF$RT$intToRef(1) + goto lbl$break$0 + a$0 := p$b } - label label$break$0 - ret$0 := local0$i - goto label$ret$0 - label label$ret$0 + label lbl$break$0 + r$0 := l0$i + goto lbl$ret$0 + label lbl$ret$0 } /return_break_continue.kt:(276,289): info: Generated Viper text for whileContinue: -method global$fun_whileContinue$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$whileContinue$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$b: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$b := dom$RuntimeType$boolToRef(true) - label label$continue$0 - anonymous$0 := local0$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var l0$b: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + l0$b := DF$RT$boolToRef(true) + label lbl$continue$0 + a$0 := l0$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - local0$b := dom$RuntimeType$boolToRef(false) - goto label$continue$0 - anonymous$0 := local0$b + l0$b := DF$RT$boolToRef(false) + goto lbl$continue$0 + a$0 := l0$b } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } /return_break_continue.kt:(375,386): info: Generated Viper text for whileNested: -method global$fun_whileNested$fun_take$T_Boolean$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$whileNested$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - var anonymous$2: Ref - label label$continue$1 - anonymous$1 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$1)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$1: Ref + var a$2: Ref + label lbl$continue$1 + a$1 := p$b + while (DF$RT$boolFromRef(a$1)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$break$1 - anonymous$1 := local$b + goto lbl$break$1 + a$1 := p$b } - label label$break$1 - goto label$continue$0 - label label$continue$2 - anonymous$2 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$2)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + label lbl$break$1 + goto lbl$continue$0 + label lbl$continue$2 + a$2 := p$b + while (DF$RT$boolFromRef(a$2)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$continue$2 - anonymous$2 := local$b + goto lbl$continue$2 + a$2 := p$b } - label label$break$2 - goto label$break$0 - anonymous$0 := local$b + label lbl$break$2 + goto lbl$break$0 + a$0 := p$b } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } /return_break_continue.kt:(556,569): info: Generated Viper text for labelledBreak: -method global$fun_labelledBreak$fun_take$T_Boolean$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$labelledBreak$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - label label$continue$1 - anonymous$1 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$1)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$1: Ref + label lbl$continue$1 + a$1 := p$b + while (DF$RT$boolFromRef(a$1)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$break$0 - goto label$break$1 - goto label$break$1 - anonymous$1 := local$b + goto lbl$break$0 + goto lbl$break$1 + goto lbl$break$1 + a$1 := p$b } - label label$break$1 - goto label$break$0 - goto label$break$0 - anonymous$0 := local$b + label lbl$break$1 + goto lbl$break$0 + goto lbl$break$0 + a$0 := p$b } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } /return_break_continue.kt:(754,770): info: Generated Viper text for labelledContinue: -method global$fun_labelledContinue$fun_take$T_Boolean$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$labelledContinue$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - label label$continue$1 - anonymous$1 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$1)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$1: Ref + label lbl$continue$1 + a$1 := p$b + while (DF$RT$boolFromRef(a$1)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$continue$0 - goto label$continue$1 - goto label$continue$1 - anonymous$1 := local$b + goto lbl$continue$0 + goto lbl$continue$1 + goto lbl$continue$1 + a$1 := p$b } - label label$break$1 - goto label$continue$0 - goto label$continue$0 - anonymous$0 := local$b + label lbl$break$1 + goto lbl$continue$0 + goto lbl$continue$0 + a$0 := p$b } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } /return_break_continue.kt:(970,992): info: Generated Viper text for labelledWhileShadowing: -method global$fun_labelledWhileShadowing$fun_take$T_Boolean$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$labelledWhileShadowing$TF$T$Boolean(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$continue$0 - anonymous$0 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$continue$0 + a$0 := p$b + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$1: Ref - var anonymous$2: Ref - label label$continue$1 - anonymous$1 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$1)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var a$1: Ref + var a$2: Ref + label lbl$continue$1 + a$1 := p$b + while (DF$RT$boolFromRef(a$1)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$break$1 - goto label$continue$1 - anonymous$1 := local$b + goto lbl$break$1 + goto lbl$continue$1 + a$1 := p$b } - label label$break$1 - label label$continue$2 - anonymous$2 := local$b - while (dom$RuntimeType$boolFromRef(anonymous$2)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + label lbl$break$1 + label lbl$continue$2 + a$2 := p$b + while (DF$RT$boolFromRef(a$2)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - goto label$break$2 - goto label$continue$2 - anonymous$2 := local$b + goto lbl$break$2 + goto lbl$continue$2 + a$2 := p$b } - label label$break$2 - goto label$break$0 - goto label$continue$0 - anonymous$0 := local$b + label lbl$break$2 + goto lbl$break$0 + goto lbl$continue$0 + a$0 := p$b } - label label$break$0 - label label$ret$0 + label lbl$break$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/try_catch.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/try_catch.fir.diag.txt index 56a364abbe4401..07aaf37c59f9ac 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/try_catch.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/try_catch.fir.diag.txt @@ -1,257 +1,247 @@ /try_catch.kt:(158,166): info: Generated Viper text for tryCatch: -method global$fun_call$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$call$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_tryCatch$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$tryCatch$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var local2$e: Ref - var anonymous$4: Ref - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - anonymous$1 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(0)) - anonymous$2 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(1)) - if (dom$RuntimeType$boolFromRef(anonymous$3)) { - goto label$catch$0 - } - goto label$try_exit$0 - label label$catch$0 - anonymous$4 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(2)) - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var l2$e: Ref + var a$4: Ref + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + a$1 := f$g$call$TF$T$Int(DF$RT$intToRef(0)) + a$2 := f$g$call$TF$T$Int(DF$RT$intToRef(1)) + if (DF$RT$boolFromRef(a$3)) { + goto lbl$catch$0 + } + goto lbl$try_exit$0 + label lbl$catch$0 + a$4 := f$g$call$TF$T$Int(DF$RT$intToRef(2)) + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) /try_catch.kt:(271,285): info: Generated Viper text for nestedTryCatch: -method global$fun_call$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$call$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_nestedTryCatch$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$nestedTryCatch$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var local3$e: Ref - var anonymous$5: Ref - var anonymous$6: Ref - var local4$e: Ref - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - anonymous$1 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(0)) - if (dom$RuntimeType$boolFromRef(anonymous$2)) { - goto label$catch$1 - } - anonymous$3 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(1)) - if (dom$RuntimeType$boolFromRef(anonymous$4)) { - goto label$catch$1 - } - goto label$try_exit$1 - label label$catch$1 - anonymous$5 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(2)) - goto label$try_exit$1 - label label$try_exit$1 - if (dom$RuntimeType$boolFromRef(anonymous$6)) { - goto label$catch$0 - } - goto label$try_exit$0 - label label$catch$0 - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + var l3$e: Ref + var a$5: Ref + var a$6: Ref + var l4$e: Ref + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + a$1 := f$g$call$TF$T$Int(DF$RT$intToRef(0)) + if (DF$RT$boolFromRef(a$2)) { + goto lbl$catch$1 + } + a$3 := f$g$call$TF$T$Int(DF$RT$intToRef(1)) + if (DF$RT$boolFromRef(a$4)) { + goto lbl$catch$1 + } + goto lbl$try_exit$1 + label lbl$catch$1 + a$5 := f$g$call$TF$T$Int(DF$RT$intToRef(2)) + goto lbl$try_exit$1 + label lbl$try_exit$1 + if (DF$RT$boolFromRef(a$6)) { + goto lbl$catch$0 + } + goto lbl$try_exit$0 + label lbl$catch$0 + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) /try_catch.kt:(574,592): info: Generated Viper text for tryCatchWithInline: -method global$fun_call$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$call$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_tryCatchWithInline$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$tryCatchWithInline$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var ret$1: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var local3$e: Ref - var anonymous$4: Ref - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - anonymous$1 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(0)) - anonymous$2 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(1)) - label label$ret$1 - if (dom$RuntimeType$boolFromRef(anonymous$3)) { - goto label$catch$0 - } - goto label$try_exit$0 - label label$catch$0 - anonymous$4 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(2)) - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var a$0: Ref + var r$1: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var l3$e: Ref + var a$4: Ref + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + a$1 := f$g$call$TF$T$Int(DF$RT$intToRef(0)) + a$2 := f$g$call$TF$T$Int(DF$RT$intToRef(1)) + label lbl$ret$1 + if (DF$RT$boolFromRef(a$3)) { + goto lbl$catch$0 + } + goto lbl$try_exit$0 + label lbl$catch$0 + a$4 := f$g$call$TF$T$Int(DF$RT$intToRef(2)) + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) /try_catch.kt:(685,702): info: Generated Viper text for tryCatchShadowing: -method global$fun_tryCatchShadowing$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$tryCatchShadowing$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - var anonymous$0: Ref - var local1$x: Ref - var anonymous$1: Ref - var local2$e: Ref - var local2$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$x := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - local1$x := dom$RuntimeType$intToRef(1) - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - goto label$catch$0 - } - goto label$try_exit$0 - label label$catch$0 - local2$x := dom$RuntimeType$intToRef(2) - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var l0$x: Ref + var a$0: Ref + var l1$x: Ref + var a$1: Ref + var l2$e: Ref + var l2$x: Ref + r$0 := DF$RT$unitValue() + l0$x := DF$RT$intToRef(0) + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + l1$x := DF$RT$intToRef(1) + if (DF$RT$boolFromRef(a$1)) { + goto lbl$catch$0 + } + goto lbl$try_exit$0 + label lbl$catch$0 + l2$x := DF$RT$intToRef(2) + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) /try_catch.kt:(813,828): info: Generated Viper text for multipleCatches: -method global$fun_call$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$call$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_multipleCatches$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$multipleCatches$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var anonymous$5: Ref - var local2$e: Ref - var anonymous$6: Ref - var local3$e: Ref - var anonymous$7: Ref - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - goto label$catch$1 - } - anonymous$2 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(0)) - anonymous$3 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(1)) - if (dom$RuntimeType$boolFromRef(anonymous$4)) { - goto label$catch$0 - } - if (dom$RuntimeType$boolFromRef(anonymous$5)) { - goto label$catch$1 - } - goto label$try_exit$0 - label label$catch$0 - anonymous$6 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(2)) - goto label$try_exit$0 - label label$catch$1 - anonymous$7 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(3)) - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + var a$5: Ref + var l2$e: Ref + var a$6: Ref + var l3$e: Ref + var a$7: Ref + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + if (DF$RT$boolFromRef(a$1)) { + goto lbl$catch$1 + } + a$2 := f$g$call$TF$T$Int(DF$RT$intToRef(0)) + a$3 := f$g$call$TF$T$Int(DF$RT$intToRef(1)) + if (DF$RT$boolFromRef(a$4)) { + goto lbl$catch$0 + } + if (DF$RT$boolFromRef(a$5)) { + goto lbl$catch$1 + } + goto lbl$try_exit$0 + label lbl$catch$0 + a$6 := f$g$call$TF$T$Int(DF$RT$intToRef(2)) + goto lbl$try_exit$0 + label lbl$catch$1 + a$7 := f$g$call$TF$T$Int(DF$RT$intToRef(3)) + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) /try_catch.kt:(1044,1056): info: Generated Viper text for useException: -method global$fun_call$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$call$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_ignore$fun_take$T_class_pkg$java$lang$global$class_Exception$return$T_Unit(local$e: Ref) +method f$g$ignore$TF$T$class_c$pkg_java_lang$g$Exception(p$e: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_useException$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$useException$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var local2$e: Ref - var anonymous$3: Ref - ret$0 := dom$RuntimeType$unitValue() - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - goto label$catch$0 - } - anonymous$1 := global$fun_call$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(0)) - if (dom$RuntimeType$boolFromRef(anonymous$2)) { - goto label$catch$0 - } - goto label$try_exit$0 - label label$catch$0 - anonymous$3 := global$fun_ignore$fun_take$T_class_pkg$java$lang$global$class_Exception$return$T_Unit(local2$e) - goto label$try_exit$0 - label label$try_exit$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var l2$e: Ref + var a$3: Ref + r$0 := DF$RT$unitValue() + if (DF$RT$boolFromRef(a$0)) { + goto lbl$catch$0 + } + a$1 := f$g$call$TF$T$Int(DF$RT$intToRef(0)) + if (DF$RT$boolFromRef(a$2)) { + goto lbl$catch$0 + } + goto lbl$try_exit$0 + label lbl$catch$0 + a$3 := f$g$ignore$TF$T$class_c$pkg_java_lang$g$Exception(l2$e) + goto lbl$try_exit$0 + label lbl$try_exit$0 + label lbl$ret$0 } -method public$property_getter_cause(this: Ref) returns (ret: Ref) +method pg$public$cause(this: Ref) returns (ret: Ref) -method public$property_getter_message(this: Ref) returns (ret: Ref) +method pg$public$message(this: Ref) returns (ret: Ref) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/when.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/when.fir.diag.txt index 47bfd22d5791ef..68be16265e9db0 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/when.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/control_flow/when.fir.diag.txt @@ -1,233 +1,218 @@ /when.kt:(23,33): info: Generated Viper text for returnWhen: -method global$fun_returnWhen$fun_take$T_Boolean$T_Boolean$T_Boolean$return$T_Int(local$a: Ref, - local$b: Ref, local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$returnWhen$TF$T$Boolean$T$Boolean$T$Boolean(p$a: Ref, p$b: Ref, p$c: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$a)) { - ret$0 := dom$RuntimeType$intToRef(0) - } elseif (dom$RuntimeType$boolFromRef(local$b)) { - ret$0 := dom$RuntimeType$intToRef(1) - } elseif (dom$RuntimeType$boolFromRef(local$c)) { - ret$0 := dom$RuntimeType$intToRef(2) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$a)) { + r$0 := DF$RT$intToRef(0) + } elseif (DF$RT$boolFromRef(p$b)) { + r$0 := DF$RT$intToRef(1) + } elseif (DF$RT$boolFromRef(p$c)) { + r$0 := DF$RT$intToRef(2) } else { - ret$0 := dom$RuntimeType$intToRef(3)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(3)} + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(171,181): info: Generated Viper text for whenReturn: -method global$fun_whenReturn$fun_take$T_Boolean$T_Boolean$T_Boolean$return$T_Int(local$a: Ref, - local$b: Ref, local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$whenReturn$TF$T$Boolean$T$Boolean$T$Boolean(p$a: Ref, p$b: Ref, p$c: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$a)) { - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - } elseif (dom$RuntimeType$boolFromRef(local$b)) { - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 - } elseif (dom$RuntimeType$boolFromRef(local$c)) { - ret$0 := dom$RuntimeType$intToRef(2) - goto label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$a)) { + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + } elseif (DF$RT$boolFromRef(p$b)) { + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 + } elseif (DF$RT$boolFromRef(p$c)) { + r$0 := DF$RT$intToRef(2) + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$intToRef(3) - goto label$ret$0 + r$0 := DF$RT$intToRef(3) + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } /when.kt:(340,356): info: Generated Viper text for singleBranchWhen: -method global$fun_singleBranchWhen$fun_take$T_Boolean$return$T_Int(local$a: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$singleBranchWhen$TF$T$Boolean(p$a: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$boolType()) - local0$x := dom$RuntimeType$intToRef(1) - if (dom$RuntimeType$boolFromRef(local$a)) { - local0$x := dom$RuntimeType$intToRef(2) + var l0$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$boolType()) + l0$x := DF$RT$intToRef(1) + if (DF$RT$boolFromRef(p$a)) { + l0$x := DF$RT$intToRef(2) } - ret$0 := local0$x - goto label$ret$0 - label label$ret$0 + r$0 := l0$x + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(446,456): info: Generated Viper text for noElseWhen: -method global$fun_noElseWhen$fun_take$T_Boolean$T_Boolean$T_Boolean$return$T_Int(local$a: Ref, - local$b: Ref, local$c: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$noElseWhen$TF$T$Boolean$T$Boolean$T$Boolean(p$a: Ref, p$b: Ref, p$c: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$a), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$c), dom$RuntimeType$boolType()) - local0$y := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$boolFromRef(local$a)) { - local0$y := dom$RuntimeType$intToRef(1) - } elseif (dom$RuntimeType$boolFromRef(local$b)) { - local0$y := dom$RuntimeType$intToRef(2) - } elseif (dom$RuntimeType$boolFromRef(local$c)) { - local0$y := dom$RuntimeType$intToRef(3) + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$a), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$c), DF$RT$boolType()) + l0$y := DF$RT$intToRef(0) + if (DF$RT$boolFromRef(p$a)) { + l0$y := DF$RT$intToRef(1) + } elseif (DF$RT$boolFromRef(p$b)) { + l0$y := DF$RT$intToRef(2) + } elseif (DF$RT$boolFromRef(p$c)) { + l0$y := DF$RT$intToRef(3) } - ret$0 := local0$y - goto label$ret$0 - label label$ret$0 + r$0 := l0$y + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(608,626): info: Generated Viper text for whenWithSubjectVar: -method global$fun_whenWithSubjectVar$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$whenWithSubjectVar$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - anonymous$0 := local$x - if (dom$RuntimeType$intFromRef(anonymous$0) == 1) { - ret$0 := dom$RuntimeType$intToRef(2) - } elseif (dom$RuntimeType$intFromRef(anonymous$0) == 2) { - ret$0 := dom$RuntimeType$intToRef(3) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + a$0 := p$x + if (DF$RT$intFromRef(a$0) == 1) { + r$0 := DF$RT$intToRef(2) + } elseif (DF$RT$intFromRef(a$0) == 2) { + r$0 := DF$RT$intToRef(3) } else { - ret$0 := dom$RuntimeType$intToRef(42)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(42)} + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(726,745): info: Generated Viper text for whenWithSubjectCall: -method global$fun_whenWithSubjectCall$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$whenWithSubjectCall$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - anonymous$0 := global$fun_whenWithSubjectVar$fun_take$T_Int$return$T_Int(local$x) - if (dom$RuntimeType$intFromRef(anonymous$0) == 1) { - ret$0 := dom$RuntimeType$intToRef(2) - } elseif (dom$RuntimeType$intFromRef(anonymous$0) == 2) { - ret$0 := dom$RuntimeType$intToRef(3) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + a$0 := f$g$whenWithSubjectVar$TF$T$Int(p$x) + if (DF$RT$intFromRef(a$0) == 1) { + r$0 := DF$RT$intToRef(2) + } elseif (DF$RT$intFromRef(a$0) == 2) { + r$0 := DF$RT$intToRef(3) } else { - var anonymous$1: Ref - anonymous$1 := global$fun_whenWithSubjectVar$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(0)) - if (dom$RuntimeType$intFromRef(anonymous$1) == 3) { - ret$0 := dom$RuntimeType$intToRef(4) - } elseif (dom$RuntimeType$intFromRef(anonymous$1) == 4) { - ret$0 := dom$RuntimeType$intToRef(5) + var a$1: Ref + a$1 := f$g$whenWithSubjectVar$TF$T$Int(DF$RT$intToRef(0)) + if (DF$RT$intFromRef(a$1) == 3) { + r$0 := DF$RT$intToRef(4) + } elseif (DF$RT$intFromRef(a$1) == 4) { + r$0 := DF$RT$intToRef(5) } else { - ret$0 := dom$RuntimeType$intToRef(42)} + r$0 := DF$RT$intToRef(42)} } - goto label$ret$0 - label label$ret$0 + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_whenWithSubjectVar$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$whenWithSubjectVar$TF$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) /when.kt:(963,972): info: Generated Viper text for emptyWhen: -method global$fun_emptyWhen$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$emptyWhen$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - ret$0 := dom$RuntimeType$intToRef(1) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(1) + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(1015,1027): info: Generated Viper text for unusedResult: -method global$fun_unusedResult$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$unusedResult$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - local0$x := dom$RuntimeType$intToRef(0) - ret$0 := local0$x - goto label$ret$0 - label label$ret$0 + var l0$x: Ref + l0$x := DF$RT$intToRef(0) + r$0 := l0$x + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(1221,1227): info: Generated Viper text for whenIs: -method global$fun_whenIs$fun_take$T_class_global$class_Foo$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$whenIs$TF$T$class_c$g$Foo(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$x), wildcard) - anonymous$0 := local$x - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$T_class_global$class_Bar())) { - ret$0 := dom$RuntimeType$boolToRef(true) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$x), wildcard) + a$0 := p$x + if (DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$T$class_c$g$Bar())) { + r$0 := DF$RT$boolToRef(true) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(1301,1315): info: Generated Viper text for whenSubjectVal: -method global$fun_whenSubjectVal$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$whenSubjectVal$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local1$x: Ref - local1$x := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$intFromRef(local1$x) == 1) { - ret$0 := dom$RuntimeType$intToRef(1) + var l1$x: Ref + l1$x := DF$RT$intToRef(0) + if (DF$RT$intFromRef(l1$x) == 1) { + r$0 := DF$RT$intToRef(1) } else { - ret$0 := local1$x} - goto label$ret$0 - label label$ret$0 + r$0 := l1$x} + goto lbl$ret$0 + label lbl$ret$0 } /when.kt:(1392,1412): info: Generated Viper text for whenSubjectValNested: -method global$fun_whenSubjectValNested$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$whenSubjectValNested$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local1$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local1$x := dom$RuntimeType$intToRef(1) - if (dom$RuntimeType$intFromRef(local1$x) == 0) { + var l1$x: Ref + r$0 := DF$RT$unitValue() + l1$x := DF$RT$intToRef(1) + if (DF$RT$intFromRef(l1$x) == 0) { } else { - var anonymous$0: Ref - var local3$y: Ref - local3$y := dom$RuntimeType$intToRef(1) - if (dom$RuntimeType$intFromRef(local3$y) == 1) { - anonymous$0 := dom$RuntimeType$intToRef(1) + var a$0: Ref + var l3$y: Ref + l3$y := DF$RT$intToRef(1) + if (DF$RT$intFromRef(l3$y) == 1) { + a$0 := DF$RT$intToRef(1) } else { - var local6$z: Ref - local6$z := dom$RuntimeType$intToRef(1) - if (dom$RuntimeType$intFromRef(local6$z) == - dom$RuntimeType$intFromRef(local3$y)) { - anonymous$0 := dom$RuntimeType$intToRef(2) - } elseif (dom$RuntimeType$intFromRef(local6$z) == - dom$RuntimeType$intFromRef(local1$x) + 1) { - anonymous$0 := dom$RuntimeType$intToRef(3) + var l6$z: Ref + l6$z := DF$RT$intToRef(1) + if (DF$RT$intFromRef(l6$z) == DF$RT$intFromRef(l3$y)) { + a$0 := DF$RT$intToRef(2) + } elseif (DF$RT$intFromRef(l6$z) == DF$RT$intFromRef(l1$x) + 1) { + a$0 := DF$RT$intToRef(3) } else { - anonymous$0 := dom$RuntimeType$intToRef(4)} + a$0 := DF$RT$intToRef(4)} } - if (dom$RuntimeType$intFromRef(local1$x) == - dom$RuntimeType$intFromRef(anonymous$0)) { + if (DF$RT$intFromRef(l1$x) == DF$RT$intFromRef(a$0)) { } } - label label$ret$0 + label lbl$ret$0 } /when.kt:(1674,1697): info: Generated Viper text for whenSubjectVarShadowing: -method global$fun_whenSubjectVarShadowing$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$whenSubjectVarShadowing$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - var local1$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$x := dom$RuntimeType$intToRef(0) - local1$x := dom$RuntimeType$intToRef(1) - label label$ret$0 + var l0$x: Ref + var l1$x: Ref + r$0 := DF$RT$unitValue() + l0$x := DF$RT$intToRef(0) + l1$x := DF$RT$intToRef(1) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/extension_properties.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/extension_properties.fir.diag.txt index e8876da1ce93b2..b1d5b3d79a4011 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/extension_properties.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/extension_properties.fir.diag.txt @@ -1,95 +1,87 @@ /extension_properties.kt:(114,137): info: Generated Viper text for extensionGetterProperty: -method global$ext_getter_intValProp$fun_take$T_Int$return$T_Int(this: Ref) - returns (ret: Ref) +method es$g$intValProp$TF$T$Int(this: Ref) returns (ret: Ref) -method global$fun_extensionGetterProperty$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$extensionGetterProperty$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$a: Ref - var anonymous$0: Ref - var local0$b: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$ext_getter_intValProp$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(0)) - local0$a := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$a), dom$RuntimeType$intType()) - anonymous$3 := global$ext_getter_intValProp$fun_take$T_Int$return$T_Int(dom$RuntimeType$intToRef(1)) - anonymous$2 := anonymous$3 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - anonymous$1 := global$ext_getter_intValProp$fun_take$T_Int$return$T_Int(anonymous$2) - local0$b := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$b), dom$RuntimeType$intType()) - label label$ret$0 + var l0$a: Ref + var a$0: Ref + var l0$b: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + r$0 := DF$RT$unitValue() + a$0 := es$g$intValProp$TF$T$Int(DF$RT$intToRef(0)) + l0$a := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$a), DF$RT$intType()) + a$3 := es$g$intValProp$TF$T$Int(DF$RT$intToRef(1)) + a$2 := a$3 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + a$1 := es$g$intValProp$TF$T$Int(a$2) + l0$b := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$b), DF$RT$intType()) + label lbl$ret$0 } /extension_properties.kt:(210,233): info: Generated Viper text for extensionSetterProperty: -method global$ext_getter_intVarProp$fun_take$T_Int$return$T_Int(this: Ref) - returns (ret: Ref) +method es$g$intVarProp$TF$T$Int(this: Ref) returns (ret: Ref) -method global$ext_setter_intVarProp$fun_take$T_Int$T_Int$return$T_Unit(this: Ref, - value: Ref) +method es$g$intVarProp$TF$T$Int$T$Int(this: Ref, value: Ref) returns (ret: Ref) -method global$fun_extensionSetterProperty$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$extensionSetterProperty$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$ext_setter_intVarProp$fun_take$T_Int$T_Int$return$T_Unit(dom$RuntimeType$intToRef(42), - dom$RuntimeType$intToRef(0)) - label label$ret$0 + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := es$g$intVarProp$TF$T$Int$T$Int(DF$RT$intToRef(42), DF$RT$intToRef(0)) + label lbl$ret$0 } /extension_properties.kt:(414,453): info: Generated Viper text for extensionGetterPropertyUserDefinedClass: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$ext_getter_pfValProp$fun_take$T_class_global$class_PrimitiveField$return$T_Int(this: Ref) +method es$g$pfValProp$TF$T$class_c$g$PrimitiveField(this: Ref) returns (ret: Ref) -method global$fun_extensionGetterPropertyUserDefinedClass$fun_take$T_class_global$class_PrimitiveField$return$T_Unit(local$pf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$extensionGetterPropertyUserDefinedClass$TF$T$class_c$g$PrimitiveField(p$pf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pf), dom$RuntimeType$T_class_global$class_PrimitiveField()) - inhale acc(T_class_global$class_PrimitiveField(local$pf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$ext_getter_pfValProp$fun_take$T_class_global$class_PrimitiveField$return$T_Int(local$pf) - local0$x := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$x), dom$RuntimeType$intType()) - label label$ret$0 + var l0$x: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pf), DF$RT$T$class_c$g$PrimitiveField()) + inhale acc(T$class_c$g$PrimitiveField(p$pf), wildcard) + r$0 := DF$RT$unitValue() + a$0 := es$g$pfValProp$TF$T$class_c$g$PrimitiveField(p$pf) + l0$x := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$x), DF$RT$intType()) + label lbl$ret$0 } /extension_properties.kt:(508,547): info: Generated Viper text for extensionSetterPropertyUserDefinedClass: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$ext_getter_pfVarProp$fun_take$T_class_global$class_PrimitiveField$return$T_Int(this: Ref) +method es$g$pfVarProp$TF$T$class_c$g$PrimitiveField(this: Ref) returns (ret: Ref) -method global$ext_setter_pfVarProp$fun_take$T_class_global$class_PrimitiveField$T_Int$return$T_Unit(this: Ref, - value: Ref) +method es$g$pfVarProp$TF$T$class_c$g$PrimitiveField$T$Int(this: Ref, value: Ref) returns (ret: Ref) -method global$fun_extensionSetterPropertyUserDefinedClass$fun_take$T_class_global$class_PrimitiveField$return$T_Unit(local$pf: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$extensionSetterPropertyUserDefinedClass$TF$T$class_c$g$PrimitiveField(p$pf: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$pf), dom$RuntimeType$T_class_global$class_PrimitiveField()) - inhale acc(T_class_global$class_PrimitiveField(local$pf), wildcard) - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$ext_setter_pfVarProp$fun_take$T_class_global$class_PrimitiveField$T_Int$return$T_Unit(local$pf, - dom$RuntimeType$intToRef(42)) - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$pf), DF$RT$T$class_c$g$PrimitiveField()) + inhale acc(T$class_c$g$PrimitiveField(p$pf), wildcard) + r$0 := DF$RT$unitValue() + a$0 := es$g$pfVarProp$TF$T$class_c$g$PrimitiveField$T$Int(p$pf, DF$RT$intToRef(42)) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/full_viper_dump.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/full_viper_dump.fir.diag.txt index 6ef8b614e879e7..8842ef976f0cf6 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/full_viper_dump.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/full_viper_dump.fir.diag.txt @@ -1,332 +1,304 @@ /full_viper_dump.kt:(172,173): info: Generated Viper text for f: -domain dom$RuntimeType { +domain D$RT { - unique function dom$RuntimeType$intType(): dom$RuntimeType + unique function DF$RT$intType(): D$RT - unique function dom$RuntimeType$boolType(): dom$RuntimeType + unique function DF$RT$boolType(): D$RT - unique function dom$RuntimeType$unitType(): dom$RuntimeType + unique function DF$RT$unitType(): D$RT - unique function dom$RuntimeType$nothingType(): dom$RuntimeType + unique function DF$RT$nothingType(): D$RT - unique function dom$RuntimeType$anyType(): dom$RuntimeType + unique function DF$RT$anyType(): D$RT - unique function dom$RuntimeType$functionType(): dom$RuntimeType + unique function DF$RT$functionType(): D$RT - unique function dom$RuntimeType$T_class_global$class_Foo(): dom$RuntimeType + unique function DF$RT$T$class_c$g$Foo(): D$RT - function dom$RuntimeType$nullValue(): Ref + function DF$RT$nullValue(): Ref - function dom$RuntimeType$unitValue(): Ref + function DF$RT$unitValue(): Ref - function dom$RuntimeType$isSubtype(t1: dom$RuntimeType, t2: dom$RuntimeType): Bool + function DF$RT$isSubtype(t1: D$RT, t2: D$RT): Bool - function dom$RuntimeType$typeOf(r: Ref): dom$RuntimeType + function DF$RT$typeOf(r: Ref): D$RT - function dom$RuntimeType$nullable(t: dom$RuntimeType): dom$RuntimeType + function DF$RT$nullable(t: D$RT): D$RT - function dom$RuntimeType$intToRef(v: Int): Ref + function DF$RT$intToRef(v: Int): Ref - function dom$RuntimeType$intFromRef(r: Ref): Int + function DF$RT$intFromRef(r: Ref): Int - function dom$RuntimeType$boolToRef(v: Bool): Ref + function DF$RT$boolToRef(v: Bool): Ref - function dom$RuntimeType$boolFromRef(r: Ref): Bool + function DF$RT$boolFromRef(r: Ref): Bool - axiom dom$RuntimeType$subtype_reflexive { - (forall t: dom$RuntimeType ::dom$RuntimeType$isSubtype(t, t)) + axiom RT$subtype_reflexive { + (forall t: D$RT ::DF$RT$isSubtype(t, t)) } - axiom dom$RuntimeType$subtype_transitive { - (forall t1: dom$RuntimeType, t2: dom$RuntimeType, t3: dom$RuntimeType :: - { dom$RuntimeType$isSubtype(t1, t2), dom$RuntimeType$isSubtype(t2, t3) } - { dom$RuntimeType$isSubtype(t1, t2), dom$RuntimeType$isSubtype(t1, t3) } - { dom$RuntimeType$isSubtype(t2, t3), dom$RuntimeType$isSubtype(t1, t3) } - dom$RuntimeType$isSubtype(t1, t2) && - dom$RuntimeType$isSubtype(t2, t3) ==> - dom$RuntimeType$isSubtype(t1, t3)) + axiom RT$subtype_transitive { + (forall t1: D$RT, t2: D$RT, t3: D$RT :: + { DF$RT$isSubtype(t1, t2), DF$RT$isSubtype(t2, t3) } + { DF$RT$isSubtype(t1, t2), DF$RT$isSubtype(t1, t3) } + { DF$RT$isSubtype(t2, t3), DF$RT$isSubtype(t1, t3) } + DF$RT$isSubtype(t1, t2) && DF$RT$isSubtype(t2, t3) ==> + DF$RT$isSubtype(t1, t3)) } - axiom dom$RuntimeType$subtype_antisymmetric { - (forall t1: dom$RuntimeType, t2: dom$RuntimeType :: - { dom$RuntimeType$isSubtype(t1, t2), dom$RuntimeType$isSubtype(t2, t1) } - dom$RuntimeType$isSubtype(t1, t2) && - dom$RuntimeType$isSubtype(t2, t1) ==> - t1 == t2) + axiom RT$subtype_antisymmetric { + (forall t1: D$RT, t2: D$RT :: + { DF$RT$isSubtype(t1, t2), DF$RT$isSubtype(t2, t1) } + DF$RT$isSubtype(t1, t2) && DF$RT$isSubtype(t2, t1) ==> t1 == t2) } - axiom dom$RuntimeType$nullable_idempotent { - (forall t: dom$RuntimeType :: - { dom$RuntimeType$nullable(dom$RuntimeType$nullable(t)) } - dom$RuntimeType$nullable(dom$RuntimeType$nullable(t)) == - dom$RuntimeType$nullable(t)) + axiom RT$nullable_idempotent { + (forall t: D$RT :: + { DF$RT$nullable(DF$RT$nullable(t)) } + DF$RT$nullable(DF$RT$nullable(t)) == DF$RT$nullable(t)) } - axiom dom$RuntimeType$nullable_supertype { - (forall t: dom$RuntimeType :: - { dom$RuntimeType$nullable(t) } - dom$RuntimeType$isSubtype(t, dom$RuntimeType$nullable(t))) + axiom RT$nullable_supertype { + (forall t: D$RT :: + { DF$RT$nullable(t) } + DF$RT$isSubtype(t, DF$RT$nullable(t))) } - axiom dom$RuntimeType$nullable_preserves_subtype { - (forall t1: dom$RuntimeType, t2: dom$RuntimeType :: - { dom$RuntimeType$isSubtype(dom$RuntimeType$nullable(t1), dom$RuntimeType$nullable(t2)) } - dom$RuntimeType$isSubtype(t1, t2) ==> - dom$RuntimeType$isSubtype(dom$RuntimeType$nullable(t1), dom$RuntimeType$nullable(t2))) + axiom RT$nullable_preserves_subtype { + (forall t1: D$RT, t2: D$RT :: + { DF$RT$isSubtype(DF$RT$nullable(t1), DF$RT$nullable(t2)) } + DF$RT$isSubtype(t1, t2) ==> + DF$RT$isSubtype(DF$RT$nullable(t1), DF$RT$nullable(t2))) } - axiom dom$RuntimeType$nullable_any_supertype { - (forall t: dom$RuntimeType ::dom$RuntimeType$isSubtype(t, dom$RuntimeType$nullable(dom$RuntimeType$anyType()))) + axiom RT$nullable_any_supertype { + (forall t: D$RT ::DF$RT$isSubtype(t, DF$RT$nullable(DF$RT$anyType()))) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$intType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$intType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$boolType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$boolType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$unitType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$unitType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$nothingType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$nothingType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$anyType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$anyType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$functionType(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$functionType(), DF$RT$anyType()) } axiom { - dom$RuntimeType$isSubtype(dom$RuntimeType$T_class_global$class_Foo(), dom$RuntimeType$anyType()) + DF$RT$isSubtype(DF$RT$T$class_c$g$Foo(), DF$RT$anyType()) } - axiom dom$RuntimeType$supertype_of_nothing { - (forall t: dom$RuntimeType ::dom$RuntimeType$isSubtype(dom$RuntimeType$nothingType(), - t)) + axiom RT$supertype_of_nothing { + (forall t: D$RT ::DF$RT$isSubtype(DF$RT$nothingType(), t)) } - axiom dom$RuntimeType$any_not_nullable_type_level { - (forall t: dom$RuntimeType ::!dom$RuntimeType$isSubtype(dom$RuntimeType$nullable(t), - dom$RuntimeType$anyType())) + axiom RT$any_not_nullable_type_level { + (forall t: D$RT ::!DF$RT$isSubtype(DF$RT$nullable(t), DF$RT$anyType())) } - axiom dom$RuntimeType$null_smartcast_value_level { - (forall r: Ref, t: dom$RuntimeType :: - { dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$nullable(t)) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$nullable(t)) ==> - r == dom$RuntimeType$nullValue() || - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), t)) + axiom RT$null_smartcast_value_level { + (forall r: Ref, t: D$RT :: + { DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$nullable(t)) } + DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$nullable(t)) ==> + r == DF$RT$nullValue() || DF$RT$isSubtype(DF$RT$typeOf(r), t)) } - axiom dom$RuntimeType$nothing_empty { - (forall r: Ref ::!dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$nothingType())) + axiom RT$nothing_empty { + (forall r: Ref ::!DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$nothingType())) } - axiom dom$RuntimeType$null_smartcast_type_level { - (forall t1: dom$RuntimeType, t2: dom$RuntimeType :: - { dom$RuntimeType$isSubtype(t1, dom$RuntimeType$anyType()), dom$RuntimeType$isSubtype(t1, - dom$RuntimeType$nullable(t2)) } - dom$RuntimeType$isSubtype(t1, dom$RuntimeType$anyType()) && - dom$RuntimeType$isSubtype(t1, dom$RuntimeType$nullable(t2)) ==> - dom$RuntimeType$isSubtype(t1, t2)) + axiom RT$null_smartcast_type_level { + (forall t1: D$RT, t2: D$RT :: + { DF$RT$isSubtype(t1, DF$RT$anyType()), DF$RT$isSubtype(t1, DF$RT$nullable(t2)) } + DF$RT$isSubtype(t1, DF$RT$anyType()) && + DF$RT$isSubtype(t1, DF$RT$nullable(t2)) ==> + DF$RT$isSubtype(t1, t2)) } - axiom dom$RuntimeType$type_of_null { - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$nullValue()), - dom$RuntimeType$nullable(dom$RuntimeType$nothingType())) + axiom RT$type_of_null { + DF$RT$isSubtype(DF$RT$typeOf(DF$RT$nullValue()), DF$RT$nullable(DF$RT$nothingType())) } - axiom dom$RuntimeType$any_not_nullable_value_level { - !dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$nullValue()), - dom$RuntimeType$anyType()) + axiom RT$any_not_nullable_value_level { + !DF$RT$isSubtype(DF$RT$typeOf(DF$RT$nullValue()), DF$RT$anyType()) } - axiom dom$RuntimeType$type_of_unit { - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$unitValue()), - dom$RuntimeType$unitType()) + axiom RT$type_of_unit { + DF$RT$isSubtype(DF$RT$typeOf(DF$RT$unitValue()), DF$RT$unitType()) } - axiom dom$RuntimeType$uniqueness_of_unit { + axiom RT$uniqueness_of_unit { (forall r: Ref :: - { dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$unitType()) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$unitType()) ==> - r == dom$RuntimeType$unitValue()) + { DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$unitType()) } + DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$unitType()) ==> + r == DF$RT$unitValue()) } axiom { (forall v: Int :: - { dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$intToRef(v)), - dom$RuntimeType$intType()) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$intToRef(v)), - dom$RuntimeType$intType())) + { DF$RT$isSubtype(DF$RT$typeOf(DF$RT$intToRef(v)), DF$RT$intType()) } + DF$RT$isSubtype(DF$RT$typeOf(DF$RT$intToRef(v)), DF$RT$intType())) } axiom { (forall v: Int :: - { dom$RuntimeType$intFromRef(dom$RuntimeType$intToRef(v)) } - dom$RuntimeType$intFromRef(dom$RuntimeType$intToRef(v)) == v) + { DF$RT$intFromRef(DF$RT$intToRef(v)) } + DF$RT$intFromRef(DF$RT$intToRef(v)) == v) } axiom { (forall r: Ref :: - { dom$RuntimeType$intToRef(dom$RuntimeType$intFromRef(r)) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$intType()) ==> - dom$RuntimeType$intToRef(dom$RuntimeType$intFromRef(r)) == r) + { DF$RT$intToRef(DF$RT$intFromRef(r)) } + DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$intType()) ==> + DF$RT$intToRef(DF$RT$intFromRef(r)) == r) } axiom { (forall v: Bool :: - { dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$boolToRef(v)), - dom$RuntimeType$boolType()) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(dom$RuntimeType$boolToRef(v)), - dom$RuntimeType$boolType())) + { DF$RT$isSubtype(DF$RT$typeOf(DF$RT$boolToRef(v)), DF$RT$boolType()) } + DF$RT$isSubtype(DF$RT$typeOf(DF$RT$boolToRef(v)), DF$RT$boolType())) } axiom { (forall v: Bool :: - { dom$RuntimeType$boolFromRef(dom$RuntimeType$boolToRef(v)) } - dom$RuntimeType$boolFromRef(dom$RuntimeType$boolToRef(v)) == v) + { DF$RT$boolFromRef(DF$RT$boolToRef(v)) } + DF$RT$boolFromRef(DF$RT$boolToRef(v)) == v) } axiom { (forall r: Ref :: - { dom$RuntimeType$boolToRef(dom$RuntimeType$boolFromRef(r)) } - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(r), dom$RuntimeType$boolType()) ==> - dom$RuntimeType$boolToRef(dom$RuntimeType$boolFromRef(r)) == r) + { DF$RT$boolToRef(DF$RT$boolFromRef(r)) } + DF$RT$isSubtype(DF$RT$typeOf(r), DF$RT$boolType()) ==> + DF$RT$boolToRef(DF$RT$boolFromRef(r)) == r) } } -field public$backing_field_x: Ref +field bf$public$x: Ref -function special$andBools(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - (dom$RuntimeType$boolFromRef(arg1) && dom$RuntimeType$boolFromRef(arg2)) +function sp$andBools(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + (DF$RT$boolFromRef(arg1) && DF$RT$boolFromRef(arg2)) -function special$divInts(arg1: Ref, arg2: Ref): Ref - requires dom$RuntimeType$intFromRef(arg2) != 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(result) == - dom$RuntimeType$intFromRef(arg1) / dom$RuntimeType$intFromRef(arg2) +function sp$divInts(arg1: Ref, arg2: Ref): Ref + requires DF$RT$intFromRef(arg2) != 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$intType()) + ensures DF$RT$intFromRef(result) == + DF$RT$intFromRef(arg1) / DF$RT$intFromRef(arg2) -function special$geInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - dom$RuntimeType$intFromRef(arg1) >= dom$RuntimeType$intFromRef(arg2) +function sp$geInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + DF$RT$intFromRef(arg1) >= DF$RT$intFromRef(arg2) -function special$gtInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - dom$RuntimeType$intFromRef(arg1) > dom$RuntimeType$intFromRef(arg2) +function sp$gtInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + DF$RT$intFromRef(arg1) > DF$RT$intFromRef(arg2) -function special$impliesBools(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - (dom$RuntimeType$boolFromRef(arg1) ==> - dom$RuntimeType$boolFromRef(arg2)) +function sp$impliesBools(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + (DF$RT$boolFromRef(arg1) ==> DF$RT$boolFromRef(arg2)) -function special$leInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - dom$RuntimeType$intFromRef(arg1) <= dom$RuntimeType$intFromRef(arg2) +function sp$leInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + DF$RT$intFromRef(arg1) <= DF$RT$intFromRef(arg2) -function special$ltInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - dom$RuntimeType$intFromRef(arg1) < dom$RuntimeType$intFromRef(arg2) +function sp$ltInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + DF$RT$intFromRef(arg1) < DF$RT$intFromRef(arg2) -function special$minusInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(result) == - dom$RuntimeType$intFromRef(arg1) - dom$RuntimeType$intFromRef(arg2) +function sp$minusInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$intType()) + ensures DF$RT$intFromRef(result) == + DF$RT$intFromRef(arg1) - DF$RT$intFromRef(arg2) -function special$notBool(arg1: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - !dom$RuntimeType$boolFromRef(arg1) +function sp$notBool(arg1: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == !DF$RT$boolFromRef(arg1) -function special$orBools(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$boolType()) - ensures dom$RuntimeType$boolFromRef(result) == - (dom$RuntimeType$boolFromRef(arg1) || dom$RuntimeType$boolFromRef(arg2)) +function sp$orBools(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$boolType()) + ensures DF$RT$boolFromRef(result) == + (DF$RT$boolFromRef(arg1) || DF$RT$boolFromRef(arg2)) -function special$plusInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(result) == - dom$RuntimeType$intFromRef(arg1) + dom$RuntimeType$intFromRef(arg2) +function sp$plusInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$intType()) + ensures DF$RT$intFromRef(result) == + DF$RT$intFromRef(arg1) + DF$RT$intFromRef(arg2) -function special$remInts(arg1: Ref, arg2: Ref): Ref - requires dom$RuntimeType$intFromRef(arg2) != 0 - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(result) == - dom$RuntimeType$intFromRef(arg1) % dom$RuntimeType$intFromRef(arg2) +function sp$remInts(arg1: Ref, arg2: Ref): Ref + requires DF$RT$intFromRef(arg2) != 0 + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$intType()) + ensures DF$RT$intFromRef(result) == + DF$RT$intFromRef(arg1) % DF$RT$intFromRef(arg2) -function special$timesInts(arg1: Ref, arg2: Ref): Ref - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(result), dom$RuntimeType$intType()) - ensures dom$RuntimeType$intFromRef(result) == - dom$RuntimeType$intFromRef(arg1) * dom$RuntimeType$intFromRef(arg2) +function sp$timesInts(arg1: Ref, arg2: Ref): Ref + ensures DF$RT$isSubtype(DF$RT$typeOf(result), DF$RT$intType()) + ensures DF$RT$intFromRef(result) == + DF$RT$intFromRef(arg1) * DF$RT$intFromRef(arg2) -predicate T_class_global$class_Foo(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$intType()) +predicate T$class_c$g$Foo(this: Ref) { + acc(this.bf$public$x, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$intType()) } -predicate Unique$T_class_global$class_Foo(special$class$predicate$subject: Ref) { - acc(special$class$predicate$subject.public$backing_field_x, wildcard) && - dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(special$class$predicate$subject.public$backing_field_x), - dom$RuntimeType$intType()) +predicate U$T$class_c$g$Foo(this: Ref) { + acc(this.bf$public$x, wildcard) && + DF$RT$isSubtype(DF$RT$typeOf(this.bf$public$x), DF$RT$intType()) } -method class_Foo$constructor$fun_take$T_Int$return$T_class_global$class_Foo(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Foo()) - ensures acc(T_class_global$class_Foo(ret), wildcard) - ensures acc(Unique$T_class_global$class_Foo(ret), write) - ensures (unfolding acc(T_class_global$class_Foo(ret), wildcard) in - dom$RuntimeType$intFromRef(ret.public$backing_field_x) == - dom$RuntimeType$intFromRef(local$x)) +method con$c$Foo$T$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Foo()) + ensures acc(T$class_c$g$Foo(ret), wildcard) + ensures acc(U$T$class_c$g$Foo(ret), write) + ensures (unfolding acc(T$class_c$g$Foo(ret), wildcard) in + DF$RT$intFromRef(ret.bf$public$x) == DF$RT$intFromRef(p$x)) -method global$fun_f$fun_take$$return$T_Unit() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$f$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$foo: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$foo := class_Foo$constructor$fun_take$T_Int$return$T_class_global$class_Foo(dom$RuntimeType$intToRef(0)) - label label$ret$0 + var l0$foo: Ref + r$0 := DF$RT$unitValue() + l0$foo := con$c$Foo$T$Int(DF$RT$intToRef(0)) + label lbl$ret$0 } -/full_viper_dump.kt:(172,173): info: Generated ExpEmbedding for global$fun_f$fun_take$$return$T_Unit: +/full_viper_dump.kt:(172,173): info: Generated ExpEmbedding for f$g$f$TF$: Function( - name = global$fun_f$fun_take$$return$T_Unit, - { - Var(ret$0) := Unit; - Declare( - Var(local0$foo), - T_class_global$class_Foo, - MethodCall(callee = class_Foo$constructor$fun_take$T_Int$return$T_class_global$class_Foo, Int(0)), - ); - }, - return = label$ret$0, + name = f$g$f$TF$, + { Var(r$0) := Unit; Declare(Var(l0$foo), T$class_c$g$Foo, MethodCall(callee = con$c$Foo$T$Int, Int(0))) }, + return = lbl$ret$0, ) diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/function_object.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/function_object.fir.diag.txt index 1215ec66f59ba4..975a9eac2d41dd 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/function_object.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/function_object.fir.diag.txt @@ -1,49 +1,47 @@ /function_object.kt:(23,35): info: Generated Viper text for unitFunction: -method global$fun_unitFunction$fun_take$fun_take$$return$T_Unit$return$T_Unit(local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$unitFunction$TF$TF$(p$f: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$functionType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$functionType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_object.kt:(90,108): info: Generated Viper text for functionObjectCall: -method global$fun_functionObjectCall$fun_take$fun_take$T_Boolean$T_Int$return$T_Int$return$T_Int(local$g: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$functionObjectCall$TF$TF$T$Boolean$T$Int(p$g: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$g), dom$RuntimeType$functionType()) - anonymous$1 := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$intType()) - ret$0 := anonymous$1 - goto label$ret$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$g), DF$RT$functionType()) + a$1 := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + r$0 := a$1 + goto lbl$ret$0 + label lbl$ret$0 } /function_object.kt:(171,195): info: Generated Viper text for functionObjectNestedCall: -method global$fun_functionObjectNestedCall$fun_take$fun_take$T_Int$return$T_Int$fun_take$T_Boolean$return$T_Int$return$T_Int(local$f: Ref, - local$g: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$functionObjectNestedCall$TF$TF$T$Int$TF$T$Boolean(p$f: Ref, p$g: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var anonymous$5: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$functionType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$g), dom$RuntimeType$functionType()) - anonymous$3 := anonymous$2 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$3), dom$RuntimeType$intType()) - anonymous$4 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$4), dom$RuntimeType$intType()) - anonymous$5 := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$5), dom$RuntimeType$intType()) - ret$0 := anonymous$5 - goto label$ret$0 - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + var a$5: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$functionType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$g), DF$RT$functionType()) + a$3 := a$2 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$3), DF$RT$intType()) + a$4 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$4), DF$RT$intType()) + a$5 := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$5), DF$RT$intType()) + r$0 := a$5 + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/function_overloading.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/function_overloading.fir.diag.txt index ef4ae125db691a..6e931b7d4d307d 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/function_overloading.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/function_overloading.fir.diag.txt @@ -1,171 +1,151 @@ /function_overloading.kt:(49,52): info: Generated Viper text for baz: -method class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Foo$return$T_Unit(this: Ref, - local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Foo(this: Ref, p$f: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(this), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$f), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(this), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$f), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(74,77): info: Generated Viper text for baz: -method class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Bar$return$T_Unit(this: Ref, - local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Bar(this: Ref, p$b: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(this), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$b), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(this), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$b), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(98,107): info: Generated Viper text for fakePrint: -method global$fun_fakePrint$fun_take$T_class_global$class_Bar$return$T_Unit(local$b: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$class_c$g$Bar(p$b: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$b), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(local$b), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$b), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(p$b), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(125,134): info: Generated Viper text for fakePrint: -method global$fun_fakePrint$fun_take$T_class_global$class_Foo$return$T_Unit(local$f: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$class_c$g$Foo(p$f: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$f), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$f), wildcard) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$f), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$f), wildcard) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(152,161): info: Generated Viper text for fakePrint: -method global$fun_fakePrint$fun_take$T_Int$return$T_Unit(local$value: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$Int(p$value: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$value), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$value), DF$RT$intType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(183,192): info: Generated Viper text for fakePrint: -method global$fun_fakePrint$fun_take$T_Boolean$return$T_Unit(local$truth: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$Boolean(p$truth: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$truth), dom$RuntimeType$boolType()) - ret$0 := dom$RuntimeType$unitValue() - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$truth), DF$RT$boolType()) + r$0 := DF$RT$unitValue() + label lbl$ret$0 } /function_overloading.kt:(219,245): info: Generated Viper text for testGlobalScopeOverloading: -method class_Bar$constructor$fun_take$$return$T_class_global$class_Bar() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Bar()) - ensures acc(T_class_global$class_Bar(ret), wildcard) - ensures acc(Unique$T_class_global$class_Bar(ret), write) +method con$c$Bar$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Bar()) + ensures acc(T$class_c$g$Bar(ret), wildcard) + ensures acc(U$T$class_c$g$Bar(ret), write) -method class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Foo()) - ensures acc(T_class_global$class_Foo(ret), wildcard) - ensures acc(Unique$T_class_global$class_Foo(ret), write) +method con$c$Foo$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Foo()) + ensures acc(T$class_c$g$Foo(ret), wildcard) + ensures acc(U$T$class_c$g$Foo(ret), write) -method global$fun_fakePrint$fun_take$T_Boolean$return$T_Unit(local$truth: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$Boolean(p$truth: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_fakePrint$fun_take$T_Int$return$T_Unit(local$value: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$Int(p$value: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_fakePrint$fun_take$T_class_global$class_Bar$return$T_Unit(local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$class_c$g$Bar(p$b: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_fakePrint$fun_take$T_class_global$class_Foo$return$T_Unit(local$f: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$g$fakePrint$TF$T$class_c$g$Foo(p$f: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_testGlobalScopeOverloading$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testGlobalScopeOverloading$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - var anonymous$4: Ref - var anonymous$5: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$fun_fakePrint$fun_take$T_Int$return$T_Unit(dom$RuntimeType$intToRef(42)) - anonymous$1 := global$fun_fakePrint$fun_take$T_Boolean$return$T_Unit(dom$RuntimeType$boolToRef(true)) - anonymous$3 := class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() - anonymous$2 := global$fun_fakePrint$fun_take$T_class_global$class_Foo$return$T_Unit(anonymous$3) - anonymous$5 := class_Bar$constructor$fun_take$$return$T_class_global$class_Bar() - anonymous$4 := global$fun_fakePrint$fun_take$T_class_global$class_Bar$return$T_Unit(anonymous$5) - label label$ret$0 + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + var a$4: Ref + var a$5: Ref + r$0 := DF$RT$unitValue() + a$0 := f$g$fakePrint$TF$T$Int(DF$RT$intToRef(42)) + a$1 := f$g$fakePrint$TF$T$Boolean(DF$RT$boolToRef(true)) + a$3 := con$c$Foo$() + a$2 := f$g$fakePrint$TF$T$class_c$g$Foo(a$3) + a$5 := con$c$Bar$() + a$4 := f$g$fakePrint$TF$T$class_c$g$Bar(a$5) + label lbl$ret$0 } /function_overloading.kt:(337,365): info: Generated Viper text for testClassFunctionOverloading: -method class_Bar$constructor$fun_take$$return$T_class_global$class_Bar() - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Bar()) - ensures acc(T_class_global$class_Bar(ret), wildcard) - ensures acc(Unique$T_class_global$class_Bar(ret), write) +method con$c$Bar$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Bar()) + ensures acc(T$class_c$g$Bar(ret), wildcard) + ensures acc(U$T$class_c$g$Bar(ret), write) -method class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Bar$return$T_Unit(this: Ref, - local$b: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method con$c$Foo$() returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Foo()) + ensures acc(T$class_c$g$Foo(ret), wildcard) + ensures acc(U$T$class_c$g$Foo(ret), write) -method class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Foo$return$T_Unit(this: Ref, - local$f: Ref) +method f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Bar(this: Ref, p$b: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() +method f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Foo(this: Ref, p$f: Ref) returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Foo()) - ensures acc(T_class_global$class_Foo(ret), wildcard) - ensures acc(Unique$T_class_global$class_Foo(ret), write) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_testClassFunctionOverloading$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$testClassFunctionOverloading$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$b: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - var anonymous$3: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$b := class_Bar$constructor$fun_take$$return$T_class_global$class_Bar() - anonymous$1 := class_Foo$constructor$fun_take$$return$T_class_global$class_Foo() - anonymous$0 := class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Foo$return$T_Unit(local0$b, - anonymous$1) - anonymous$3 := class_Bar$constructor$fun_take$$return$T_class_global$class_Bar() - anonymous$2 := class_Bar$fun_baz$fun_take$T_class_global$class_Bar$T_class_global$class_Bar$return$T_Unit(local0$b, - anonymous$3) - label label$ret$0 + var l0$b: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + var a$3: Ref + r$0 := DF$RT$unitValue() + l0$b := con$c$Bar$() + a$1 := con$c$Foo$() + a$0 := f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Foo(l0$b, a$1) + a$3 := con$c$Bar$() + a$2 := f$c$Bar$baz$TF$T$class_c$g$Bar$T$class_c$g$Bar(l0$b, a$3) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/captured.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/captured.fir.diag.txt index 8a6cbbe7212a4e..048989d2976538 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/captured.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/captured.fir.diag.txt @@ -1,200 +1,194 @@ /captured.kt:(155,165): info: Generated Viper text for captureArg: -method global$fun_captureArg$fun_take$fun_take$T_Int$return$T_Int$return$T_Int(local$g: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$captureArg$TF$TF$T$Int(p$g: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var anonymous$1: Ref - var anonymous$2: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$g), dom$RuntimeType$functionType()) - anonymous$0 := dom$RuntimeType$intToRef(0) - anonymous$2 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$2), dom$RuntimeType$intType()) - ret$2 := anonymous$2 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + var a$1: Ref + var a$2: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$g), DF$RT$functionType()) + a$0 := DF$RT$intToRef(0) + a$2 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$2), DF$RT$intType()) + r$2 := a$2 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(225,235): info: Generated Viper text for captureVar: -method global$fun_captureVar$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$captureVar$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - local0$x := dom$RuntimeType$intToRef(1) - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := special$plusInts(anonymous$0, local0$x) - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var l0$x: Ref + var r$1: Ref + var r$2: Ref + var a$0: Ref + l0$x := DF$RT$intToRef(1) + a$0 := DF$RT$intToRef(0) + r$2 := sp$plusInts(a$0, l0$x) + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(295,311): info: Generated Viper text for captureAndShadow: -method global$fun_captureAndShadow$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$captureAndShadow$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var local2$y: Ref - var local2$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - anonymous$0 := dom$RuntimeType$intToRef(0) - local2$y := local$x - local2$x := dom$RuntimeType$intToRef(1) - ret$2 := special$plusInts(special$plusInts(anonymous$0, local2$x), local2$y) - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + var l2$y: Ref + var l2$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + a$0 := DF$RT$intToRef(0) + l2$y := p$x + l2$x := DF$RT$intToRef(1) + r$2 := sp$plusInts(sp$plusInts(a$0, l2$x), l2$y) + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(513,528): info: Generated Viper text for captureVarClash: -method global$fun_captureVarClash$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$captureVarClash$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var local1$x: Ref - var anonymous$1: Ref - var ret$2: Ref - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - local1$x := dom$RuntimeType$intToRef(1) - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := special$timesInts(anonymous$0, local$x) - goto label$ret$2 - label label$ret$2 - anonymous$1 := ret$2 - ret$1 := special$plusInts(anonymous$1, local1$x) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var l1$x: Ref + var a$1: Ref + var r$2: Ref + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + l1$x := DF$RT$intToRef(1) + a$0 := DF$RT$intToRef(0) + r$2 := sp$timesInts(a$0, p$x) + goto lbl$ret$2 + label lbl$ret$2 + a$1 := r$2 + r$1 := sp$plusInts(a$1, l1$x) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(585,606): info: Generated Viper text for captureAndShadowClash: -method global$fun_captureAndShadowClash$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$captureAndShadowClash$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var local1$x: Ref - var anonymous$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var local2$y: Ref - var local2$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - local1$x := dom$RuntimeType$intToRef(1) - anonymous$0 := dom$RuntimeType$intToRef(0) - local2$y := local$x - local2$x := dom$RuntimeType$intToRef(2) - ret$2 := special$plusInts(special$plusInts(local2$x, local2$y), anonymous$0) - goto label$ret$2 - label label$ret$2 - anonymous$1 := ret$2 - ret$1 := special$plusInts(anonymous$1, local1$x) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var l1$x: Ref + var a$1: Ref + var r$2: Ref + var a$0: Ref + var l2$y: Ref + var l2$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + l1$x := DF$RT$intToRef(1) + a$0 := DF$RT$intToRef(0) + l2$y := p$x + l2$x := DF$RT$intToRef(2) + r$2 := sp$plusInts(sp$plusInts(l2$x, l2$y), a$0) + goto lbl$ret$2 + label lbl$ret$2 + a$1 := r$2 + r$1 := sp$plusInts(a$1, l1$x) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(715,736): info: Generated Viper text for nestedLambdaShadowing: -method global$fun_nestedLambdaShadowing$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$nestedLambdaShadowing$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var local1$x: Ref - var anonymous$2: Ref - var ret$2: Ref - var anonymous$0: Ref - var ret$3: Ref - var local3$x: Ref - var anonymous$3: Ref - var ret$4: Ref - var anonymous$1: Ref - var local4$x: Ref - var local2$y: Ref - var local2$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - local1$x := dom$RuntimeType$intToRef(1) - anonymous$0 := dom$RuntimeType$intToRef(0) - local3$x := dom$RuntimeType$intToRef(1) - anonymous$1 := dom$RuntimeType$intToRef(0) - local4$x := dom$RuntimeType$intToRef(3) - ret$4 := special$plusInts(local4$x, anonymous$1) - goto label$ret$4 - label label$ret$4 - anonymous$3 := ret$4 - ret$3 := special$plusInts(anonymous$3, local3$x) - goto label$ret$3 - label label$ret$3 - local2$y := local$x - local2$x := dom$RuntimeType$intToRef(4) - ret$2 := special$plusInts(special$plusInts(local2$x, local2$y), anonymous$0) - goto label$ret$2 - label label$ret$2 - anonymous$2 := ret$2 - ret$1 := special$plusInts(anonymous$2, local1$x) - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var l1$x: Ref + var a$2: Ref + var r$2: Ref + var a$0: Ref + var r$3: Ref + var l3$x: Ref + var a$3: Ref + var r$4: Ref + var a$1: Ref + var l4$x: Ref + var l2$y: Ref + var l2$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + l1$x := DF$RT$intToRef(1) + a$0 := DF$RT$intToRef(0) + l3$x := DF$RT$intToRef(1) + a$1 := DF$RT$intToRef(0) + l4$x := DF$RT$intToRef(3) + r$4 := sp$plusInts(l4$x, a$1) + goto lbl$ret$4 + label lbl$ret$4 + a$3 := r$4 + r$3 := sp$plusInts(a$3, l3$x) + goto lbl$ret$3 + label lbl$ret$3 + l2$y := p$x + l2$x := DF$RT$intToRef(4) + r$2 := sp$plusInts(sp$plusInts(l2$x, l2$y), a$0) + goto lbl$ret$2 + label lbl$ret$2 + a$2 := r$2 + r$1 := sp$plusInts(a$2, l1$x) + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /captured.kt:(1008,1024): info: Generated Viper text for callDoubleInvoke: -method global$fun_callDoubleInvoke$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$callDoubleInvoke$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var local2$x: Ref - var ret$3: Ref - var anonymous$1: Ref - var local3$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - anonymous$0 := dom$RuntimeType$intToRef(0) - local2$x := anonymous$0 - ret$2 := local2$x - goto label$ret$2 - label label$ret$2 - anonymous$1 := dom$RuntimeType$intToRef(1) - local3$x := anonymous$1 - ret$3 := local3$x - goto label$ret$3 - label label$ret$3 - ret$1 := ret$3 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + var l2$x: Ref + var r$3: Ref + var a$1: Ref + var l3$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + a$0 := DF$RT$intToRef(0) + l2$x := a$0 + r$2 := l2$x + goto lbl$ret$2 + label lbl$ret$2 + a$1 := DF$RT$intToRef(1) + l3$x := a$1 + r$3 := l3$x + goto lbl$ret$3 + label lbl$ret$3 + r$1 := r$3 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/inline.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/inline.fir.diag.txt index f02ce6b952783d..9b81e70ad55d0e 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/inline.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/inline.fir.diag.txt @@ -1,62 +1,60 @@ /inline.kt:(230,239): info: Generated Viper text for quadruple: -method global$fun_quadruple$fun_take$T_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$quadruple$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var ret$1: Ref - var local1$y: Ref - var anonymous$1: Ref - var ret$2: Ref - var local2$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - local1$y := special$plusInts(local$x, local$x) - ret$1 := local1$y - goto label$ret$1 - label label$ret$1 - anonymous$0 := ret$1 - local2$y := special$plusInts(local$x, local$x) - ret$2 := local2$y - goto label$ret$2 - label label$ret$2 - anonymous$1 := ret$2 - ret$0 := special$plusInts(anonymous$0, anonymous$1) - goto label$ret$0 - label label$ret$0 + var a$0: Ref + var r$1: Ref + var l1$y: Ref + var a$1: Ref + var r$2: Ref + var l2$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + l1$y := sp$plusInts(p$x, p$x) + r$1 := l1$y + goto lbl$ret$1 + label lbl$ret$1 + a$0 := r$1 + l2$y := sp$plusInts(p$x, p$x) + r$2 := l2$y + goto lbl$ret$2 + label lbl$ret$2 + a$1 := r$2 + r$0 := sp$plusInts(a$0, a$1) + goto lbl$ret$0 + label lbl$ret$0 } /inline.kt:(469,481): info: Generated Viper text for useBranching: -method global$fun_useBranching$fun_take$$return$T_Int() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$useBranching$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$2: Ref - var ret$1: Ref - var anonymous$0: Ref - var anonymous$3: Ref - var ret$2: Ref - var anonymous$1: Ref - anonymous$0 := dom$RuntimeType$boolToRef(false) - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - ret$1 := dom$RuntimeType$intToRef(1) - goto label$ret$1 + var a$2: Ref + var r$1: Ref + var a$0: Ref + var a$3: Ref + var r$2: Ref + var a$1: Ref + a$0 := DF$RT$boolToRef(false) + if (DF$RT$boolFromRef(a$0)) { + r$1 := DF$RT$intToRef(1) + goto lbl$ret$1 } else { - ret$1 := dom$RuntimeType$intToRef(0) - goto label$ret$1 + r$1 := DF$RT$intToRef(0) + goto lbl$ret$1 } - label label$ret$1 - anonymous$2 := ret$1 - anonymous$1 := dom$RuntimeType$boolToRef(true) - if (dom$RuntimeType$boolFromRef(anonymous$1)) { - ret$2 := dom$RuntimeType$intToRef(1) - goto label$ret$2 + label lbl$ret$1 + a$2 := r$1 + a$1 := DF$RT$boolToRef(true) + if (DF$RT$boolFromRef(a$1)) { + r$2 := DF$RT$intToRef(1) + goto lbl$ret$2 } else { - ret$2 := dom$RuntimeType$intToRef(0) - goto label$ret$2 + r$2 := DF$RT$intToRef(0) + goto lbl$ret$2 } - label label$ret$2 - anonymous$3 := ret$2 - ret$0 := special$plusInts(anonymous$2, anonymous$3) - goto label$ret$0 - label label$ret$0 + label lbl$ret$2 + a$3 := r$2 + r$0 := sp$plusInts(a$2, a$3) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/lambdas.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/lambdas.fir.diag.txt index 70cd904c7cf2ff..1a66a9f618739e 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/lambdas.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/inlining/lambdas.fir.diag.txt @@ -1,151 +1,149 @@ /lambdas.kt:(155,166): info: Generated Viper text for explicitArg: -method global$fun_explicitArg$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$explicitArg$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := special$plusInts(anonymous$0, anonymous$0) - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + a$0 := DF$RT$intToRef(0) + r$2 := sp$plusInts(a$0, a$0) + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /lambdas.kt:(216,227): info: Generated Viper text for implicitArg: -method global$fun_implicitArg$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$implicitArg$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := special$timesInts(anonymous$0, dom$RuntimeType$intToRef(2)) - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + a$0 := DF$RT$intToRef(0) + r$2 := sp$timesInts(a$0, DF$RT$intToRef(2)) + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /lambdas.kt:(273,281): info: Generated Viper text for lambdaIf: -method global$fun_lambdaIf$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$lambdaIf$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - anonymous$0 := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$intFromRef(anonymous$0) == 0) { - ret$2 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) + var r$1: Ref + var r$2: Ref + var a$0: Ref + a$0 := DF$RT$intToRef(0) + if (DF$RT$intFromRef(a$0) == 0) { + r$2 := sp$plusInts(a$0, DF$RT$intToRef(1)) } else { - ret$2 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(2))} - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + r$2 := sp$plusInts(a$0, DF$RT$intToRef(2))} + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /lambdas.kt:(412,430): info: Generated Viper text for returnValueNotUsed: -method global$fun_returnValueNotUsed$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$returnValueNotUsed$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$2 := anonymous$0 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := DF$RT$intToRef(0) + r$2 := a$0 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + label lbl$ret$0 } /lambdas.kt:(466,475): info: Generated Viper text for shadowing: -method global$fun_shadowing$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$shadowing$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - var local0$y: Ref - var ret$1: Ref - var ret$2: Ref - var anonymous$0: Ref - var local2$y: Ref - local0$x := dom$RuntimeType$intToRef(1) - local0$y := dom$RuntimeType$intToRef(1) - anonymous$0 := dom$RuntimeType$intToRef(0) - local2$y := dom$RuntimeType$intToRef(0) - ret$2 := special$plusInts(anonymous$0, local2$y) - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var l0$x: Ref + var l0$y: Ref + var r$1: Ref + var r$2: Ref + var a$0: Ref + var l2$y: Ref + l0$x := DF$RT$intToRef(1) + l0$y := DF$RT$intToRef(1) + a$0 := DF$RT$intToRef(0) + l2$y := DF$RT$intToRef(0) + r$2 := sp$plusInts(a$0, l2$y) + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /lambdas.kt:(711,717): info: Generated Viper text for nested: -method global$fun_nested$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$nested$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$x: Ref - var ret$1: Ref - var local1$x: Ref - var ret$2: Ref - var ret$3: Ref - var anonymous$0: Ref - local0$x := dom$RuntimeType$intToRef(2) - local1$x := dom$RuntimeType$intToRef(2) - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$3 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - goto label$ret$3 - label label$ret$3 - ret$2 := ret$3 - goto label$ret$2 - label label$ret$2 - ret$1 := ret$2 - goto label$ret$1 - label label$ret$1 - ret$0 := ret$1 - goto label$ret$0 - label label$ret$0 + var l0$x: Ref + var r$1: Ref + var l1$x: Ref + var r$2: Ref + var r$3: Ref + var a$0: Ref + l0$x := DF$RT$intToRef(2) + l1$x := DF$RT$intToRef(2) + a$0 := DF$RT$intToRef(0) + r$3 := sp$plusInts(a$0, DF$RT$intToRef(1)) + goto lbl$ret$3 + label lbl$ret$3 + r$2 := r$3 + goto lbl$ret$2 + label lbl$ret$2 + r$1 := r$2 + goto lbl$ret$1 + label lbl$ret$1 + r$0 := r$1 + goto lbl$ret$0 + label lbl$ret$0 } /lambdas.kt:(853,870): info: Generated Viper text for lambdaPassthrough: -method global$fun_lambdaPassthrough$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$lambdaPassthrough$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var ret$1: Ref - var ret$2: Ref - var ret$3: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := dom$RuntimeType$intToRef(0) - ret$3 := special$plusInts(anonymous$0, dom$RuntimeType$intToRef(1)) - goto label$ret$3 - label label$ret$3 - ret$2 := ret$3 - goto label$ret$2 - label label$ret$2 - label label$ret$1 - label label$ret$0 + var r$1: Ref + var r$2: Ref + var r$3: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := DF$RT$intToRef(0) + r$3 := sp$plusInts(a$0, DF$RT$intToRef(1)) + goto lbl$ret$3 + label lbl$ret$3 + r$2 := r$3 + goto lbl$ret$2 + label lbl$ret$2 + label lbl$ret$1 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/arithmetic.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/arithmetic.fir.diag.txt index c395e288eaf63a..69fad79d43deaa 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/arithmetic.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/arithmetic.fir.diag.txt @@ -1,48 +1,44 @@ /arithmetic.kt:(23,31): info: Generated Viper text for addition: -method global$fun_addition$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$addition$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$y := special$plusInts(local$x, local$x) - label label$ret$0 + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$y := sp$plusInts(p$x, p$x) + label lbl$ret$0 } /arithmetic.kt:(66,77): info: Generated Viper text for subtraction: -method global$fun_subtraction$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$subtraction$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$y := special$minusInts(local$x, local$x) - label label$ret$0 + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$y := sp$minusInts(p$x, p$x) + label lbl$ret$0 } /arithmetic.kt:(112,126): info: Generated Viper text for multiplication: -method global$fun_multiplication$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$multiplication$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$y := special$timesInts(local$x, local$x) - label label$ret$0 + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$y := sp$timesInts(p$x, p$x) + label lbl$ret$0 } /arithmetic.kt:(161,169): info: Generated Viper text for division: -method global$fun_division$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$division$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - inhale dom$RuntimeType$intFromRef(local$x) != 0 - local0$y := special$divInts(local$x, local$x) - label label$ret$0 + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + inhale DF$RT$intFromRef(p$x) != 0 + l0$y := sp$divInts(p$x, p$x) + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/as_operator.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/as_operator.fir.diag.txt index 18159daadf3adf..38d05995bf75ae 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/as_operator.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/as_operator.fir.diag.txt @@ -1,73 +1,64 @@ /as_operator.kt:(57,63): info: Generated Viper text for testAs: -method global$fun_testAs$fun_take$T_class_global$class_Foo$return$T_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Bar()) - ensures acc(T_class_global$class_Bar(ret$0), wildcard) +method f$g$testAs$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Bar()) + ensures acc(T$class_c$g$Bar(r$0), wildcard) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := local$foo - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$T_class_global$class_Bar()) - inhale acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := p$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$T$class_c$g$Bar()) + inhale acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } /as_operator.kt:(97,111): info: Generated Viper text for testNullableAs: -method global$fun_testNullableAs$fun_take$NT_class_global$class_Foo$return$NT_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) +method f$g$testNullableAs$TF$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Foo())) - inhale local$foo != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Foo(local$foo), wildcard) - ret$0 := local$foo - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - inhale ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$nullable(DF$RT$T$class_c$g$Foo())) + inhale p$foo != DF$RT$nullValue() ==> + acc(T$class_c$g$Foo(p$foo), wildcard) + r$0 := p$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + inhale r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } /as_operator.kt:(148,158): info: Generated Viper text for testSafeAs: -method global$fun_testSafeAs$fun_take$T_class_global$class_Foo$return$NT_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) +method f$g$testSafeAs$TF$T$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Bar())) { - ret$0 := local$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + if (DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Bar())) { + r$0 := p$foo } else { - ret$0 := dom$RuntimeType$nullValue()} - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - inhale ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + inhale r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } /as_operator.kt:(194,212): info: Generated Viper text for testNullableSafeAs: -method global$fun_testNullableSafeAs$fun_take$NT_class_global$class_Foo$return$NT_class_global$class_Bar(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - ensures ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) +method f$g$testNullableSafeAs$TF$class_c$g$Foo(p$foo: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + ensures r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Foo())) - inhale local$foo != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Foo(local$foo), wildcard) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Bar())) { - ret$0 := local$foo + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$nullable(DF$RT$T$class_c$g$Foo())) + inhale p$foo != DF$RT$nullValue() ==> + acc(T$class_c$g$Foo(p$foo), wildcard) + if (DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Bar())) { + r$0 := p$foo } else { - ret$0 := dom$RuntimeType$nullValue()} - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Bar())) - inhale ret$0 != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Bar(ret$0), wildcard) - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$T$class_c$g$Bar())) + inhale r$0 != DF$RT$nullValue() ==> acc(T$class_c$g$Bar(r$0), wildcard) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/boolean_logic.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/boolean_logic.fir.diag.txt index 26da088f5c2d3f..6a422c4bc75ab8 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/boolean_logic.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/boolean_logic.fir.diag.txt @@ -1,65 +1,60 @@ /boolean_logic.kt:(23,31): info: Generated Viper text for negation: -method global$fun_negation$fun_take$T_Boolean$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$negation$TF$T$Boolean(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$boolType()) - ret$0 := special$notBool(local$x) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$boolType()) + r$0 := sp$notBool(p$x) + goto lbl$ret$0 + label lbl$ret$0 } /boolean_logic.kt:(75,86): info: Generated Viper text for conjunction: -method global$fun_conjunction$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$conjunction$TF$T$Boolean$T$Boolean(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$x)) { - ret$0 := local$y + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$x)) { + r$0 := p$y } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } /boolean_logic.kt:(146,168): info: Generated Viper text for conjunctionSideEffects: -method global$fun_conjunctionSideEffects$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$conjunctionSideEffects$TF$T$Boolean$T$Boolean(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$boolType()) - anonymous$0 := global$fun_negation$fun_take$T_Boolean$return$T_Boolean(local$x) - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - ret$0 := global$fun_negation$fun_take$T_Boolean$return$T_Boolean(local$y) + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$boolType()) + a$0 := f$g$negation$TF$T$Boolean(p$x) + if (DF$RT$boolFromRef(a$0)) { + r$0 := f$g$negation$TF$T$Boolean(p$y) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_negation$fun_take$T_Boolean$return$T_Boolean(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$boolType()) +method f$g$negation$TF$T$Boolean(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$boolType()) /boolean_logic.kt:(341,352): info: Generated Viper text for disjunction: -method global$fun_disjunction$fun_take$T_Boolean$T_Boolean$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$disjunction$TF$T$Boolean$T$Boolean(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$boolType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(local$x)) { - ret$0 := dom$RuntimeType$boolToRef(true) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$boolType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$boolType()) + if (DF$RT$boolFromRef(p$x)) { + r$0 := DF$RT$boolToRef(true) } else { - ret$0 := local$y} - goto label$ret$0 - label label$ret$0 + r$0 := p$y} + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/comparison.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/comparison.fir.diag.txt index 7ef5d326146a9c..55366843780253 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/comparison.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/comparison.fir.diag.txt @@ -1,50 +1,44 @@ /comparison.kt:(23,27): info: Generated Viper text for less: -method global$fun_less$fun_take$T_Int$T_Int$return$T_Boolean(local$x: Ref, local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$less$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - ret$0 := special$ltInts(local$x, local$y) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + r$0 := sp$ltInts(p$x, p$y) + goto lbl$ret$0 + label lbl$ret$0 } /comparison.kt:(79,88): info: Generated Viper text for lessEqual: -method global$fun_lessEqual$fun_take$T_Int$T_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$lessEqual$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - ret$0 := special$leInts(local$x, local$y) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + r$0 := sp$leInts(p$x, p$y) + goto lbl$ret$0 + label lbl$ret$0 } /comparison.kt:(141,148): info: Generated Viper text for greater: -method global$fun_greater$fun_take$T_Int$T_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$greater$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - ret$0 := special$gtInts(local$x, local$y) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + r$0 := sp$gtInts(p$x, p$y) + goto lbl$ret$0 + label lbl$ret$0 } /comparison.kt:(200,212): info: Generated Viper text for greaterEqual: -method global$fun_greaterEqual$fun_take$T_Int$T_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$greaterEqual$TF$T$Int$T$Int(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$intType()) - ret$0 := special$geInts(local$x, local$y) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$intType()) + r$0 := sp$geInts(p$x, p$y) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/elvis.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/elvis.fir.diag.txt index aeea1d0d51e6ab..a963116bca41df 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/elvis.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/elvis.fir.diag.txt @@ -1,59 +1,54 @@ /elvis.kt:(121,134): info: Generated Viper text for elvisOperator: -method global$fun_elvisOperator$fun_take$NT_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$elvisOperator$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - if (local$x != dom$RuntimeType$nullValue()) { - ret$0 := local$x + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + if (p$x != DF$RT$nullValue()) { + r$0 := p$x } else { - ret$0 := dom$RuntimeType$intToRef(3)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(3)} + goto lbl$ret$0 + label lbl$ret$0 } /elvis.kt:(176,196): info: Generated Viper text for elvisOperatorComplex: -method global$fun_elvisOperator$fun_take$NT_Int$return$T_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$intType()) +method f$g$elvisOperator$TF$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$intType()) -method global$fun_elvisOperatorComplex$fun_take$NT_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$elvisOperatorComplex$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - anonymous$0 := global$fun_id$fun_take$NT_Int$return$NT_Int(local$x) - if (anonymous$0 != dom$RuntimeType$nullValue()) { - ret$0 := anonymous$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + a$0 := f$g$id$TF$Int(p$x) + if (a$0 != DF$RT$nullValue()) { + r$0 := a$0 } else { - ret$0 := global$fun_elvisOperator$fun_take$NT_Int$return$T_Int(dom$RuntimeType$intToRef(2))} - goto label$ret$0 - label label$ret$0 + r$0 := f$g$elvisOperator$TF$Int(DF$RT$intToRef(2))} + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_id$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$id$TF$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$nullable(DF$RT$intType())) /elvis.kt:(257,276): info: Generated Viper text for elvisOperatorReturn: -method global$fun_elvisOperatorReturn$fun_take$NT_Int$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$elvisOperatorReturn$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$y: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - if (local$x != dom$RuntimeType$nullValue()) { - local0$y := local$x + var l0$y: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + if (p$x != DF$RT$nullValue()) { + l0$y := p$x } else { - var anonymous$0: Ref - ret$0 := dom$RuntimeType$intToRef(0) - goto label$ret$0 - local0$y := anonymous$0 + var a$0: Ref + r$0 := DF$RT$intToRef(0) + goto lbl$ret$0 + l0$y := a$0 } - ret$0 := local0$y - goto label$ret$0 - label label$ret$0 + r$0 := l0$y + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/is_operator.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/is_operator.fir.diag.txt index 881d9490f3a81c..00f776ec488cdc 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/is_operator.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/is_operator.fir.diag.txt @@ -1,39 +1,34 @@ /is_operator.kt:(23,36): info: Generated Viper text for isNonNullable: -method global$fun_isNonNullable$fun_take$NT_Int$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$isNonNullable$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), - dom$RuntimeType$intType())) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType())) + goto lbl$ret$0 + label lbl$ret$0 } /is_operator.kt:(84,97): info: Generated Viper text for notIsNullable: -method global$fun_notIsNullable$fun_take$NT_Int$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$notIsNullable$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := special$notBool(dom$RuntimeType$boolToRef(dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), - dom$RuntimeType$nothingType()))) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := sp$notBool(DF$RT$boolToRef(DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nothingType()))) + goto lbl$ret$0 + label lbl$ret$0 } /is_operator.kt:(150,159): info: Generated Viper text for smartCast: -method global$fun_smartCast$fun_take$NT_Any$return$T_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$smartCast$TF$Any(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - if (dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType())) { - ret$0 := local$x - goto label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + if (DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType())) { + r$0 := p$x + goto lbl$ret$0 } else { - ret$0 := dom$RuntimeType$intToRef(-1) - goto label$ret$0 + r$0 := DF$RT$intToRef(-1) + goto lbl$ret$0 } - label label$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/safe_call.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/safe_call.fir.diag.txt index 4b6c005d66f8ac..00079d797eb5aa 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/operators/safe_call.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/operators/safe_call.fir.diag.txt @@ -1,127 +1,121 @@ /safe_call.kt:(142,154): info: Generated Viper text for testSafeCall: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_f$fun_take$T_class_global$class_Foo$return$T_Unit(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$c$Foo$f$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_testSafeCall$fun_take$NT_class_global$class_Foo$return$NT_Unit(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$unitType())) +method f$g$testSafeCall$TF$class_c$g$Foo(p$foo: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$unitType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Foo())) - inhale local$foo != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Foo(local$foo), wildcard) - if (local$foo != dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - anonymous$0 := class_Foo$fun_f$fun_take$T_class_global$class_Foo$return$T_Unit(local$foo) - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$nullable(DF$RT$T$class_c$g$Foo())) + inhale p$foo != DF$RT$nullValue() ==> + acc(T$class_c$g$Foo(p$foo), wildcard) + if (p$foo != DF$RT$nullValue()) { + var a$0: Ref + a$0 := f$c$Foo$f$TF$T$class_c$g$Foo(p$foo) + r$0 := a$0 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /safe_call.kt:(217,240): info: Generated Viper text for testSafeCallNonNullable: -field public$backing_field_x: Ref +field bf$public$x: Ref -method class_Foo$fun_f$fun_take$T_class_global$class_Foo$return$T_Unit(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$unitType()) +method f$c$Foo$f$TF$T$class_c$g$Foo(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$unitType()) -method global$fun_testSafeCallNonNullable$fun_take$T_class_global$class_Foo$return$NT_Unit(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$unitType())) +method f$g$testSafeCallNonNullable$TF$T$class_c$g$Foo(p$foo: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$unitType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - if (local$foo != dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - anonymous$0 := class_Foo$fun_f$fun_take$T_class_global$class_Foo$return$T_Unit(local$foo) - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + if (p$foo != DF$RT$nullValue()) { + var a$0: Ref + a$0 := f$c$Foo$f$TF$T$class_c$g$Foo(p$foo) + r$0 := a$0 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /safe_call.kt:(267,287): info: Generated Viper text for testSafeCallProperty: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_testSafeCallProperty$fun_take$NT_class_global$class_Foo$return$NT_Int(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$testSafeCallProperty$TF$class_c$g$Foo(p$foo: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Foo())) - inhale local$foo != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Foo(local$foo), wildcard) - if (local$foo != dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - unfold acc(T_class_global$class_Foo(local$foo), wildcard) - anonymous$0 := local$foo.public$backing_field_x - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$nullable(DF$RT$T$class_c$g$Foo())) + inhale p$foo != DF$RT$nullValue() ==> + acc(T$class_c$g$Foo(p$foo), wildcard) + if (p$foo != DF$RT$nullValue()) { + var a$0: Ref + unfold acc(T$class_c$g$Foo(p$foo), wildcard) + a$0 := p$foo.bf$public$x + r$0 := a$0 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /safe_call.kt:(354,385): info: Generated Viper text for testSafeCallPropertyNonNullable: -field public$backing_field_x: Ref +field bf$public$x: Ref -method global$fun_testSafeCallPropertyNonNullable$fun_take$T_class_global$class_Foo$return$NT_Int(local$foo: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$testSafeCallPropertyNonNullable$TF$T$class_c$g$Foo(p$foo: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$foo), dom$RuntimeType$T_class_global$class_Foo()) - inhale acc(T_class_global$class_Foo(local$foo), wildcard) - if (local$foo != dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - unfold acc(T_class_global$class_Foo(local$foo), wildcard) - anonymous$0 := local$foo.public$backing_field_x - ret$0 := anonymous$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$foo), DF$RT$T$class_c$g$Foo()) + inhale acc(T$class_c$g$Foo(p$foo), wildcard) + if (p$foo != DF$RT$nullValue()) { + var a$0: Ref + unfold acc(T$class_c$g$Foo(p$foo), wildcard) + a$0 := p$foo.bf$public$x + r$0 := a$0 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } /safe_call.kt:(493,506): info: Generated Viper text for safeCallChain: -field public$backing_field_v: Ref +field bf$public$v: Ref -method class_Rec$fun_nullable$fun_take$T_class_global$class_Rec$return$NT_class_global$class_Rec(this: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Rec())) - ensures ret != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Rec(ret), wildcard) +method f$c$Rec$nullable$TF$T$class_c$g$Rec(this: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$nullable(DF$RT$T$class_c$g$Rec())) + ensures ret != DF$RT$nullValue() ==> acc(T$class_c$g$Rec(ret), wildcard) -method global$fun_safeCallChain$fun_take$NT_class_global$class_Rec$return$NT_Int(local$rec: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$safeCallChain$TF$class_c$g$Rec(p$rec: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$rec), dom$RuntimeType$nullable(dom$RuntimeType$T_class_global$class_Rec())) - inhale local$rec != dom$RuntimeType$nullValue() ==> - acc(T_class_global$class_Rec(local$rec), wildcard) - if (local$rec != dom$RuntimeType$nullValue()) { - anonymous$1 := class_Rec$fun_nullable$fun_take$T_class_global$class_Rec$return$NT_class_global$class_Rec(local$rec) + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$rec), DF$RT$nullable(DF$RT$T$class_c$g$Rec())) + inhale p$rec != DF$RT$nullValue() ==> + acc(T$class_c$g$Rec(p$rec), wildcard) + if (p$rec != DF$RT$nullValue()) { + a$1 := f$c$Rec$nullable$TF$T$class_c$g$Rec(p$rec) } else { - anonymous$1 := dom$RuntimeType$nullValue()} - if (anonymous$1 != dom$RuntimeType$nullValue()) { - anonymous$0 := class_Rec$fun_nullable$fun_take$T_class_global$class_Rec$return$NT_class_global$class_Rec(anonymous$1) + a$1 := DF$RT$nullValue()} + if (a$1 != DF$RT$nullValue()) { + a$0 := f$c$Rec$nullable$TF$T$class_c$g$Rec(a$1) } else { - anonymous$0 := dom$RuntimeType$nullValue()} - if (anonymous$0 != dom$RuntimeType$nullValue()) { - var anonymous$2: Ref - unfold acc(T_class_global$class_Rec(anonymous$0), wildcard) - anonymous$2 := anonymous$0.public$backing_field_v - ret$0 := anonymous$2 + a$0 := DF$RT$nullValue()} + if (a$0 != DF$RT$nullValue()) { + var a$2: Ref + unfold acc(T$class_c$g$Rec(a$0), wildcard) + a$2 := a$0.bf$public$v + r$0 := a$2 } else { - ret$0 := dom$RuntimeType$nullValue()} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$nullValue()} + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/shadowing.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/shadowing.fir.diag.txt index 94192839227398..92644546d99557 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/shadowing.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/shadowing.fir.diag.txt @@ -1,74 +1,71 @@ /shadowing.kt:(23,34): info: Generated Viper text for shadowLocal: -method global$fun_shadowLocal$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$shadowLocal$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$foo: Ref - var local0$x: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$x := dom$RuntimeType$intToRef(0) - if (dom$RuntimeType$intFromRef(local0$x) == 0) { - var local2$x: Ref - local0$foo := local0$x - local2$x := dom$RuntimeType$intToRef(1) - local0$foo := local2$x + var l0$foo: Ref + var l0$x: Ref + r$0 := DF$RT$unitValue() + l0$x := DF$RT$intToRef(0) + if (DF$RT$intFromRef(l0$x) == 0) { + var l2$x: Ref + l0$foo := l0$x + l2$x := DF$RT$intToRef(1) + l0$foo := l2$x } else { - var local3$x: Ref - local0$foo := local0$x - local3$x := dom$RuntimeType$intToRef(2) - local0$foo := local3$x + var l3$x: Ref + l0$foo := l0$x + l3$x := DF$RT$intToRef(2) + l0$foo := l3$x } - local0$foo := local0$x - label label$ret$0 + l0$foo := l0$x + label lbl$ret$0 } /shadowing.kt:(232,243): info: Generated Viper text for shadowParam: -method global$fun_shadowParam$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$shadowParam$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$foo: Ref - var local0$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$foo := local$x - local0$x := dom$RuntimeType$intToRef(0) - local0$foo := local0$x - label label$ret$0 + var l0$foo: Ref + var l0$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$foo := p$x + l0$x := DF$RT$intToRef(0) + l0$foo := l0$x + label lbl$ret$0 } /shadowing.kt:(322,334): info: Generated Viper text for shadowNested: -method global$fun_shadowNested$fun_take$T_Int$return$T_Unit(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$shadowNested$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$foo: Ref - var local0$x: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := dom$RuntimeType$unitValue() - local0$foo := local$x - local0$x := dom$RuntimeType$intToRef(0) - local0$foo := local0$x + var l0$foo: Ref + var l0$x: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := DF$RT$unitValue() + l0$foo := p$x + l0$x := DF$RT$intToRef(0) + l0$foo := l0$x if (true) { - var local2$x: Ref - var anonymous$0: Ref - local0$foo := local0$x - local2$x := dom$RuntimeType$intToRef(1) - local0$foo := local2$x - label label$continue$0 - anonymous$0 := dom$RuntimeType$boolToRef(true) - while (dom$RuntimeType$boolFromRef(anonymous$0)) - invariant dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) + var l2$x: Ref + var a$0: Ref + l0$foo := l0$x + l2$x := DF$RT$intToRef(1) + l0$foo := l2$x + label lbl$continue$0 + a$0 := DF$RT$boolToRef(true) + while (DF$RT$boolFromRef(a$0)) + invariant DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local3$x: Ref - local0$foo := local2$x - local3$x := dom$RuntimeType$intToRef(2) - local0$foo := local3$x - anonymous$0 := dom$RuntimeType$boolToRef(true) + var l3$x: Ref + l0$foo := l2$x + l3$x := DF$RT$intToRef(2) + l0$foo := l3$x + a$0 := DF$RT$boolToRef(true) } - label label$break$0 - local0$foo := local2$x + label lbl$break$0 + l0$foo := l2$x } - local0$foo := local0$x - label label$ret$0 + l0$foo := l0$x + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/types/any.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/types/any.fir.diag.txt index 80b13c0be380c4..6c33f8bf14bf18 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/types/any.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/types/any.fir.diag.txt @@ -1,21 +1,19 @@ /any.kt:(23,40): info: Generated Viper text for anyArgumentReturn: -method global$fun_anyArgumentReturn$fun_take$T_Any$return$T_Any(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$anyType()) +method f$g$anyArgumentReturn$TF$T$Any(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$anyType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$anyType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$anyType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /any.kt:(76,83): info: Generated Viper text for anyCast: -method global$fun_anyCast$fun_take$T_Int$return$T_Any(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$anyType()) +method f$g$anyCast$TF$T$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$anyType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$intType()) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$intType()) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/types/generics.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/types/generics.fir.diag.txt index 99f893353cac74..17b00df7f57c22 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/types/generics.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/types/generics.fir.diag.txt @@ -1,128 +1,121 @@ /generics.kt:(52,65): info: Generated Viper text for genericMethod: -field public$backing_field_t: Ref +field bf$public$t: Ref -method class_Box$fun_genericMethod$fun_take$T_class_global$class_Box$NT_Any$return$NT_Any(this: Ref, - local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) +method f$c$Box$genericMethod$TF$T$class_c$g$Box$Any(this: Ref, p$x: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$anyType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(this), dom$RuntimeType$T_class_global$class_Box()) - inhale acc(T_class_global$class_Box(this), wildcard) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(this), DF$RT$T$class_c$g$Box()) + inhale acc(T$class_c$g$Box(this), wildcard) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$anyType())) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } /generics.kt:(107,116): info: Generated Viper text for createBox: -field public$backing_field_t: Ref +field bf$public$t: Ref -method class_Box$constructor$fun_take$NT_Any$return$T_class_global$class_Box(local$t: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Box()) - ensures acc(T_class_global$class_Box(ret), wildcard) - ensures acc(Unique$T_class_global$class_Box(ret), write) +method con$c$Box$Any(p$t: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Box()) + ensures acc(T$class_c$g$Box(ret), wildcard) + ensures acc(U$T$class_c$g$Box(ret), write) -method global$fun_createBox$fun_take$$return$T_Int() returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$createBox$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var local0$boolBox: Ref - var local0$b: Ref - var anonymous$0: Ref - var local0$intBox: Ref - var anonymous$1: Ref - local0$boolBox := class_Box$constructor$fun_take$NT_Any$return$T_class_global$class_Box(dom$RuntimeType$boolToRef(true)) - inhale acc(local0$boolBox.public$backing_field_t, write) - anonymous$0 := local0$boolBox.public$backing_field_t - exhale acc(local0$boolBox.public$backing_field_t, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - local0$b := anonymous$0 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local0$b), dom$RuntimeType$boolType()) - local0$intBox := class_Box$constructor$fun_take$NT_Any$return$T_class_global$class_Box(dom$RuntimeType$intToRef(2)) - inhale acc(local0$intBox.public$backing_field_t, write) - anonymous$1 := local0$intBox.public$backing_field_t - exhale acc(local0$intBox.public$backing_field_t, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) - goto label$ret$0 - label label$ret$0 + var l0$boolBox: Ref + var l0$b: Ref + var a$0: Ref + var l0$intBox: Ref + var a$1: Ref + l0$boolBox := con$c$Box$Any(DF$RT$boolToRef(true)) + inhale acc(l0$boolBox.bf$public$t, write) + a$0 := l0$boolBox.bf$public$t + exhale acc(l0$boolBox.bf$public$t, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$nullable(DF$RT$anyType())) + l0$b := a$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(l0$b), DF$RT$boolType()) + l0$intBox := con$c$Box$Any(DF$RT$intToRef(2)) + inhale acc(l0$intBox.bf$public$t, write) + a$1 := l0$intBox.bf$public$t + exhale acc(l0$intBox.bf$public$t, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$nullable(DF$RT$anyType())) + r$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) + goto lbl$ret$0 + label lbl$ret$0 } /generics.kt:(227,242): info: Generated Viper text for setGenericField: -field public$backing_field_t: Ref +field bf$public$t: Ref -method class_Box$constructor$fun_take$NT_Any$return$T_class_global$class_Box(local$t: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$T_class_global$class_Box()) - ensures acc(T_class_global$class_Box(ret), wildcard) - ensures acc(Unique$T_class_global$class_Box(ret), write) +method con$c$Box$Any(p$t: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$T$class_c$g$Box()) + ensures acc(T$class_c$g$Box(ret), wildcard) + ensures acc(U$T$class_c$g$Box(ret), write) -method global$fun_setGenericField$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$setGenericField$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$box: Ref - ret$0 := dom$RuntimeType$unitValue() - local0$box := class_Box$constructor$fun_take$NT_Any$return$T_class_global$class_Box(dom$RuntimeType$intToRef(3)) - inhale acc(local0$box.public$backing_field_t, write) - local0$box.public$backing_field_t := dom$RuntimeType$intToRef(5) - exhale acc(local0$box.public$backing_field_t, write) - label label$ret$0 + var l0$box: Ref + r$0 := DF$RT$unitValue() + l0$box := con$c$Box$Any(DF$RT$intToRef(3)) + inhale acc(l0$box.bf$public$t, write) + l0$box.bf$public$t := DF$RT$intToRef(5) + exhale acc(l0$box.bf$public$t, write) + label lbl$ret$0 } /generics.kt:(293,303): info: Generated Viper text for genericFun: -method global$fun_genericFun$fun_take$NT_Any$return$NT_Any(local$t: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) +method f$g$genericFun$TF$Any(p$t: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$anyType())) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$t), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - ret$0 := local$t - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$t), DF$RT$nullable(DF$RT$anyType())) + r$0 := p$t + goto lbl$ret$0 + label lbl$ret$0 } /generics.kt:(322,337): info: Generated Viper text for callGenericFunc: -method global$fun_callGenericFunc$fun_take$$return$T_Unit() - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$unitType()) +method f$g$callGenericFunc$TF$() returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$unitType()) { - var local0$x: Ref - var anonymous$0: Ref - ret$0 := dom$RuntimeType$unitValue() - anonymous$0 := global$fun_genericFun$fun_take$NT_Any$return$NT_Any(dom$RuntimeType$intToRef(3)) - local0$x := anonymous$0 - label label$ret$0 + var l0$x: Ref + var a$0: Ref + r$0 := DF$RT$unitValue() + a$0 := f$g$genericFun$TF$Any(DF$RT$intToRef(3)) + l0$x := a$0 + label lbl$ret$0 } -method global$fun_genericFun$fun_take$NT_Any$return$NT_Any(local$t: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) +method f$g$genericFun$TF$Any(p$t: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$nullable(DF$RT$anyType())) /generics.kt:(375,395): info: Generated Viper text for genericAsIfCondition: -field public$backing_field_t: Ref +field bf$public$t: Ref -method global$fun_genericAsIfCondition$fun_take$T_class_global$class_Box$return$T_Int(local$box: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$genericAsIfCondition$TF$T$class_c$g$Box(p$box: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - var anonymous$0: Ref - var anonymous$1: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$box), dom$RuntimeType$T_class_global$class_Box()) - inhale acc(T_class_global$class_Box(local$box), wildcard) - inhale acc(local$box.public$backing_field_t, write) - anonymous$1 := local$box.public$backing_field_t - exhale acc(local$box.public$backing_field_t, write) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), dom$RuntimeType$nullable(dom$RuntimeType$anyType())) - anonymous$0 := anonymous$1 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$0), dom$RuntimeType$boolType()) - if (dom$RuntimeType$boolFromRef(anonymous$0)) { - ret$0 := dom$RuntimeType$intToRef(20) + var a$0: Ref + var a$1: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$box), DF$RT$T$class_c$g$Box()) + inhale acc(T$class_c$g$Box(p$box), wildcard) + inhale acc(p$box.bf$public$t, write) + a$1 := p$box.bf$public$t + exhale acc(p$box.bf$public$t, write) + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$nullable(DF$RT$anyType())) + a$0 := a$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$0), DF$RT$boolType()) + if (DF$RT$boolFromRef(a$0)) { + r$0 := DF$RT$intToRef(20) } else { - ret$0 := dom$RuntimeType$intToRef(10)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(10)} + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/types/nullable.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/types/nullable.fir.diag.txt index fd0e1bb09ccdc6..cbc8d61767c13a 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/types/nullable.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/types/nullable.fir.diag.txt @@ -1,70 +1,63 @@ /nullable.kt:(80,96): info: Generated Viper text for useNullableTwice: -method global$fun_useNullableTwice$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$useNullableTwice$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - var local0$a: Ref - var local0$b: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - local0$a := local$x - local0$b := local$x - ret$0 := local0$a - goto label$ret$0 - label label$ret$0 + var l0$a: Ref + var l0$b: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + l0$a := p$x + l0$b := p$x + r$0 := l0$a + goto lbl$ret$0 + label lbl$ret$0 } /nullable.kt:(162,183): info: Generated Viper text for passNullableParameter: -method global$fun_passNullableParameter$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$passNullableParameter$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$nullable(DF$RT$intType())) { - var anonymous$0: Ref - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - anonymous$0 := global$fun_useNullableTwice$fun_take$NT_Int$return$NT_Int(local$x) - ret$0 := local$x - goto label$ret$0 - label label$ret$0 + var a$0: Ref + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + a$0 := f$g$useNullableTwice$TF$Int(p$x) + r$0 := p$x + goto lbl$ret$0 + label lbl$ret$0 } -method global$fun_useNullableTwice$fun_take$NT_Int$return$NT_Int(local$x: Ref) - returns (ret: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret), dom$RuntimeType$nullable(dom$RuntimeType$intType())) +method f$g$useNullableTwice$TF$Int(p$x: Ref) returns (ret: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(ret), DF$RT$nullable(DF$RT$intType())) /nullable.kt:(245,271): info: Generated Viper text for nullableNullableComparison: -method global$fun_nullableNullableComparison$fun_take$NT_Int$NT_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$nullableNullableComparison$TF$Int$Int(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$boolToRef(local$x == local$y) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$boolToRef(p$x == p$y) + goto lbl$ret$0 + label lbl$ret$0 } /nullable.kt:(326,355): info: Generated Viper text for nullableNonNullableComparison: -method global$fun_nullableNonNullableComparison$fun_take$NT_Int$NT_Int$return$T_Boolean(local$x: Ref, - local$y: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$nullableNonNullableComparison$TF$Int$Int(p$x: Ref, p$y: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$y), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := special$notBool(dom$RuntimeType$boolToRef(local$x == - dom$RuntimeType$intToRef(3))) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + inhale DF$RT$isSubtype(DF$RT$typeOf(p$y), DF$RT$nullable(DF$RT$intType())) + r$0 := sp$notBool(DF$RT$boolToRef(p$x == DF$RT$intToRef(3))) + goto lbl$ret$0 + label lbl$ret$0 } /nullable.kt:(410,424): info: Generated Viper text for nullComparison: -method global$fun_nullComparison$fun_take$NT_Int$return$T_Boolean(local$x: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$nullComparison$TF$Int(p$x: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$x), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - ret$0 := dom$RuntimeType$boolToRef(local$x == dom$RuntimeType$nullValue()) - goto label$ret$0 - label label$ret$0 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$x), DF$RT$nullable(DF$RT$intType())) + r$0 := DF$RT$boolToRef(p$x == DF$RT$nullValue()) + goto lbl$ret$0 + label lbl$ret$0 } diff --git a/plugins/formal-verification/testData/diagnostics/no_contracts/types/smartcast.fir.diag.txt b/plugins/formal-verification/testData/diagnostics/no_contracts/types/smartcast.fir.diag.txt index 52f6e53f0ec81e..cecac5ff605fd3 100644 --- a/plugins/formal-verification/testData/diagnostics/no_contracts/types/smartcast.fir.diag.txt +++ b/plugins/formal-verification/testData/diagnostics/no_contracts/types/smartcast.fir.diag.txt @@ -1,43 +1,40 @@ /smartcast.kt:(23,38): info: Generated Viper text for smartcastReturn: -method global$fun_smartcastReturn$fun_take$NT_Int$return$T_Int(local$n: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$intType()) +method f$g$smartcastReturn$TF$Int(p$n: Ref) returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$intType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$n), dom$RuntimeType$nullable(dom$RuntimeType$intType())) - if (!(local$n == dom$RuntimeType$nullValue())) { - ret$0 := local$n + inhale DF$RT$isSubtype(DF$RT$typeOf(p$n), DF$RT$nullable(DF$RT$intType())) + if (!(p$n == DF$RT$nullValue())) { + r$0 := p$n } else { - ret$0 := dom$RuntimeType$intToRef(0)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$intToRef(0)} + goto lbl$ret$0 + label lbl$ret$0 } /smartcast.kt:(88,106): info: Generated Viper text for isNullOrEmptyWrong: -method global$fun_isNullOrEmptyWrong$fun_take$NT_class_pkg$kotlin$global$class_CharSequence$return$T_Boolean(local$seq: Ref) - returns (ret$0: Ref) - ensures dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(ret$0), dom$RuntimeType$boolType()) +method f$g$isNullOrEmptyWrong$TF$class_c$pkg_kotlin$g$CharSequence(p$seq: Ref) + returns (r$0: Ref) + ensures DF$RT$isSubtype(DF$RT$typeOf(r$0), DF$RT$boolType()) { - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(local$seq), dom$RuntimeType$nullable(dom$RuntimeType$T_class_pkg$kotlin$global$class_CharSequence())) - inhale local$seq != dom$RuntimeType$nullValue() ==> - acc(T_class_pkg$kotlin$global$class_CharSequence(local$seq), wildcard) - if (local$seq == dom$RuntimeType$nullValue()) { - var anonymous$0: Ref - if (local$seq != dom$RuntimeType$nullValue()) { - var anonymous$1: Ref - var anonymous$2: Ref - anonymous$2 := public$property_getter_length(local$seq) - anonymous$1 := anonymous$2 - inhale dom$RuntimeType$isSubtype(dom$RuntimeType$typeOf(anonymous$1), - dom$RuntimeType$intType()) - anonymous$0 := anonymous$1 + inhale DF$RT$isSubtype(DF$RT$typeOf(p$seq), DF$RT$nullable(DF$RT$T$class_c$pkg_kotlin$g$CharSequence())) + inhale p$seq != DF$RT$nullValue() ==> + acc(T$class_c$pkg_kotlin$g$CharSequence(p$seq), wildcard) + if (p$seq == DF$RT$nullValue()) { + var a$0: Ref + if (p$seq != DF$RT$nullValue()) { + var a$1: Ref + var a$2: Ref + a$2 := pg$public$length(p$seq) + a$1 := a$2 + inhale DF$RT$isSubtype(DF$RT$typeOf(a$1), DF$RT$intType()) + a$0 := a$1 } else { - anonymous$0 := dom$RuntimeType$nullValue()} - ret$0 := dom$RuntimeType$boolToRef(anonymous$0 == - dom$RuntimeType$intToRef(0)) + a$0 := DF$RT$nullValue()} + r$0 := DF$RT$boolToRef(a$0 == DF$RT$intToRef(0)) } else { - ret$0 := dom$RuntimeType$boolToRef(false)} - goto label$ret$0 - label label$ret$0 + r$0 := DF$RT$boolToRef(false)} + goto lbl$ret$0 + label lbl$ret$0 } -method public$property_getter_length(this: Ref) returns (ret: Ref) +method pg$public$length(this: Ref) returns (ret: Ref)