Skip to content

Commit 856429c

Browse files
authored
Merge pull request #10833 from gottesmm/enum_valueownershipkind_erased_return_value
2 parents 72c8d6a + 9be606e commit 856429c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,10 @@ OwnershipCompatibilityUseChecker::visitReturnInst(ReturnInst *RI) {
862862
Base = MergedValue.getValue();
863863
}
864864

865+
if (auto *E = getType().getEnumOrBoundGenericEnum()) {
866+
return visitNonTrivialEnum(E, Base);
867+
}
868+
865869
return {compatibleWithOwnership(Base), true};
866870
}
867871

test/SIL/ownership-verifier/use_verifier.sil

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ bb0(%0 : @trivial $@thick SuperKlass.Type):
351351
return %9999 : $()
352352
}
353353

354+
sil @trivial_enum_return_value : $@convention(thin) () -> @owned Optional<Builtin.NativeObject> {
355+
bb0:
356+
%0 = enum $Optional<Builtin.NativeObject>, #Optional.none!enumelt
357+
return %0 : $Optional<Builtin.NativeObject>
358+
}
359+
354360
//////////////////////
355361
// Terminator Tests //
356362
//////////////////////

0 commit comments

Comments
 (0)