From 00554b4c0051a6083c764a54f2e44da090821f93 Mon Sep 17 00:00:00 2001 From: Komi Golov Date: Sat, 13 Jul 2024 14:16:38 +0200 Subject: [PATCH] Remove unused function TypeEmbeddings. (#226) These were used for CallsInPlace; I thought they were still necessary but I hadn't looked correctly. --- .../formver/embeddings/TypeEmbedding.kt | 19 +++++-------------- .../embeddings/callables/SpecialMethods.kt | 17 +---------------- .../embeddings/expression/ControlFlow.kt | 19 ++++++------------- .../control_flow/loop_invariants.fir.diag.txt | 4 +--- .../no_contracts/full_viper_dump.fir.diag.txt | 3 --- .../no_contracts/function_object.fir.diag.txt | 4 ---- .../inlining/captured.fir.diag.txt | 1 - 7 files changed, 13 insertions(+), 54 deletions(-) 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 026185d31313d..aba29144c08cd 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,7 +8,10 @@ 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.* +import org.jetbrains.kotlin.formver.names.ClassScope +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 @@ -164,20 +167,8 @@ data class NullableTypeEmbedding(val elementType: TypeEmbedding) : TypeEmbedding override val isNullable = true } -abstract class UnspecifiedFunctionTypeEmbedding : TypeEmbedding { +data class FunctionTypeEmbedding(val signature: CallableSignatureData) : TypeEmbedding { override val runtimeType = RuntimeTypeDomain.functionType() -} - -/** - * Some of our older code requires specific type annotations for built-ins with function types. - * However, we don't actually want to distinguish these builtins by type, so we introduce this - * type embedding as a workaround. - */ -data object LegacyUnspecifiedFunctionTypeEmbedding : UnspecifiedFunctionTypeEmbedding() { - override val name: MangledName = SpecialName("legacy_function_object_type") -} - -data class FunctionTypeEmbedding(val signature: CallableSignatureData) : UnspecifiedFunctionTypeEmbedding() { override val name = object : MangledName { override val mangled: String = "fun_take\$${signature.formalArgTypes.joinToString("$") { it.name.mangled }}\$return\$${signature.returnType.name.mangled}" diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/callables/SpecialMethods.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/callables/SpecialMethods.kt index 3025fd0b036e1..057a5e35bfd3a 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/callables/SpecialMethods.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/callables/SpecialMethods.kt @@ -5,23 +5,8 @@ package org.jetbrains.kotlin.formver.embeddings.callables -import org.jetbrains.kotlin.formver.embeddings.LegacyUnspecifiedFunctionTypeEmbedding -import org.jetbrains.kotlin.formver.embeddings.expression.AnonymousVariableEmbedding -import org.jetbrains.kotlin.formver.linearization.pureToViper -import org.jetbrains.kotlin.formver.names.SpecialName import org.jetbrains.kotlin.formver.viper.ast.BuiltInMethod -import org.jetbrains.kotlin.formver.viper.ast.Declaration -import org.jetbrains.kotlin.formver.viper.ast.Exp - -object InvokeFunctionObjectMethod : BuiltInMethod(SpecialName("invoke_function_object")) { - private val thisArg = AnonymousVariableEmbedding(0, LegacyUnspecifiedFunctionTypeEmbedding) - - override val formalArgs: List = listOf(thisArg.toLocalVarDecl()) - override val formalReturns: List = listOf() - override val pres: List = thisArg.accessInvariants().pureToViper(toBuiltin = true) - override val posts: List = thisArg.allAccessInvariants().pureToViper(toBuiltin = true) -} object SpecialMethods { - val all = listOf(InvokeFunctionObjectMethod) + val all: List = listOf() } \ No newline at end of file diff --git a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ControlFlow.kt b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ControlFlow.kt index 90fe0af19b5c1..500f296f8c9e1 100644 --- a/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ControlFlow.kt +++ b/plugins/formal-verification/formver.core/src/org/jetbrains/kotlin/formver/embeddings/expression/ControlFlow.kt @@ -8,14 +8,16 @@ package org.jetbrains.kotlin.formver.embeddings.expression import org.jetbrains.kotlin.formver.asPosition import org.jetbrains.kotlin.formver.embeddings.* import org.jetbrains.kotlin.formver.embeddings.callables.FullNamedFunctionSignature -import org.jetbrains.kotlin.formver.embeddings.callables.InvokeFunctionObjectMethod import org.jetbrains.kotlin.formver.embeddings.callables.NamedFunctionSignature import org.jetbrains.kotlin.formver.embeddings.callables.toMethodCall import org.jetbrains.kotlin.formver.embeddings.expression.debug.* import org.jetbrains.kotlin.formver.linearization.LinearizationContext import org.jetbrains.kotlin.formver.linearization.addLabel import org.jetbrains.kotlin.formver.linearization.pureToViper -import org.jetbrains.kotlin.formver.viper.ast.* +import org.jetbrains.kotlin.formver.viper.ast.Exp +import org.jetbrains.kotlin.formver.viper.ast.Label +import org.jetbrains.kotlin.formver.viper.ast.PermExp +import org.jetbrains.kotlin.formver.viper.ast.Stmt // TODO: make a nice BlockBuilder interface. data class Block(val exps: List) : OptionalResultExpEmbedding { @@ -207,17 +209,8 @@ data class InvokeFunctionObject(val receiver: ExpEmbedding, val args: List