Skip to content

Commit c392de0

Browse files
committed
Remove TypeInference::unifyGeneralized()
1 parent 621c06a commit c392de0

File tree

7 files changed

+97
-106
lines changed

7 files changed

+97
-106
lines changed

libsolidity/experimental/analysis/TypeInference.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -1071,18 +1071,9 @@ TypeRegistration::TypeClassInstantiations const& typeClassInstantiations(Analysi
10711071
}
10721072
}
10731073

1074-
void TypeInference::unifyGeneralized(Type _type, Type _scheme, std::vector<Type> _monomorphicTypes, langutil::SourceLocation _location)
1074+
experimental::Type TypeInference::polymorphicInstance(Type const& _scheme)
10751075
{
1076-
solUnimplementedAssert(_monomorphicTypes.empty(), "unsupported");
1077-
Type fresh = m_env->fresh(_scheme);
1078-
unify(_type, fresh, _location);
1079-
}
1080-
1081-
experimental::Type TypeInference::polymorphicInstance(Type _scheme, langutil::SourceLocation _location)
1082-
{
1083-
Type result = m_typeSystem.freshTypeVariable({});
1084-
unifyGeneralized(result, _scheme, {}, _location);
1085-
return result;
1076+
return m_env->fresh(_scheme);
10861077
}
10871078

10881079
void TypeInference::unify(Type _a, Type _b, langutil::SourceLocation _location)

libsolidity/experimental/analysis/TypeInference.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class TypeInference: public ASTConstVisitor
110110
GlobalAnnotation& annotation();
111111

112112
void unify(Type _a, Type _b, langutil::SourceLocation _location = {});
113-
void unifyGeneralized(Type _type, Type _scheme, std::vector<Type> _monomorphicTypes, langutil::SourceLocation _location = {});
114-
Type polymorphicInstance(Type _scheme, langutil::SourceLocation _location = {});
113+
/// Creates a polymorphic instance of a global type scheme
114+
Type polymorphicInstance(Type const& _scheme);
115115
Type memberType(Type _type, std::string _memberName, langutil::SourceLocation _location = {});
116116
enum class ExpressionContext { Term, Type, Sort };
117117
Type handleIdentifierByReferencedDeclaration(langutil::SourceLocation _location, Declaration const& _declaration);

