Skip to content

Commit 1e5194c

Browse files
committed
[cxx-interop] Re-word message and documentation for FRT diagnostics
Several changes: - shorten the warning at the call-site of unannotated functions that return FRTS - place the call to action ("annotate 'X' with 'Y'") at the diagnostic note attached to the unannotated callee, where the annotation should be made - re-word the foreign-reference-type.md documentation to (1) reflect the diagnostic wording change, (2) give a little bit more background about why the annotations are needed, and (3) not be specific to C++ (since we can import FRTs from C as well)
1 parent d47a262 commit 1e5194c

File tree

11 files changed

+87
-78
lines changed

11 files changed

+87
-78
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,11 +2212,11 @@ ERROR(expose_nested_type_to_cxx,none,
22122212
ERROR(expose_macro_to_cxx,none,
22132213
"Swift macro can not yet be represented in C++", (ValueDecl *))
22142214
GROUPED_WARNING(warn_unannotated_cxx_func_returning_frt, ForeignReferenceType, none,
2215-
"cannot infer the ownership of the returned value, annotate %0 with "
2216-
"either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED",
2215+
"cannot infer ownership of foreign reference value returned by %0",
2216+
(const ValueDecl *))
2217+
NOTE(note_unannotated_cxx_func_returning_frt, none,
2218+
"annotate %0 with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED",
22172219
(const ValueDecl *))
2218-
NOTE(note_unannotated_cxx_func_returning_frt, none, "%0 is defined here",
2219-
(const ValueDecl *))
22202220
ERROR(unexposed_other_decl_in_cxx,none,
22212221
"%kind0 is not yet exposed to C++", (ValueDecl *))
22222222
ERROR(unsupported_other_decl_in_cxx,none,

test/Interop/Cxx/foreign-reference/Inputs/cxx-functions-and-methods-returning-frt.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ __attribute__((swift_attr("unsafe")));
179179

180180
// C++ APIs returning cxx frts (for testing diagnostics)
181181
struct StructWithAPIsReturningCxxFrt {
182-
static FRTStruct *_Nonnull StaticMethodReturningCxxFrt(); // expected-note {{'StaticMethodReturningCxxFrt()' is defined here}}
182+
static FRTStruct *_Nonnull StaticMethodReturningCxxFrt(); // expected-note {{annotate 'StaticMethodReturningCxxFrt()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
183183
static FRTStruct *_Nonnull StaticMethodReturningCxxFrtWithAnnotation()
184184
__attribute__((swift_attr("returns_retained")));
185185
};
186186

187-
FRTStruct *_Nonnull global_function_returning_cxx_frt(); // expected-note {{'global_function_returning_cxx_frt()' is defined here}}
187+
FRTStruct *_Nonnull global_function_returning_cxx_frt(); // expected-note {{annotate 'global_function_returning_cxx_frt()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
188188
FRTStruct *_Nonnull global_function_returning_cxx_frt_with_annotations()
189189
__attribute__((swift_attr("returns_retained")));
190190

@@ -303,7 +303,9 @@ __attribute__((swift_attr(
303303
operator-(const FRTOverloadedOperators &other);
304304
};
305305

306-
FRTOverloadedOperators *_Nonnull returnFRTOverloadedOperators(); // expected-note {{'returnFRTOverloadedOperators()' is defined here}} // expected-note {{'returnFRTOverloadedOperators()' is defined here}}
306+
FRTOverloadedOperators *_Nonnull returnFRTOverloadedOperators();
307+
// expected-note@-1 {{annotate 'returnFRTOverloadedOperators()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
308+
// expected-note@-2 {{annotate 'returnFRTOverloadedOperators()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
307309

308310
void retain_FRTOverloadedOperators(FRTOverloadedOperators *_Nonnull v);
309311
void release_FRTOverloadedOperators(FRTOverloadedOperators *_Nonnull v);
@@ -371,7 +373,7 @@ struct __attribute__((swift_attr("import_reference")))
371373
__attribute__((swift_attr("retain:rretain")))
372374
__attribute__((swift_attr("release:rrelease"))) RefType {};
373375

374-
RefType *returnRefType() { return new RefType(); } // expected-note {{'returnRefType()' is defined here}}
376+
RefType *returnRefType() { return new RefType(); } // expected-note {{annotate 'returnRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
375377

376378
struct __attribute__((swift_attr("import_reference")))
377379
__attribute__((swift_attr("retain:dretain")))
@@ -420,10 +422,10 @@ __attribute__((swift_attr("retain:dRetain")))
420422
__attribute__((swift_attr("release:dRelease"))) DerivedTypeNonDefault
421423
: public BaseTypeNonDefault {};
422424

423-
BaseTypeNonDefault *createBaseTypeNonDefault() { // expected-note {{'createBaseTypeNonDefault()' is defined here}}
425+
BaseTypeNonDefault *createBaseTypeNonDefault() { // expected-note {{annotate 'createBaseTypeNonDefault()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
424426
return new BaseTypeNonDefault();
425427
}
426-
DerivedTypeNonDefault *createDerivedTypeNonDefault() { // expected-note {{'createDerivedTypeNonDefault()' is defined here}}
428+
DerivedTypeNonDefault *createDerivedTypeNonDefault() { // expected-note {{annotate 'createDerivedTypeNonDefault()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
427429
return new DerivedTypeNonDefault();
428430
}
429431

@@ -464,7 +466,9 @@ __attribute__((swift_attr("release:release_SourceLocCacheB"))) TypeB {};
464466

465467
template <typename T>
466468
struct Factory {
467-
static T *make() { return new T(); } // expected-note {{'make()' is defined here}} // expected-note {{'make()' is defined here}}
469+
static T *make() { return new T(); }
470+
// expected-note@-1 {{annotate 'make()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
471+
// expected-note@-2 {{annotate 'make()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
468472
};
469473

470474
using FactoryA = Factory<TypeA>;
@@ -508,7 +512,7 @@ class RefTemplate<FRTStruct> {
508512
return &instance;
509513
}
510514

511-
FRTStruct* value() const { // expected-note {{'value()' is defined here}}
515+
FRTStruct* value() const { // expected-note {{annotate 'value()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
512516
return new FRTStruct;
513517
}
514518
};

test/Interop/Cxx/foreign-reference/Inputs/frt-reference-returns.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ struct RefCountedType {
88
__attribute__((swift_attr("retain:retainRefCounted")))
99
__attribute__((swift_attr("release:releaseRefCounted")));
1010

11-
RefCountedType& getRefCountedByRef(); // expected-note {{'getRefCountedByRef()' is defined here}}
12-
RefCountedType& createRefCountedByRef(); // expected-note {{'createRefCountedByRef()' is defined here}}
13-
RefCountedType& copyRefCountedByRef(); // expected-note {{'copyRefCountedByRef()' is defined here}}
11+
RefCountedType& getRefCountedByRef(); // expected-note {{annotate 'getRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
12+
RefCountedType& createRefCountedByRef(); // expected-note {{annotate 'createRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
13+
RefCountedType& copyRefCountedByRef(); // expected-note {{annotate 'copyRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
1414

1515
} // namespace NoAnnotations
1616

test/Interop/Cxx/foreign-reference/Inputs/inheritance.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ __attribute__((swift_attr("release:immortal"))) ImmortalRefType {};
109109
ImmortalRefType *returnImmortalRefType() { return new ImmortalRefType(); };
110110

111111
struct DerivedFromImmortalRefType : ImmortalRefType {};
112-
DerivedFromImmortalRefType *returnDerivedFromImmortalRefType() { // expected-note {{'returnDerivedFromImmortalRefType()' is defined here}}
112+
DerivedFromImmortalRefType *returnDerivedFromImmortalRefType() { // expected-note {{annotate 'returnDerivedFromImmortalRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
113113
return new DerivedFromImmortalRefType();
114114
};
115115

@@ -122,7 +122,7 @@ ValueType *returnValueType() { return new ValueType(); }
122122
struct __attribute__((swift_attr("import_reference")))
123123
__attribute__((swift_attr("retain:ret1")))
124124
__attribute__((swift_attr("release:rel1"))) RefType {};
125-
RefType *returnRefType() { return new RefType(); } // expected-note {{'returnRefType()' is defined here}}
125+
RefType *returnRefType() { return new RefType(); } // expected-note {{annotate 'returnRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
126126

127127
struct DerivedFromValueType : ValueType {};
128128
DerivedFromValueType *returnDerivedFromValueType() {
@@ -133,20 +133,20 @@ struct __attribute__((swift_attr("import_reference")))
133133
__attribute__((swift_attr("retain:ret2")))
134134
__attribute__((swift_attr("release:rel2"))) DerivedFromValueTypeAndAnnotated
135135
: ValueType {};
136-
DerivedFromValueTypeAndAnnotated *returnDerivedFromValueTypeAndAnnotated() { // expected-note {{'returnDerivedFromValueTypeAndAnnotated()' is defined here}}
136+
DerivedFromValueTypeAndAnnotated *returnDerivedFromValueTypeAndAnnotated() { // expected-note {{annotate 'returnDerivedFromValueTypeAndAnnotated()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
137137
return new DerivedFromValueTypeAndAnnotated();
138138
}
139139

140140
struct DerivedFromRefType final : RefType {};
141-
DerivedFromRefType *returnDerivedFromRefType() { // expected-note {{'returnDerivedFromRefType()' is defined here}}
141+
DerivedFromRefType *returnDerivedFromRefType() { // expected-note {{annotate 'returnDerivedFromRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
142142
return new DerivedFromRefType();
143143
}
144144

145145
struct __attribute__((swift_attr("import_reference")))
146146
__attribute__((swift_attr("retain:ret3")))
147147
__attribute__((swift_attr("release:rel3"))) DerivedFromRefTypeAndAnnotated
148148
: RefType {};
149-
DerivedFromRefTypeAndAnnotated *returnDerivedFromRefTypeAndAnnotated() { // expected-note {{'returnDerivedFromRefTypeAndAnnotated()' is defined here}}
149+
DerivedFromRefTypeAndAnnotated *returnDerivedFromRefTypeAndAnnotated() { // expected-note {{annotate 'returnDerivedFromRefTypeAndAnnotated()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
150150
return new DerivedFromRefTypeAndAnnotated();
151151
}
152152
} // namespace ExplicitAnnotationHasPrecedence1
@@ -184,7 +184,7 @@ __attribute__((swift_attr("retain:retain_C")))
184184
__attribute__((swift_attr("release:release_C"))) DerivedFromRefTypeAAndBAnnotated
185185
: RefTypeA,
186186
RefTypeB {};
187-
DerivedFromRefTypeAAndBAnnotated *returnDerivedFromRefTypeAAndBAnnotated() { // expected-note {{'returnDerivedFromRefTypeAAndBAnnotated()' is defined here}}
187+
DerivedFromRefTypeAAndBAnnotated *returnDerivedFromRefTypeAAndBAnnotated() { // expected-note {{annotate 'returnDerivedFromRefTypeAAndBAnnotated()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
188188
return new DerivedFromRefTypeAAndBAnnotated();
189189
}
190190
} // namespace ExplicitAnnotationHasPrecedence2
@@ -206,10 +206,10 @@ struct __attribute__((swift_attr("import_reference")))
206206
__attribute__((swift_attr("retain:RCRetain")))
207207
__attribute__((swift_attr("release:RCRelease"))) RefType {};
208208

209-
RefType *returnRefType() { return new RefType(); }; // expected-note {{'returnRefType()' is defined here}}
209+
RefType *returnRefType() { return new RefType(); }; // expected-note {{annotate 'returnRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
210210

211211
struct DerivedFromRefType final : RefType {};
212-
DerivedFromRefType *returnDerivedFromRefType() { // expected-note {{'returnDerivedFromRefType()' is defined here}}
212+
DerivedFromRefType *returnDerivedFromRefType() { // expected-note {{annotate 'returnDerivedFromRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
213213
return new DerivedFromRefType();
214214
};
215215
} // namespace BasicInheritanceExample
@@ -236,7 +236,7 @@ DerivedFromBaseRef1AndBaseRef2 *returnDerivedFromBaseRef1AndBaseRef2() {
236236
};
237237

238238
struct DerivedFromBaseRef3 : BaseRef3 {};
239-
DerivedFromBaseRef3 *returnDerivedFromBaseRef3() { // expected-note {{'returnDerivedFromBaseRef3()' is defined here}}
239+
DerivedFromBaseRef3 *returnDerivedFromBaseRef3() { // expected-note {{annotate 'returnDerivedFromBaseRef3()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
240240
return new DerivedFromBaseRef3();
241241
};
242242
} // namespace MultipleInheritanceExample1
@@ -312,7 +312,7 @@ __attribute__((swift_attr("release:samerelease"))) B2 {}; // expected-error {{m
312312

313313
struct D : B1, B2 {}; // expected-error {{multiple functions 'sameretain' found; there must be exactly one retain function for reference type 'D'}}
314314
// expected-error@-1 {{multiple functions 'samerelease' found; there must be exactly one release function for reference type 'D'}}
315-
D *returnD() { return new D(); }; // expected-note {{'returnD()' is defined here}}
315+
D *returnD() { return new D(); }; // expected-note {{annotate 'returnD()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
316316
} // namespace OverloadedRetainRelease
317317

318318
void sameretain(OverloadedRetainRelease::B1 *v) {}
@@ -339,7 +339,7 @@ struct BVirtual : virtual A {};
339339
struct CVirtual : virtual A {};
340340

341341
struct VirtualDiamond : BVirtual, CVirtual {};
342-
VirtualDiamond *returnVirtualDiamond() { return new VirtualDiamond(); }; // expected-note {{'returnVirtualDiamond()' is defined here}}
342+
VirtualDiamond *returnVirtualDiamond() { return new VirtualDiamond(); }; // expected-note {{annotate 'returnVirtualDiamond()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
343343
} // namespace RefTypeDiamondInheritance
344344

345345
void retainA(RefTypeDiamondInheritance::A *a) {};
@@ -355,7 +355,7 @@ __attribute__((swift_attr("release:releaseB"))) B : A {};
355355
struct C : A {};
356356

357357
struct Diamond : B, C {};
358-
Diamond *returnDiamond() { return new Diamond(); }; // expected-note {{'returnDiamond()' is defined here}}
358+
Diamond *returnDiamond() { return new Diamond(); }; // expected-note {{annotate 'returnDiamond()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
359359

360360
} // namespace NonRefTypeDiamondInheritance
361361

@@ -384,7 +384,7 @@ __attribute__((swift_attr("retain:forestRetain"))) __attribute__((
384384
};
385385

386386
class Forest : public IntrusiveRefCountedTemplate<Forest> {};
387-
Forest *returnForest() { return new Forest(); }; // expected-note {{'returnForest()' is defined here}}
387+
Forest *returnForest() { return new Forest(); }; // expected-note {{annotate 'returnForest()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
388388
} // namespace InheritingTemplatedRefType
389389

390390
void forestRetain(InheritingTemplatedRefType::IntrusiveRefCountedTemplate<

test/Interop/Cxx/foreign-reference/frt-reference-returns-diagnostics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import FRTReferenceReturns
66

77
func testNoAnnotations() {
88
let _ = NoAnnotations.getRefCountedByRef()
9-
// expected-warning@-1 {{cannot infer the ownership of the returned value, annotate 'getRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
9+
// expected-warning@-1 {{cannot infer ownership of foreign reference value returned by 'getRefCountedByRef()'}}
1010
let _ = NoAnnotations.createRefCountedByRef()
11-
// expected-warning@-1 {{cannot infer the ownership of the returned value, annotate 'createRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
11+
// expected-warning@-1 {{cannot infer ownership of foreign reference value returned by 'createRefCountedByRef()'}}
1212
let _ = NoAnnotations.copyRefCountedByRef()
13-
// expected-warning@-1 {{cannot infer the ownership of the returned value, annotate 'copyRefCountedByRef()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
13+
// expected-warning@-1 {{cannot infer ownership of foreign reference value returned by 'copyRefCountedByRef()'}}
1414
}
1515

1616
func testAPIAnnotations() {

test/Interop/Cxx/foreign-reference/frt-retained-unretained-attributes-error.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import CxxStdlib
88

99
let frtLocalVar1 = global_function_returning_FRT_with_both_attrs_returns_retained_returns_unretained()
1010
let frtLocalVar2 = StructWithStaticMethodsReturningFRTWithBothAttributesReturnsRetainedAndReturnsUnretained.StaticMethodReturningFRT()
11-
let frtLocalVar3 = StructWithAPIsReturningCxxFrt.StaticMethodReturningCxxFrt() // expected-warning {{cannot infer the ownership of the returned value, annotate 'StaticMethodReturningCxxFrt()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
11+
let frtLocalVar3 = StructWithAPIsReturningCxxFrt.StaticMethodReturningCxxFrt() // expected-warning {{cannot infer ownership of foreign reference value returned by 'StaticMethodReturningCxxFrt()'}}
1212
let frtLocalVar4 = StructWithAPIsReturningCxxFrt.StaticMethodReturningCxxFrtWithAnnotation()
13-
let frtLocalVar5 = global_function_returning_cxx_frt() // expected-warning {{cannot infer the ownership of the returned value, annotate 'global_function_returning_cxx_frt()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
13+
let frtLocalVar5 = global_function_returning_cxx_frt() // expected-warning {{cannot infer ownership of foreign reference value returned by 'global_function_returning_cxx_frt()'}}
1414
let frtLocalVar6 = global_function_returning_cxx_frt_with_annotations()
1515
let frtLocalVar7 = StructWithAPIsReturningNonCxxFrt.StaticMethodReturningNonCxxFrt()
1616
let frtLocalVar8 = StructWithAPIsReturningNonCxxFrt.StaticMethodReturningNonCxxFrtWithAnnotation()
@@ -23,8 +23,8 @@ let frtLocalVar14 = global_function_returning_immortal_reference_with_annotation
2323
let frtLocalVar16 = StructWithAPIsReturningUnsafeReference.StaticMethodReturningUnsafeReferenceWithAnnotation()
2424
let frtLocalVar17 = global_function_returning_unsafe_reference()
2525
let frtLocalVar18 = global_function_returning_unsafe_reference_with_annotations()
26-
let x = returnFRTOverloadedOperators() // expected-warning {{cannot infer the ownership of the returned value, annotate 'returnFRTOverloadedOperators()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
27-
let y = returnFRTOverloadedOperators() // expected-warning {{cannot infer the ownership of the returned value, annotate 'returnFRTOverloadedOperators()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
26+
let x = returnFRTOverloadedOperators() // expected-warning {{cannot infer ownership of foreign reference value returned by 'returnFRTOverloadedOperators()'}}
27+
let y = returnFRTOverloadedOperators() // expected-warning {{cannot infer ownership of foreign reference value returned by 'returnFRTOverloadedOperators()'}}
2828
let z = x + y
2929
let w = x - y
3030
let f = FunctionVoidToFRTStruct()
@@ -34,18 +34,18 @@ let nonFrtLocalVar1 = global_function_returning_templated_retrun_frt_owned(nonFr
3434
let _ = DefaultOwnershipConventionOnCXXForeignRefType.returnRefTyDefUnretained()
3535
let _ = FunctionAnnotationHasPrecedence.returnRefTyDefUnretained()
3636
let _ = FunctionAnnotationHasPrecedence.returnRefTyDefUnretainedAnnotatedRetained()
37-
let _ = DefaultOwnershipSuppressUnannotatedAPIWarning.returnRefType() // expected-warning {{cannot infer the ownership of the returned value, annotate 'returnRefType()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
37+
let _ = DefaultOwnershipSuppressUnannotatedAPIWarning.returnRefType() // expected-warning {{cannot infer ownership of foreign reference value returned by 'returnRefType()'}}
3838
let _ = DefaultOwnershipSuppressUnannotatedAPIWarning.returnRefTyDefUnretainedd()
3939
let _ = DefaultOwnershipInheritance.createBaseType()
4040
let _ = DefaultOwnershipInheritance.createDerivedType()
4141
let _ = DefaultOwnershipInheritance.createDerivedType2()
42-
let _ = DefaultOwnershipInheritance.createBaseTypeNonDefault() // expected-warning {{cannot infer the ownership of the returned value, annotate 'createBaseTypeNonDefault()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
43-
let _ = DefaultOwnershipInheritance.createDerivedTypeNonDefault() // expected-warning {{cannot infer the ownership of the returned value, annotate 'createDerivedTypeNonDefault()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
42+
let _ = DefaultOwnershipInheritance.createBaseTypeNonDefault() // expected-warning {{cannot infer ownership of foreign reference value returned by 'createBaseTypeNonDefault()'}}
43+
let _ = DefaultOwnershipInheritance.createDerivedTypeNonDefault() // expected-warning {{cannot infer ownership of foreign reference value returned by 'createDerivedTypeNonDefault()'}}
4444
let _ = DefaultOwnershipInheritance.createDerivedTypeNonDefaultUnretained()
45-
let _ = SourceLocationCaching.FactoryA.make() // expected-warning {{cannot infer the ownership of the returned value, annotate 'make()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
46-
let _ = SourceLocationCaching.FactoryB.make() // expected-warning {{cannot infer the ownership of the returned value, annotate 'make()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
45+
let _ = SourceLocationCaching.FactoryA.make() // expected-warning {{cannot infer ownership of foreign reference value returned by 'make()'}}
46+
let _ = SourceLocationCaching.FactoryB.make() // expected-warning {{cannot infer ownership of foreign reference value returned by 'make()'}}
4747

4848
let refTemplate = FRTStructRef()
4949
let templatePtr = refTemplate.ptr()
5050
let templateGet = refTemplate.get()
51-
let templateValue = refTemplate.value() // expected-warning {{cannot infer the ownership of the returned value, annotate 'value()' with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED}}
51+
let templateValue = refTemplate.value() // expected-warning {{cannot infer ownership of foreign reference value returned by 'value()'}}

0 commit comments

Comments
 (0)