@@ -2308,7 +2308,8 @@ static bool shouldDiagnoseExistingDataRaces(const DeclContext *dc) {
2308
2308
return false ;
2309
2309
}
2310
2310
2311
- void swift::checkConcurrentValueConformance (ProtocolConformance *conformance) {
2311
+ void swift::checkConcurrentValueConformance (
2312
+ ProtocolConformance *conformance, bool asWarning) {
2312
2313
auto conformanceDC = conformance->getDeclContext ();
2313
2314
auto nominal = conformance->getType ()->getAnyNominal ();
2314
2315
if (!nominal)
@@ -2326,7 +2327,9 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2326
2327
if (!conformanceDC->getParentSourceFile () ||
2327
2328
conformanceDC->getParentSourceFile () != nominal->getParentSourceFile ()) {
2328
2329
conformanceDecl->diagnose (
2329
- diag::concurrent_value_outside_source_file,
2330
+ asWarning
2331
+ ? diag::concurrent_value_outside_source_file_warn
2332
+ : diag::concurrent_value_outside_source_file,
2330
2333
nominal->getDescriptiveKind (), nominal->getName ());
2331
2334
return ;
2332
2335
}
@@ -2335,8 +2338,11 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2335
2338
// An open class cannot conform to `ConcurrentValue`.
2336
2339
if (classDecl->getFormalAccess () == AccessLevel::Open) {
2337
2340
classDecl->diagnose (
2338
- diag::concurrent_value_open_class, classDecl->getName ());
2339
- return ;
2341
+ asWarning ? diag::concurrent_value_open_class_warn
2342
+ : diag::concurrent_value_open_class,
2343
+ classDecl->getName ());
2344
+ if (!asWarning)
2345
+ return ;
2340
2346
}
2341
2347
2342
2348
// A 'ConcurrentValue' class cannot inherit from another class, although
@@ -2345,10 +2351,12 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2345
2351
if (auto superclassDecl = classDecl->getSuperclassDecl ()) {
2346
2352
if (!superclassDecl->isNSObject ()) {
2347
2353
classDecl->diagnose (
2348
- diag::concurrent_value_inherit,
2354
+ asWarning ? diag::concurrent_value_inherit_warn
2355
+ : diag::concurrent_value_inherit,
2349
2356
nominal->getASTContext ().LangOpts .EnableObjCInterop ,
2350
2357
classDecl->getName ());
2351
- return ;
2358
+ if (!asWarning)
2359
+ return ;
2352
2360
}
2353
2361
}
2354
2362
}
@@ -2359,7 +2367,10 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2359
2367
if (isa<StructDecl>(nominal) || classDecl) {
2360
2368
for (auto property : nominal->getStoredProperties ()) {
2361
2369
if (classDecl && property->supportsMutation ()) {
2362
- property->diagnose (diag::concurrent_value_class_mutable_property, property->getName (), nominal->getDescriptiveKind (),
2370
+ property->diagnose (
2371
+ asWarning ? diag::concurrent_value_class_mutable_property_warn
2372
+ : diag::concurrent_value_class_mutable_property,
2373
+ property->getName (), nominal->getDescriptiveKind (),
2363
2374
nominal->getName ());
2364
2375
continue ;
2365
2376
}
@@ -2368,7 +2379,9 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2368
2379
conformanceDC->mapTypeIntoContext (property->getInterfaceType ());
2369
2380
if (!isConcurrentValueType (conformanceDC, propertyType)) {
2370
2381
property->diagnose (
2371
- diag::non_concurrent_type_member, false , property->getName (),
2382
+ asWarning ? diag::non_concurrent_type_member_warn
2383
+ : diag::non_concurrent_type_member,
2384
+ false , property->getName (),
2372
2385
nominal->getDescriptiveKind (), nominal->getName (), propertyType);
2373
2386
continue ;
2374
2387
}
@@ -2389,7 +2402,9 @@ void swift::checkConcurrentValueConformance(ProtocolConformance *conformance) {
2389
2402
element->getArgumentInterfaceType ());
2390
2403
if (!isConcurrentValueType (conformanceDC, elementType)) {
2391
2404
element->diagnose (
2392
- diag::non_concurrent_type_member, true , element->getName (),
2405
+ asWarning ? diag::non_concurrent_type_member_warn
2406
+ : diag::non_concurrent_type_member,
2407
+ true , element->getName (),
2393
2408
nominal->getDescriptiveKind (), nominal->getName (), elementType);
2394
2409
continue ;
2395
2410
}
0 commit comments