test/libsolidity/syntaxTests/experimental/builtin/builtin_type_definition.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ contract C {
8484
// Info 4164: (525-529): Inferred type: word
8585
// Info 4164: (540-553): Inferred type: bool
8686
// Info 4164: (540-550): Inferred type: (bool, word) -> bool
87-
// Info 4164: (540-544): Inferred type: ('cb:type, 'cc:type)
87+
// Info 4164: (540-544): Inferred type: ('bl:type, 'bm:type)
8888
// Info 4164: (551-552): Inferred type: (bool, word)
8989
// Info 4164: (563-577): Inferred type: word
9090
// Info 4164: (563-574): Inferred type: (bool, word) -> word
91-
// Info 4164: (563-567): Inferred type: ('ci:type, 'cj:type)
91+
// Info 4164: (563-567): Inferred type: ('bq:type, 'br:type)
9292
// Info 4164: (575-576): Inferred type: (bool, word)

test/libsolidity/syntaxTests/experimental/inference/polymorphic_function_call.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ function run(a: T, b: U(T), c: U(U(T))) {
1818
// Info 4164: (39-49): Inferred type: tfun('u:type, U('u:type))
1919
// Info 4164: (45-48): Inferred type: 't:type
2020
// Info 4164: (46-47): Inferred type: 't:type
21-
// Info 4164: (51-82): Inferred type: ('x:type, 'y:type, U('bb:type)) -> ()
22-
// Info 4164: (61-79): Inferred type: ('x:type, 'y:type, U('bb:type))
21+
// Info 4164: (51-82): Inferred type: ('x:type, 'y:type, U('ba:type)) -> ()
22+
// Info 4164: (61-79): Inferred type: ('x:type, 'y:type, U('ba:type))
2323
// Info 4164: (62-63): Inferred type: 'x:type
2424
// Info 4164: (65-69): Inferred type: 'y:type
2525
// Info 4164: (68-69): Inferred type: 'y:type
26-
// Info 4164: (71-78): Inferred type: U('bb:type)
27-
// Info 4164: (74-78): Inferred type: U('bb:type)
28-
// Info 4164: (74-75): Inferred type: tfun('bb:type, U('bb:type))
29-
// Info 4164: (76-77): Inferred type: 'bb:type
26+
// Info 4164: (71-78): Inferred type: U('ba:type)
27+
// Info 4164: (74-78): Inferred type: U('ba:type)
28+
// Info 4164: (74-75): Inferred type: tfun('ba:type, U('ba:type))
29+
// Info 4164: (76-77): Inferred type: 'ba:type
3030
// Info 4164: (84-159): Inferred type: (T, U(T), U(U(T))) -> ()
3131
// Info 4164: (96-123): Inferred type: (T, U(T), U(U(T)))
3232
// Info 4164: (97-101): Inferred type: T

test/libsolidity/syntaxTests/experimental/inference/polymorphic_type.sol

+14-14
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ function run() {
2929
// Info 4164: (88-92): Inferred type: 'bg:(type, D)
3030
// Info 4164: (100-170): Inferred type: () -> ()
3131
// Info 4164: (112-114): Inferred type: ()
32-
// Info 4164: (125-141): Inferred type: T(U, 'bo:type, 'bq:(type, C))
33-
// Info 4164: (128-141): Inferred type: T(U, 'bo:type, 'bq:(type, C))
34-
// Info 4164: (128-129): Inferred type: tfun((U, 'bo:type, 'bq:(type, C)), T(U, 'bo:type, 'bq:(type, C)))
32+
// Info 4164: (125-141): Inferred type: T(U, 'bm:type, 'bo:(type, C))
33+
// Info 4164: (128-141): Inferred type: T(U, 'bm:type, 'bo:(type, C))
34+
// Info 4164: (128-129): Inferred type: tfun((U, 'bm:type, 'bo:(type, C)), T(U, 'bm:type, 'bo:(type, C)))
3535
// Info 4164: (130-131): Inferred type: U
36-
// Info 4164: (133-134): Inferred type: 'bo:type
37-
// Info 4164: (136-140): Inferred type: 'bq:(type, C)
38-
// Info 4164: (136-137): Inferred type: 'bq:(type, C)
39-
// Info 4164: (139-140): Inferred type: 'bq:(type, C)
40-
// Info 4164: (151-167): Inferred type: T(V, 'bx:type, 'bz:(type, D))
41-
// Info 4164: (154-167): Inferred type: T(V, 'bx:type, 'bz:(type, D))
42-
// Info 4164: (154-155): Inferred type: tfun((V, 'bx:type, 'bz:(type, D)), T(V, 'bx:type, 'bz:(type, D)))
36+
// Info 4164: (133-134): Inferred type: 'bm:type
37+
// Info 4164: (136-140): Inferred type: 'bo:(type, C)
38+
// Info 4164: (136-137): Inferred type: 'bo:(type, C)
39+
// Info 4164: (139-140): Inferred type: 'bo:(type, C)
40+
// Info 4164: (151-167): Inferred type: T(V, 'bt:type, 'bv:(type, D))
41+
// Info 4164: (154-167): Inferred type: T(V, 'bt:type, 'bv:(type, D))
42+
// Info 4164: (154-155): Inferred type: tfun((V, 'bt:type, 'bv:(type, D)), T(V, 'bt:type, 'bv:(type, D)))
4343
// Info 4164: (156-157): Inferred type: V
44-
// Info 4164: (159-160): Inferred type: 'bx:type
45-
// Info 4164: (162-166): Inferred type: 'bz:(type, D)
46-
// Info 4164: (162-163): Inferred type: 'bz:(type, D)
47-
// Info 4164: (165-166): Inferred type: 'bz:(type, D)
44+
// Info 4164: (159-160): Inferred type: 'bt:type
45+
// Info 4164: (162-166): Inferred type: 'bv:(type, D)
46+
// Info 4164: (162-163): Inferred type: 'bv:(type, D)
47+
// Info 4164: (165-166): Inferred type: 'bv:(type, D)

test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_abs_and_rep.sol

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function fun() {
4343
// Info 4164: (134-141): Inferred type: T(uint)
4444
// Info 4164: (134-135): Inferred type: tfun(uint, T(uint))
4545
// Info 4164: (136-140): Inferred type: uint
46-
// Info 4164: (147-155): Inferred type: T('bp:type)
47-
// Info 4164: (147-152): Inferred type: U(uint) -> T('bp:type)
48-
// Info 4164: (147-148): Inferred type: U('bm:type)
46+
// Info 4164: (147-155): Inferred type: T('bi:type)
47+
// Info 4164: (147-152): Inferred type: U(uint) -> T('bi:type)
48+
// Info 4164: (147-148): Inferred type: U('bg:type)
4949
// Info 4164: (153-154): Inferred type: U(uint)
50-
// Info 4164: (161-169): Inferred type: U('bv:type)
51-
// Info 4164: (161-166): Inferred type: T(uint) -> U('bv:type)
52-
// Info 4164: (161-162): Inferred type: U('bs:type)
50+
// Info 4164: (161-169): Inferred type: U('bm:type)
51+
// Info 4164: (161-166): Inferred type: T(uint) -> U('bm:type)
52+
// Info 4164: (161-162): Inferred type: U('bk:type)
5353
// Info 4164: (167-168): Inferred type: T(uint)
5454
// Info 4164: (180-192): Inferred type: U(string)
5555
// Info 4164: (183-192): Inferred type: U(string)
@@ -59,11 +59,11 @@ function fun() {
5959
// Info 4164: (205-214): Inferred type: T(string)
6060
// Info 4164: (205-206): Inferred type: tfun(string, T(string))
6161
// Info 4164: (207-213): Inferred type: string
62-
// Info 4164: (220-228): Inferred type: T('cj:type)
63-
// Info 4164: (220-225): Inferred type: U(string) -> T('cj:type)
64-
// Info 4164: (220-221): Inferred type: U('cg:type)
62+
// Info 4164: (220-228): Inferred type: T('bu:type)
63+
// Info 4164: (220-225): Inferred type: U(string) -> T('bu:type)
64+
// Info 4164: (220-221): Inferred type: U('bs:type)
6565
// Info 4164: (226-227): Inferred type: U(string)
66-
// Info 4164: (234-242): Inferred type: U('cp:type)
67-
// Info 4164: (234-239): Inferred type: T(string) -> U('cp:type)
68-
// Info 4164: (234-235): Inferred type: U('cm:type)
66+
// Info 4164: (234-242): Inferred type: U('by:type)
67+
// Info 4164: (234-239): Inferred type: T(string) -> U('by:type)
68+
// Info 4164: (234-235): Inferred type: U('bw:type)
6969
// Info 4164: (240-241): Inferred type: T(string)

test/libsolidity/syntaxTests/experimental/inference/polymorphic_type_instantiation_and_operators.sol

+59-59
Original file line numberDiff line numberDiff line change
@@ -57,79 +57,79 @@ function fun(a: T(int: P3), b: T(str: P4)) {
5757
// Info 4164: (74-83): Inferred type: int
5858
// Info 4164: (84-93): Inferred type: str
5959
// Info 4164: (95-156): Inferred type: C
60-
// Info 4164: (101-105): Inferred type: 'bf:(type, C)
61-
// Info 4164: (115-154): Inferred type: ('bf:(type, C), 'bf:(type, C)) -> 'bf:(type, C)
62-
// Info 4164: (127-145): Inferred type: ('bf:(type, C), 'bf:(type, C))
63-
// Info 4164: (128-135): Inferred type: 'bf:(type, C)
64-
// Info 4164: (131-135): Inferred type: 'bf:(type, C)
65-
// Info 4164: (137-144): Inferred type: 'bf:(type, C)
66-
// Info 4164: (140-144): Inferred type: 'bf:(type, C)
67-
// Info 4164: (149-153): Inferred type: 'bf:(type, C)
60+
// Info 4164: (101-105): Inferred type: 'bd:(type, C)
61+
// Info 4164: (115-154): Inferred type: ('bd:(type, C), 'bd:(type, C)) -> 'bd:(type, C)
62+
// Info 4164: (127-145): Inferred type: ('bd:(type, C), 'bd:(type, C))
63+
// Info 4164: (128-135): Inferred type: 'bd:(type, C)
64+
// Info 4164: (131-135): Inferred type: 'bd:(type, C)
65+
// Info 4164: (137-144): Inferred type: 'bd:(type, C)
66+
// Info 4164: (140-144): Inferred type: 'bd:(type, C)
67+
// Info 4164: (149-153): Inferred type: 'bd:(type, C)
6868
// Info 4164: (158-175): Inferred type: P1
69-
// Info 4164: (164-168): Inferred type: 'bi:(type, P1)
69+
// Info 4164: (164-168): Inferred type: 'bg:(type, P1)
7070
// Info 4164: (176-193): Inferred type: P2
71-
// Info 4164: (182-186): Inferred type: 'bl:(type, P2)
71+
// Info 4164: (182-186): Inferred type: 'bj:(type, P2)
7272
// Info 4164: (194-211): Inferred type: P3
73-
// Info 4164: (200-204): Inferred type: 'cb:(type, P3)
73+
// Info 4164: (200-204): Inferred type: 'bw:(type, P3)
7474
// Info 4164: (212-229): Inferred type: P4
75-
// Info 4164: (218-222): Inferred type: 'cd:(type, P4)
75+
// Info 4164: (218-222): Inferred type: 'by:(type, P4)
7676
// Info 4164: (231-255): Inferred type: void
7777
// Info 4164: (256-280): Inferred type: void
7878
// Info 4164: (281-305): Inferred type: void
7979
// Info 4164: (307-331): Inferred type: void
8080
// Info 4164: (332-356): Inferred type: void
8181
// Info 4164: (357-381): Inferred type: void
8282
// Info 4164: (383-458): Inferred type: void
83-
// Info 4164: (398-405): Inferred type: 'cf:(type, P1)
84-
// Info 4164: (399-404): Inferred type: 'cf:(type, P1)
85-
// Info 4164: (402-404): Inferred type: 'cf:(type, P1)
86-
// Info 4164: (415-456): Inferred type: (T('cf:(type, P1)), T('cf:(type, P1))) -> T('cf:(type, P1))
87-
// Info 4164: (427-445): Inferred type: (T('cf:(type, P1)), T('cf:(type, P1)))
88-
// Info 4164: (428-435): Inferred type: T('cf:(type, P1))
89-
// Info 4164: (431-435): Inferred type: T('cf:(type, P1))
90-
// Info 4164: (431-432): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
91-
// Info 4164: (433-434): Inferred type: 'cf:(type, P1)
92-
// Info 4164: (437-444): Inferred type: T('cf:(type, P1))
93-
// Info 4164: (440-444): Inferred type: T('cf:(type, P1))
94-
// Info 4164: (440-441): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
95-
// Info 4164: (442-443): Inferred type: 'cf:(type, P1)
96-
// Info 4164: (449-453): Inferred type: T('cf:(type, P1))
97-
// Info 4164: (449-450): Inferred type: tfun('cf:(type, P1), T('cf:(type, P1)))
98-
// Info 4164: (451-452): Inferred type: 'cf:(type, P1)
83+
// Info 4164: (398-405): Inferred type: 'ca:(type, P1)
84+
// Info 4164: (399-404): Inferred type: 'ca:(type, P1)
85+
// Info 4164: (402-404): Inferred type: 'ca:(type, P1)
86+
// Info 4164: (415-456): Inferred type: (T('ca:(type, P1)), T('ca:(type, P1))) -> T('ca:(type, P1))
87+
// Info 4164: (427-445): Inferred type: (T('ca:(type, P1)), T('ca:(type, P1)))
88+
// Info 4164: (428-435): Inferred type: T('ca:(type, P1))
89+
// Info 4164: (431-435): Inferred type: T('ca:(type, P1))
90+
// Info 4164: (431-432): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
91+
// Info 4164: (433-434): Inferred type: 'ca:(type, P1)
92+
// Info 4164: (437-444): Inferred type: T('ca:(type, P1))
93+
// Info 4164: (440-444): Inferred type: T('ca:(type, P1))
94+
// Info 4164: (440-441): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
95+
// Info 4164: (442-443): Inferred type: 'ca:(type, P1)
96+
// Info 4164: (449-453): Inferred type: T('ca:(type, P1))
97+
// Info 4164: (449-450): Inferred type: tfun('ca:(type, P1), T('ca:(type, P1)))
98+
// Info 4164: (451-452): Inferred type: 'ca:(type, P1)
9999
// Info 4164: (460-535): Inferred type: void
100-
// Info 4164: (475-482): Inferred type: 'cs:(type, P2)
101-
// Info 4164: (476-481): Inferred type: 'cs:(type, P2)
102-
// Info 4164: (479-481): Inferred type: 'cs:(type, P2)
103-
// Info 4164: (493-533): Inferred type: (T('cs:(type, P2)), T('cs:(type, P2))) -> bool
104-
// Info 4164: (504-522): Inferred type: (T('cs:(type, P2)), T('cs:(type, P2)))
105-
// Info 4164: (505-512): Inferred type: T('cs:(type, P2))
106-
// Info 4164: (508-512): Inferred type: T('cs:(type, P2))
107-
// Info 4164: (508-509): Inferred type: tfun('cs:(type, P2), T('cs:(type, P2)))
108-
// Info 4164: (510-511): Inferred type: 'cs:(type, P2)
109-
// Info 4164: (514-521): Inferred type: T('cs:(type, P2))
110-
// Info 4164: (517-521): Inferred type: T('cs:(type, P2))
111-
// Info 4164: (517-518): Inferred type: tfun('cs:(type, P2), T('cs:(type, P2)))
112-
// Info 4164: (519-520): Inferred type: 'cs:(type, P2)
100+
// Info 4164: (475-482): Inferred type: 'ck:(type, P2)
101+
// Info 4164: (476-481): Inferred type: 'ck:(type, P2)
102+
// Info 4164: (479-481): Inferred type: 'ck:(type, P2)
103+
// Info 4164: (493-533): Inferred type: (T('ck:(type, P2)), T('ck:(type, P2))) -> bool
104+
// Info 4164: (504-522): Inferred type: (T('ck:(type, P2)), T('ck:(type, P2)))
105+
// Info 4164: (505-512): Inferred type: T('ck:(type, P2))
106+
// Info 4164: (508-512): Inferred type: T('ck:(type, P2))
107+
// Info 4164: (508-509): Inferred type: tfun('ck:(type, P2), T('ck:(type, P2)))
108+
// Info 4164: (510-511): Inferred type: 'ck:(type, P2)
109+
// Info 4164: (514-521): Inferred type: T('ck:(type, P2))
110+
// Info 4164: (517-521): Inferred type: T('ck:(type, P2))
111+
// Info 4164: (517-518): Inferred type: tfun('ck:(type, P2), T('ck:(type, P2)))
112+
// Info 4164: (519-520): Inferred type: 'ck:(type, P2)
113113
// Info 4164: (526-530): Inferred type: bool
114114
// Info 4164: (537-618): Inferred type: void
115-
// Info 4164: (552-565): Inferred type: 'bo:(type, P1, P2)
116-
// Info 4164: (553-564): Inferred type: 'bo:(type, P1, P2)
117-
// Info 4164: (556-564): Inferred type: 'bo:(type, P1, P2)
118-
// Info 4164: (557-559): Inferred type: 'bo:(type, P1, P2)
119-
// Info 4164: (561-563): Inferred type: 'bo:(type, P1, P2)
120-
// Info 4164: (575-616): Inferred type: (T('bo:(type, P1, P2)), T('bo:(type, P1, P2))) -> T('bo:(type, P1, P2))
121-
// Info 4164: (587-605): Inferred type: (T('bo:(type, P1, P2)), T('bo:(type, P1, P2)))
122-
// Info 4164: (588-595): Inferred type: T('bo:(type, P1, P2))
123-
// Info 4164: (591-595): Inferred type: T('bo:(type, P1, P2))
124-
// Info 4164: (591-592): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
125-
// Info 4164: (593-594): Inferred type: 'bo:(type, P1, P2)
126-
// Info 4164: (597-604): Inferred type: T('bo:(type, P1, P2))
127-
// Info 4164: (600-604): Inferred type: T('bo:(type, P1, P2))
128-
// Info 4164: (600-601): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
129-
// Info 4164: (602-603): Inferred type: 'bo:(type, P1, P2)
130-
// Info 4164: (609-613): Inferred type: T('bo:(type, P1, P2))
131-
// Info 4164: (609-610): Inferred type: tfun('bo:(type, P1, P2), T('bo:(type, P1, P2)))
132-
// Info 4164: (611-612): Inferred type: 'bo:(type, P1, P2)
115+
// Info 4164: (552-565): Inferred type: 'bm:(type, P1, P2)
116+
// Info 4164: (553-564): Inferred type: 'bm:(type, P1, P2)
117+
// Info 4164: (556-564): Inferred type: 'bm:(type, P1, P2)
118+
// Info 4164: (557-559): Inferred type: 'bm:(type, P1, P2)
119+
// Info 4164: (561-563): Inferred type: 'bm:(type, P1, P2)
120+
// Info 4164: (575-616): Inferred type: (T('bm:(type, P1, P2)), T('bm:(type, P1, P2))) -> T('bm:(type, P1, P2))
121+
// Info 4164: (587-605): Inferred type: (T('bm:(type, P1, P2)), T('bm:(type, P1, P2)))
122+
// Info 4164: (588-595): Inferred type: T('bm:(type, P1, P2))
123+
// Info 4164: (591-595): Inferred type: T('bm:(type, P1, P2))
124+
// Info 4164: (591-592): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
125+
// Info 4164: (593-594): Inferred type: 'bm:(type, P1, P2)
126+
// Info 4164: (597-604): Inferred type: T('bm:(type, P1, P2))
127+
// Info 4164: (600-604): Inferred type: T('bm:(type, P1, P2))
128+
// Info 4164: (600-601): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
129+
// Info 4164: (602-603): Inferred type: 'bm:(type, P1, P2)
130+
// Info 4164: (609-613): Inferred type: T('bm:(type, P1, P2))
131+
// Info 4164: (609-610): Inferred type: tfun('bm:(type, P1, P2), T('bm:(type, P1, P2)))
132+
// Info 4164: (611-612): Inferred type: 'bm:(type, P1, P2)
133133
// Info 4164: (620-748): Inferred type: (T(int), T(str)) -> ()
134134
// Info 4164: (632-662): Inferred type: (T(int), T(str))
135135
// Info 4164: (633-646): Inferred type: T(int)

0 commit comments

Comments
 (0)