@@ -3068,7 +3068,7 @@ class ConstraintSystem {
30683068 return nullptr ;
30693069 }
30703070
3071- TypeBase* getFavoredType (Expr *E) {
3071+ TypeBase * getFavoredType (Expr *E) {
30723072 assert (E != nullptr );
30733073 return this ->FavoredTypes [E];
30743074 }
@@ -3082,95 +3082,46 @@ class ConstraintSystem {
30823082 // /
30833083 // / The side tables are used through the expression type checker to avoid
30843084 // / mutating nodes until we know we have successfully type-checked them.
3085- void setType (ASTNode node, Type type) {
3086- ASSERT (!node.isNull () && " Cannot set type information on null node" );
3087- ASSERT (type && " Expected non-null type" );
3088-
3089- // Record the type.
3090- Type &entry = NodeTypes[node];
3091- Type oldType = entry;
3092- entry = type;
3093-
3094- if (oldType.getPointer () != type.getPointer ()) {
3095- // Record the fact that we assigned a type to this node.
3096- if (solverState)
3097- recordChange (SolverTrail::Change::RecordedNodeType (node, oldType));
3098- }
3099- }
3085+ void setType (ASTNode node, Type type,
3086+ PreparedOverloadBuilder *preparedOverload=nullptr );
31003087
31013088 // / Undo the above change.
3102- void restoreType (ASTNode node, Type oldType) {
3103- ASSERT (!node.isNull () && " Cannot set type information on null node" );
3104-
3105- if (oldType) {
3106- auto found = NodeTypes.find (node);
3107- ASSERT (found != NodeTypes.end ());
3108- found->second = oldType;
3109- } else {
3110- bool erased = NodeTypes.erase (node);
3111- ASSERT (erased);
3112- }
3113- }
3089+ void restoreType (ASTNode node, Type oldType);
31143090
31153091 // / Check to see if we have a type for a node.
31163092 bool hasType (ASTNode node) const {
3117- assert (!node.isNull () && " Expected non-null node" );
3093+ ASSERT (!node.isNull () && " Expected non-null node" );
31183094 return NodeTypes.count (node) > 0 ;
31193095 }
31203096
31213097 // / Set the type in our type map for a given expression. The side
31223098 // / map is used throughout the expression type checker in order to
31233099 // / avoid mutating expressions until we know we have successfully
31243100 // / type-checked them.
3125- void setType (const KeyPathExpr *KP, unsigned I, Type T) {
3126- ASSERT (KP && " Expected non-null key path parameter!" );
3127- ASSERT (T && " Expected non-null type!" );
3101+ void setType (const KeyPathExpr *KP, unsigned I, Type T);
31283102
3129- Type &entry = KeyPathComponentTypes[{KP, I}];
3130- Type oldType = entry;
3131- entry = T;
3132-
3133- if (oldType.getPointer () != T.getPointer ()) {
3134- if (solverState) {
3135- recordChange (
3136- SolverTrail::Change::RecordedKeyPathComponentType (
3137- KP, I, oldType));
3138- }
3139- }
3140- }
3141-
3142- void restoreType (const KeyPathExpr *KP, unsigned I, Type T) {
3143- ASSERT (KP && " Expected non-null key path parameter!" );
3144-
3145- if (T) {
3146- auto found = KeyPathComponentTypes.find ({KP, I});
3147- ASSERT (found != KeyPathComponentTypes.end ());
3148- found->second = T;
3149- } else {
3150- bool erased = KeyPathComponentTypes.erase ({KP, I});
3151- ASSERT (erased);
3152- }
3153- }
3103+ void restoreType (const KeyPathExpr *KP, unsigned I, Type T);
31543104
31553105 bool hasType (const KeyPathExpr *KP, unsigned I) const {
3156- assert (KP && " Expected non-null key path parameter!" );
3106+ ASSERT (KP && " Expected non-null key path parameter!" );
31573107 return KeyPathComponentTypes.find (std::make_pair (KP, I))
31583108 != KeyPathComponentTypes.end ();
31593109 }
31603110
31613111 // / Get the type for an node.
31623112 Type getType (ASTNode node) const {
3163- assert (hasType (node) && " Expected type to have been set!" );
3164- // FIXME: lvalue differences
3165- // assert((!E->getType() ||
3166- // E->getType()->isEqual(ExprTypes.find(E)->second)) &&
3167- // "Mismatched types!");
3168- return NodeTypes.find (node)->second ;
3113+ ASSERT (!node.isNull () && " Expected non-null node" );
3114+ auto found = NodeTypes.find (node);
3115+ ASSERT (found != NodeTypes.end () && " Expected type to have been set!" );
3116+ return found->second ;
31693117 }
31703118
31713119 Type getType (const KeyPathExpr *KP, unsigned I) const {
3172- assert (hasType (KP, I) && " Expected type to have been set!" );
3173- return KeyPathComponentTypes.find (std::make_pair (KP, I))->second ;
3120+ ASSERT (KP && " Expected non-null key path parameter!" );
3121+ auto found = KeyPathComponentTypes.find (std::make_pair (KP, I));
3122+ ASSERT (found != KeyPathComponentTypes.end () &&
3123+ " Expected type to have been set!" );
3124+ return found->second ;
31743125 }
31753126
31763127 // / Retrieve the type of the node, if known.
@@ -3182,11 +3133,6 @@ class ConstraintSystem {
31823133 return known->second ;
31833134 }
31843135
3185- // / Retrieve type of the given declaration to be used in
3186- // / constraint system, this is better than calling `getType()`
3187- // / directly because it accounts of constraint system flags.
3188- Type getVarType (const VarDecl *var);
3189-
31903136 // / Cache the type of the expression argument and return that same
31913137 // / argument.
31923138 template <typename T>
0 commit comments