@@ -250,7 +250,7 @@ static bool unifyConcreteTypes(
250250// /
251251// / Returns the most derived superclass, which becomes the new superclass
252252// / that gets recorded in the property map.
253- static Symbol unifySuperclasses (
253+ static std::pair< Symbol, bool > unifySuperclasses (
254254 Symbol lhs, Symbol rhs, RewriteContext &ctx,
255255 SmallVectorImpl<InducedRule> &inducedRules,
256256 bool debug) {
@@ -282,7 +282,7 @@ static Symbol unifySuperclasses(
282282 llvm::dbgs () << " %% Unrelated superclass types\n " ;
283283 }
284284
285- return lhs;
285+ return std::make_pair ( lhs, true ) ;
286286 }
287287
288288 if (lhsClass != rhsClass) {
@@ -300,14 +300,15 @@ static Symbol unifySuperclasses(
300300 if (debug) {
301301 llvm::dbgs () << " %% Superclass conflict\n " ;
302302 }
303- return rhs;
303+ return std::make_pair ( rhs, true ) ;
304304 }
305305
306306 // Record the more specific class.
307- return rhs;
307+ return std::make_pair ( rhs, false ) ;
308308}
309309
310- void PropertyBag::addProperty (
310+ // / Returns true if there was a conflict.
311+ bool PropertyBag::addProperty (
311312 Symbol property, unsigned ruleID, RewriteContext &ctx,
312313 SmallVectorImpl<InducedRule> &inducedRules,
313314 bool debug) {
@@ -316,46 +317,55 @@ void PropertyBag::addProperty(
316317 case Symbol::Kind::Protocol:
317318 ConformsTo.push_back (property.getProtocol ());
318319 ConformsToRules.push_back (ruleID);
319- return ;
320+ return false ;
320321
321322 case Symbol::Kind::Layout:
322323 if (!Layout) {
323324 Layout = property.getLayoutConstraint ();
324325 LayoutRule = ruleID;
325- } else
326+ } else {
326327 Layout = Layout.merge (property.getLayoutConstraint ());
328+ if (!Layout->isKnownLayout ())
329+ return true ;
330+ }
327331
328- return ;
332+ return false ;
329333
330334 case Symbol::Kind::Superclass: {
331335 // FIXME: Also handle superclass vs concrete
332336
333- if (Superclass) {
334- Superclass = unifySuperclasses (*Superclass, property,
335- ctx, inducedRules, debug);
336- } else {
337+ if (!Superclass) {
337338 Superclass = property;
338339 SuperclassRule = ruleID;
340+ } else {
341+ auto pair = unifySuperclasses (*Superclass, property,
342+ ctx, inducedRules, debug);
343+ Superclass = pair.first ;
344+ bool conflict = pair.second ;
345+ if (conflict)
346+ return true ;
339347 }
340348
341- return ;
349+ return false ;
342350 }
343351
344352 case Symbol::Kind::ConcreteType: {
345- if (ConcreteType) {
346- (void ) unifyConcreteTypes (*ConcreteType, property,
347- ctx, inducedRules, debug);
348- } else {
353+ if (!ConcreteType) {
349354 ConcreteType = property;
350355 ConcreteTypeRule = ruleID;
356+ } else {
357+ bool conflict = unifyConcreteTypes (*ConcreteType, property,
358+ ctx, inducedRules, debug);
359+ if (conflict)
360+ return true ;
351361 }
352362
353- return ;
363+ return false ;
354364 }
355365
356366 case Symbol::Kind::ConcreteConformance:
357367 // FIXME
358- return ;
368+ return false ;
359369
360370 case Symbol::Kind::Name:
361371 case Symbol::Kind::GenericParam:
0 commit comments