Skip to content

Commit 03a7e16

Browse files
authored
Merge pull request #8047 from hughbe/copy-ctor-workaround
Make use of copy constructors called statically but not dynamically an error
2 parents 1f37d3a + de570e1 commit 03a7e16

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

include/swift/AST/TypeRepr.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,12 @@ class SimpleIdentTypeRepr : public ComponentIdentTypeRepr {
283283
SimpleIdentTypeRepr(SourceLoc Loc, Identifier Id)
284284
: ComponentIdentTypeRepr(TypeReprKind::SimpleIdent, Loc, Id) {}
285285

286+
// SmallVector::emplace_back will never need to call this because
287+
// we reserve the right size, but it does try statically.
286288
SimpleIdentTypeRepr(const SimpleIdentTypeRepr &repr)
287-
: SimpleIdentTypeRepr(repr.getLoc(), repr.getIdentifier()) {}
289+
: SimpleIdentTypeRepr(repr.getLoc(), repr.getIdentifier()) {
290+
llvm_unreachable("should not be called dynamically");
291+
}
288292

289293
static bool classof(const TypeRepr *T) {
290294
return T->getKind() == TypeReprKind::SimpleIdent;
@@ -849,8 +853,11 @@ class FixedTypeRepr : public TypeRepr {
849853
FixedTypeRepr(Type Ty, SourceLoc Loc)
850854
: TypeRepr(TypeReprKind::Fixed), Ty(Ty), Loc(Loc) {}
851855

852-
FixedTypeRepr(const FixedTypeRepr& repr)
853-
: FixedTypeRepr(repr.Ty, repr.Loc) {}
856+
// SmallVector::emplace_back will never need to call this because
857+
// we reserve the right size, but it does try statically.
858+
FixedTypeRepr(const FixedTypeRepr &repr) : FixedTypeRepr(repr.Ty, repr.Loc) {
859+
llvm_unreachable("should not be called dynamically");
860+
}
854861

855862
/// Retrieve the location.
856863
SourceLoc getLoc() const { return Loc; }

0 commit comments

Comments
 (0)