Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4413,6 +4413,12 @@ bool Type::findIf(llvm::function_ref<bool(Type)> pred) const {
}

TypeTraitResult TypeBase::canBeClass() {
// Foreign reference types are represented as Swift classes in the AST,
// however, they use custom retain/release operations, and therefore aren't
// AnyObjects.
if (isForeignReferenceType())
return TypeTraitResult::IsNot;

// Any bridgeable object type can be a class.
if (isBridgeableObjectType())
return TypeTraitResult::Is;
Expand Down
9 changes: 9 additions & 0 deletions test/Interop/Cxx/foreign-reference/array-of-classes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ func go() {
y.append(x)
// CHECK: 1
print(y.count)

var loopCount = 0
for it in y {
// CHECK: RefType()
print(it)
loopCount += 1
}
// CHECK: 1
print(loopCount)
}

go()
Expand Down