From 781a73b12391f084fdbffef1f6e7b112d155d3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 27 Oct 2023 17:00:37 +0200 Subject: [PATCH] Remove TypeInference::unifyGeneralized() --- libsolidity/experimental/analysis/TypeInference.cpp | 12 ++---------- libsolidity/experimental/analysis/TypeInference.h | 4 ++-- .../experimental/builtin/builtin_type_definition.sol | 4 ++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/libsolidity/experimental/analysis/TypeInference.cpp b/libsolidity/experimental/analysis/TypeInference.cpp index 519087ac4606..67c011476c8b 100644 --- a/libsolidity/experimental/analysis/TypeInference.cpp +++ b/libsolidity/experimental/analysis/TypeInference.cpp @@ -1079,17 +1079,9 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(Analysi } } -void TypeInference::unifyGeneralized(Type _type, Type _scheme, std::vector _monomorphicTypes, langutil::SourceLocation _location) +experimental::Type TypeInference::polymorphicInstance(Type const& _scheme) { - solUnimplementedAssert(_monomorphicTypes.empty(), "unsupported"); - unify(_type, m_env->fresh(_scheme), _location); -} - -experimental::Type TypeInference::polymorphicInstance(Type _scheme, langutil::SourceLocation _location) -{ - TypeVariable result = m_typeSystem.freshTypeVariable({}); - unifyGeneralized(result, _scheme, {}, _location); - return result; + return m_env->fresh(_scheme); } void TypeInference::unify(Type _a, Type _b, langutil::SourceLocation _location) diff --git a/libsolidity/experimental/analysis/TypeInference.h b/libsolidity/experimental/analysis/TypeInference.h index eb1b03f6974d..2f156eae02bd 100644 --- a/libsolidity/experimental/analysis/TypeInference.h +++ b/libsolidity/experimental/analysis/TypeInference.h @@ -110,8 +110,8 @@ class TypeInference: public ASTConstVisitor GlobalAnnotation& annotation(); void unify(Type _a, Type _b, langutil::SourceLocation _location = {}); - void unifyGeneralized(Type _type, Type _scheme, std::vector _monomorphicTypes, langutil::SourceLocation _location = {}); - Type polymorphicInstance(Type _scheme, langutil::SourceLocation _location = {}); + /// Creates a polymorphic instance of a global type scheme + Type polymorphicInstance(Type const& _scheme); Type memberType(Type _type, std::string _memberName, langutil::SourceLocation _location = {}); enum class ExpressionContext { Term, Type, Sort }; Type handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration); diff --git a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol index 753cf42faf8f..872e67d483f5 100644 --- a/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol +++ b/test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol @@ -83,9 +83,9 @@ contract C { // Info 4164: (525-529): Inferred type: word // Info 4164: (540-553): Inferred type: bool // Info 4164: (540-550): Inferred type: (bool, word) -> bool -// Info 4164: (540-544): Inferred type: ('cb:type, 'cc:type) +// Info 4164: (540-544): Inferred type: ('bl:type, 'bm:type) // Info 4164: (551-552): Inferred type: (bool, word) // Info 4164: (563-577): Inferred type: word // Info 4164: (563-574): Inferred type: (bool, word) -> word -// Info 4164: (563-567): Inferred type: ('ci:type, 'cj:type) +// Info 4164: (563-567): Inferred type: ('bq:type, 'br:type) // Info 4164: (575-576): Inferred type: (bool, word)