Skip to content

Commit b57b4cf

Browse files
committed
AST: Don't emit 'AnyObject' (aka 'AnyObject') for primitive AnyObject
1 parent 7e6fcc8 commit b57b4cf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,19 @@ static bool isInterestingTypealias(Type type) {
322322
return false;
323323
if (type->is<BuiltinType>())
324324
return false;
325+
326+
auto underlyingTy = aliasTy->getDecl()->getUnderlyingTypeLoc().getType();
327+
328+
// A typealias that directly points at Builtin.AnyObject is not
329+
// 'interesting', since it is in fact the AnyObject typealias in
330+
// the standard library.
331+
if (underlyingTy->isAnyObject() &&
332+
isa<ProtocolCompositionType>(underlyingTy.getPointer()))
333+
return false;
334+
325335
if (aliasTy->getDecl()->isCompatibilityAlias())
326-
return isInterestingTypealias(aliasTy->getSinglyDesugaredType());
336+
return isInterestingTypealias(underlyingTy);
337+
327338
return true;
328339
}
329340

0 commit comments

Comments
 (0)