Skip to content

Commit

Permalink
Remove TypeInference::unifyGeneralized()
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Nov 1, 2023
1 parent c078827 commit 0162b8e
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 106 deletions.
13 changes: 2 additions & 11 deletions libsolidity/experimental/analysis/TypeInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,18 +1071,9 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(Analysi
}
}

void TypeInference::unifyGeneralized(Type _type, Type _scheme, std::vector<Type> _monomorphicTypes, langutil::SourceLocation _location)
experimental::Type TypeInference::polymorphicInstance(Type const& _scheme)
{
solUnimplementedAssert(_monomorphicTypes.empty(), "unsupported");
Type fresh = m_env->fresh(_scheme);
unify(_type, fresh, _location);
}

experimental::Type TypeInference::polymorphicInstance(Type _scheme, langutil::SourceLocation _location)
{
Type 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)
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/experimental/analysis/TypeInference.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type> _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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,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)
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ function run(a: T, b: U(T), c: U(U(T))) {
// Info 4164: (39-49): Inferred type: tfun('u:type, U('u:type))
// Info 4164: (45-48): Inferred type: 't:type
// Info 4164: (46-47): Inferred type: 't:type
// Info 4164: (51-82): Inferred type: ('x:type, 'y:type, U('bb:type)) -> ()
// Info 4164: (61-79): Inferred type: ('x:type, 'y:type, U('bb:type))
// Info 4164: (51-82): Inferred type: ('x:type, 'y:type, U('ba:type)) -> ()
// Info 4164: (61-79): Inferred type: ('x:type, 'y:type, U('ba:type))
// Info 4164: (62-63): Inferred type: 'x:type
// Info 4164: (65-69): Inferred type: 'y:type
// Info 4164: (68-69): Inferred type: 'y:type
// Info 4164: (71-78): Inferred type: U('bb:type)
// Info 4164: (74-78): Inferred type: U('bb:type)
// Info 4164: (74-75): Inferred type: tfun('bb:type, U('bb:type))
// Info 4164: (76-77): Inferred type: 'bb:type
// Info 4164: (71-78): Inferred type: U('ba:type)
// Info 4164: (74-78): Inferred type: U('ba:type)
// Info 4164: (74-75): Inferred type: tfun('ba:type, U('ba:type))
// Info 4164: (76-77): Inferred type: 'ba:type
// Info 4164: (84-159): Inferred type: (T, U(T), U(U(T))) -> ()
// Info 4164: (96-123): Inferred type: (T, U(T), U(U(T)))
// Info 4164: (97-101): Inferred type: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ function run() {
// Info 4164: (88-92): Inferred type: 'bg:(type, D)
// Info 4164: (100-170): Inferred type: () -> ()
// Info 4164: (112-114): Inferred type: ()
// Info 4164: (125-141): Inferred type: T(U, 'bo:type, 'bq:(type, C))
// Info 4164: (128-141): Inferred type: T(U, 'bo:type, 'bq:(type, C))
// Info 4164: (128-129): Inferred type: tfun((U, 'bo:type, 'bq:(type, C)), T(U, 'bo:type, 'bq:(type, C)))
// Info 4164: (125-141): Inferred type: T(U, 'bm:type, 'bo:(type, C))
// Info 4164: (128-141): Inferred type: T(U, 'bm:type, 'bo:(type, C))
// Info 4164: (128-129): Inferred type: tfun((U, 'bm:type, 'bo:(type, C)), T(U, 'bm:type, 'bo:(type, C)))
// Info 4164: (130-131): Inferred type: U
// Info 4164: (133-134): Inferred type: 'bo:type
// Info 4164: (136-140): Inferred type: 'bq:(type, C)
// Info 4164: (136-137): Inferred type: 'bq:(type, C)
// Info 4164: (139-140): Inferred type: 'bq:(type, C)
// Info 4164: (151-167): Inferred type: T(V, 'bx:type, 'bz:(type, D))
// Info 4164: (154-167): Inferred type: T(V, 'bx:type, 'bz:(type, D))
// Info 4164: (154-155): Inferred type: tfun((V, 'bx:type, 'bz:(type, D)), T(V, 'bx:type, 'bz:(type, D)))
// Info 4164: (133-134): Inferred type: 'bm:type
// Info 4164: (136-140): Inferred type: 'bo:(type, C)
// Info 4164: (136-137): Inferred type: 'bo:(type, C)
// Info 4164: (139-140): Inferred type: 'bo:(type, C)
// Info 4164: (151-167): Inferred type: T(V, 'bt:type, 'bv:(type, D))
// Info 4164: (154-167): Inferred type: T(V, 'bt:type, 'bv:(type, D))
// Info 4164: (154-155): Inferred type: tfun((V, 'bt:type, 'bv:(type, D)), T(V, 'bt:type, 'bv:(type, D)))
// Info 4164: (156-157): Inferred type: V
// Info 4164: (159-160): Inferred type: 'bx:type
// Info 4164: (162-166): Inferred type: 'bz:(type, D)
// Info 4164: (162-163): Inferred type: 'bz:(type, D)
// Info 4164: (165-166): Inferred type: 'bz:(type, D)
// Info 4164: (159-160): Inferred type: 'bt:type
// Info 4164: (162-166): Inferred type: 'bv:(type, D)
// Info 4164: (162-163): Inferred type: 'bv:(type, D)
// Info 4164: (165-166): Inferred type: 'bv:(type, D)
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function fun() {
// Info 4164: (134-141): Inferred type: T(uint)
// Info 4164: (134-135): Inferred type: tfun(uint, T(uint))
// Info 4164: (136-140): Inferred type: uint
// Info 4164: (147-155): Inferred type: T('bp:type)
// Info 4164: (147-152): Inferred type: U(uint) -> T('bp:type)
// Info 4164: (147-148): Inferred type: U('bm:type)
// Info 4164: (147-155): Inferred type: T('bi:type)
// Info 4164: (147-152): Inferred type: U(uint) -> T('bi:type)
// Info 4164: (147-148): Inferred type: U('bg:type)
// Info 4164: (153-154): Inferred type: U(uint)
// Info 4164: (161-169): Inferred type: U('bv:type)
// Info 4164: (161-166): Inferred type: T(uint) -> U('bv:type)
// Info 4164: (161-162): Inferred type: U('bs:type)
// Info 4164: (161-169): Inferred type: U('bm:type)
// Info 4164: (161-166): Inferred type: T(uint) -> U('bm:type)
// Info 4164: (161-162): Inferred type: U('bk:type)
// Info 4164: (167-168): Inferred type: T(uint)
// Info 4164: (180-192): Inferred type: U(string)
// Info 4164: (183-192): Inferred type: U(string)
Expand All @@ -59,11 +59,11 @@ function fun() {
// Info 4164: (205-214): Inferred type: T(string)
// Info 4164: (205-206): Inferred type: tfun(string, T(string))
// Info 4164: (207-213): Inferred type: string
// Info 4164: (220-228): Inferred type: T('cj:type)
// Info 4164: (220-225): Inferred type: U(string) -> T('cj:type)
// Info 4164: (220-221): Inferred type: U('cg:type)
// Info 4164: (220-228): Inferred type: T('bu:type)
// Info 4164: (220-225): Inferred type: U(string) -> T('bu:type)
// Info 4164: (220-221): Inferred type: U('bs:type)
// Info 4164: (226-227): Inferred type: U(string)
// Info 4164: (234-242): Inferred type: U('cp:type)
// Info 4164: (234-239): Inferred type: T(string) -> U('cp:type)
// Info 4164: (234-235): Inferred type: U('cm:type)
// Info 4164: (234-242): Inferred type: U('by:type)
// Info 4164: (234-239): Inferred type: T(string) -> U('by:type)
// Info 4164: (234-235): Inferred type: U('bw:type)
// Info 4164: (240-241): Inferred type: T(string)
Original file line number Diff line number Diff line change
Expand Up @@ -57,79 +57,79 @@ function fun(a: T(int: P3), b: T(str: P4)) {
// Info 4164: (74-83): Inferred type: int
// Info 4164: (84-93): Inferred type: str
// Info 4164: (95-156): Inferred type: C
// Info 4164: (101-105): Inferred type: 'bf:(type, C)
// Info 4164: (115-154): Inferred type: ('bf:(type, C), 'bf:(type, C)) -> 'bf:(type, C)
// Info 4164: (127-145): Inferred type: ('bf:(type, C), 'bf:(type, C))
// Info 4164: (128-135): Inferred type: 'bf:(type, C)
// Info 4164: (131-135): Inferred type: 'bf:(type, C)
// Info 4164: (137-144): Inferred type: 'bf:(type, C)
// Info 4164: (140-144): Inferred type: 'bf:(type, C)
// Info 4164: (149-153): Inferred type: 'bf:(type, C)
// Info 4164: (101-105): Inferred type: 'bd:(type, C)
// Info 4164: (115-154): Inferred type: ('bd:(type, C), 'bd:(type, C)) -> 'bd:(type, C)
// Info 4164: (127-145): Inferred type: ('bd:(type, C), 'bd:(type, C))
// Info 4164: (128-135): Inferred type: 'bd:(type, C)
// Info 4164: (131-135): Inferred type: 'bd:(type, C)
// Info 4164: (137-144): Inferred type: 'bd:(type, C)
// Info 4164: (140-144): Inferred type: 'bd:(type, C)
// Info 4164: (149-153): Inferred type: 'bd:(type, C)
// Info 4164: (158-175): Inferred type: P1
// Info 4164: (164-168): Inferred type: 'bi:(type, P1)
// Info 4164: (164-168): Inferred type: 'bg:(type, P1)
// Info 4164: (176-193): Inferred type: P2
// Info 4164: (182-186): Inferred type: 'bl:(type, P2)
// Info 4164: (182-186): Inferred type: 'bj:(type, P2)
// Info 4164: (194-211): Inferred type: P3
// Info 4164: (200-204): Inferred type: 'cb:(type, P3)
// Info 4164: (200-204): Inferred type: 'bw:(type, P3)
// Info 4164: (212-229): Inferred type: P4
// Info 4164: (218-222): Inferred type: 'cd:(type, P4)
// Info 4164: (218-222): Inferred type: 'by:(type, P4)
// Info 4164: (231-255): Inferred type: void
// Info 4164: (256-280): Inferred type: void
// Info 4164: (281-305): Inferred type: void
// Info 4164: (307-331): Inferred type: void
// Info 4164: (332-356): Inferred type: void
// Info 4164: (357-381): Inferred type: void
// Info 4164: (383-458): Inferred type: void
// Info 4164: (398-405): Inferred type: 'cf:(type, P1)
// Info 4164: (399-404): Inferred type: 'cf:(type, P1)
// Info 4164: (402-404): Inferred type: 'cf:(type, P1)
// Info 4164: (415-456): Inferred type: (T('cf:(type, P1)), T('cf:(type, P1))) -> T('cf:(type, P1))
// Info 4164: (427-445): Inferred type: (T('cf:(type, P1)), T('cf:(type, P1)))
// Info 4164: (428-435): Inferred type: T('cf:(type, P1))
// Info 4164: (431-435): Inferred type: T('cf:(type, P1))
// Info 4164: (431-432): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
// Info 4164: (433-434): Inferred type: 'cf:(type, P1)
// Info 4164: (437-444): Inferred type: T('cf:(type, P1))
// Info 4164: (440-444): Inferred type: T('cf:(type, P1))
// Info 4164: (440-441): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
// Info 4164: (442-443): Inferred type: 'cf:(type, P1)
// Info 4164: (449-453): Inferred type: T('cf:(type, P1))
// Info 4164: (449-450): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
// Info 4164: (451-452): Inferred type: 'cf:(type, P1)
// Info 4164: (398-405): Inferred type: 'ca:(type, P1)
// Info 4164: (399-404): Inferred type: 'ca:(type, P1)
// Info 4164: (402-404): Inferred type: 'ca:(type, P1)
// Info 4164: (415-456): Inferred type: (T('ca:(type, P1)), T('ca:(type, P1))) -> T('ca:(type, P1))
// Info 4164: (427-445): Inferred type: (T('ca:(type, P1)), T('ca:(type, P1)))
// Info 4164: (428-435): Inferred type: T('ca:(type, P1))
// Info 4164: (431-435): Inferred type: T('ca:(type, P1))
// Info 4164: (431-432): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
// Info 4164: (433-434): Inferred type: 'ca:(type, P1)
// Info 4164: (437-444): Inferred type: T('ca:(type, P1))
// Info 4164: (440-444): Inferred type: T('ca:(type, P1))
// Info 4164: (440-441): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
// Info 4164: (442-443): Inferred type: 'ca:(type, P1)
// Info 4164: (449-453): Inferred type: T('ca:(type, P1))
// Info 4164: (449-450): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
// Info 4164: (451-452): Inferred type: 'ca:(type, P1)
// Info 4164: (460-535): Inferred type: void
// Info 4164: (475-482): Inferred type: 'cs:(type, P2)
// Info 4164: (476-481): Inferred type: 'cs:(type, P2)
// Info 4164: (479-481): Inferred type: 'cs:(type, P2)
// Info 4164: (493-533): Inferred type: (T('cs:(type, P2)), T('cs:(type, P2))) -> bool
// Info 4164: (504-522): Inferred type: (T('cs:(type, P2)), T('cs:(type, P2)))
// Info 4164: (505-512): Inferred type: T('cs:(type, P2))
// Info 4164: (508-512): Inferred type: T('cs:(type, P2))
// Info 4164: (508-509): Inferred type: tfun('cs:(type, P2), T('cs:(type, P2)))
// Info 4164: (510-511): Inferred type: 'cs:(type, P2)
// Info 4164: (514-521): Inferred type: T('cs:(type, P2))
// Info 4164: (517-521): Inferred type: T('cs:(type, P2))
// Info 4164: (517-518): Inferred type: tfun('cs:(type, P2), T('cs:(type, P2)))
// Info 4164: (519-520): Inferred type: 'cs:(type, P2)
// Info 4164: (475-482): Inferred type: 'ck:(type, P2)
// Info 4164: (476-481): Inferred type: 'ck:(type, P2)
// Info 4164: (479-481): Inferred type: 'ck:(type, P2)
// Info 4164: (493-533): Inferred type: (T('ck:(type, P2)), T('ck:(type, P2))) -> bool
// Info 4164: (504-522): Inferred type: (T('ck:(type, P2)), T('ck:(type, P2)))
// Info 4164: (505-512): Inferred type: T('ck:(type, P2))
// Info 4164: (508-512): Inferred type: T('ck:(type, P2))
// Info 4164: (508-509): Inferred type: tfun('ck:(type, P2), T('ck:(type, P2)))
// Info 4164: (510-511): Inferred type: 'ck:(type, P2)
// Info 4164: (514-521): Inferred type: T('ck:(type, P2))
// Info 4164: (517-521): Inferred type: T('ck:(type, P2))
// Info 4164: (517-518): Inferred type: tfun('ck:(type, P2), T('ck:(type, P2)))
// Info 4164: (519-520): Inferred type: 'ck:(type, P2)
// Info 4164: (526-530): Inferred type: bool
// Info 4164: (537-618): Inferred type: void
// Info 4164: (552-565): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (553-564): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (556-564): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (557-559): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (561-563): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (575-616): Inferred type: (T('bo:(type, P1, P2)), T('bo:(type, P1, P2))) -> T('bo:(type, P1, P2))
// Info 4164: (587-605): Inferred type: (T('bo:(type, P1, P2)), T('bo:(type, P1, P2)))
// Info 4164: (588-595): Inferred type: T('bo:(type, P1, P2))
// Info 4164: (591-595): Inferred type: T('bo:(type, P1, P2))
// Info 4164: (591-592): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
// Info 4164: (593-594): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (597-604): Inferred type: T('bo:(type, P1, P2))
// Info 4164: (600-604): Inferred type: T('bo:(type, P1, P2))
// Info 4164: (600-601): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
// Info 4164: (602-603): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (609-613): Inferred type: T('bo:(type, P1, P2))
// Info 4164: (609-610): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
// Info 4164: (611-612): Inferred type: 'bo:(type, P1, P2)
// Info 4164: (552-565): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (553-564): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (556-564): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (557-559): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (561-563): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (575-616): Inferred type: (T('bm:(type, P1, P2)), T('bm:(type, P1, P2))) -> T('bm:(type, P1, P2))
// Info 4164: (587-605): Inferred type: (T('bm:(type, P1, P2)), T('bm:(type, P1, P2)))
// Info 4164: (588-595): Inferred type: T('bm:(type, P1, P2))
// Info 4164: (591-595): Inferred type: T('bm:(type, P1, P2))
// Info 4164: (591-592): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
// Info 4164: (593-594): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (597-604): Inferred type: T('bm:(type, P1, P2))
// Info 4164: (600-604): Inferred type: T('bm:(type, P1, P2))
// Info 4164: (600-601): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
// Info 4164: (602-603): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (609-613): Inferred type: T('bm:(type, P1, P2))
// Info 4164: (609-610): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
// Info 4164: (611-612): Inferred type: 'bm:(type, P1, P2)
// Info 4164: (620-748): Inferred type: (T(int), T(str)) -> ()
// Info 4164: (632-662): Inferred type: (T(int), T(str))
// Info 4164: (633-646): Inferred type: T(int)
Expand Down

0 comments on commit 0162b8e

Please sign in to comment.