@@ -306,7 +306,7 @@ pub enum Mutability {
306
306
MutableWithImmutableSuperclass ( ItemIdentifier ) ,
307
307
#[ default]
308
308
InteriorMutable ,
309
- // MainThreadOnly,
309
+ MainThreadOnly ,
310
310
}
311
311
312
312
impl Mutability {
@@ -330,6 +330,7 @@ impl fmt::Display for Mutability {
330
330
write ! ( f, "MutableWithImmutableSuperclass<{}>" , superclass. path( ) )
331
331
}
332
332
Self :: InteriorMutable => write ! ( f, "InteriorMutable" ) ,
333
+ Self :: MainThreadOnly => write ! ( f, "MainThreadOnly" ) ,
333
334
}
334
335
}
335
336
}
@@ -349,7 +350,6 @@ pub enum Stmt {
349
350
mutability : Mutability ,
350
351
skipped : bool ,
351
352
sendable : bool ,
352
- mainthreadonly : bool ,
353
353
} ,
354
354
/// @interface class_name (name) <protocols*>
355
355
/// ->
@@ -565,7 +565,7 @@ impl Stmt {
565
565
context,
566
566
) ;
567
567
568
- let ( sendable, mainthreadonly) = parse_attributes ( entity, context) ;
568
+ let ( sendable, mut mainthreadonly) = parse_attributes ( entity, context) ;
569
569
570
570
let mut protocols = Default :: default ( ) ;
571
571
parse_protocols ( entity, & mut protocols, context) ;
@@ -579,7 +579,17 @@ impl Stmt {
579
579
580
580
let superclasses: Vec < _ > = superclasses_full
581
581
. iter ( )
582
- . map ( |( id, generics, _) | ( id. clone ( ) , generics. clone ( ) ) )
582
+ . map ( |( id, generics, entity) | {
583
+ // Ignore sendability on superclasses; because it's an auto trait, it's propagated to subclasses anyhow!
584
+ let ( _sendable, superclass_mainthreadonly) =
585
+ parse_attributes ( entity, context) ;
586
+
587
+ if superclass_mainthreadonly {
588
+ mainthreadonly = true ;
589
+ }
590
+
591
+ ( id. clone ( ) , generics. clone ( ) )
592
+ } )
583
593
. collect ( ) ;
584
594
585
595
// Used for duplicate checking (sometimes the subclass
@@ -592,8 +602,6 @@ impl Stmt {
592
602
. filter_map ( |( superclass_id, _, entity) | {
593
603
let superclass_data = context. class_data . get ( & superclass_id. name ) ;
594
604
595
- // let (sendable, mainthreadonly) = parse_attributes(entity, context);
596
-
597
605
// Explicitly keep going, even if the class itself is skipped
598
606
// if superclass_data.skipped
599
607
@@ -647,10 +655,13 @@ impl Stmt {
647
655
superclasses,
648
656
designated_initializers,
649
657
derives : data. map ( |data| data. derives . clone ( ) ) . unwrap_or_default ( ) ,
650
- mutability : data. map ( |data| data. mutability . clone ( ) ) . unwrap_or_default ( ) ,
658
+ mutability : if mainthreadonly {
659
+ Mutability :: MainThreadOnly
660
+ } else {
661
+ data. map ( |data| data. mutability . clone ( ) ) . unwrap_or_default ( )
662
+ } ,
651
663
skipped : data. map ( |data| data. definition_skipped ) . unwrap_or_default ( ) ,
652
664
sendable : sendable. unwrap_or ( false ) ,
653
- mainthreadonly,
654
665
} )
655
666
. chain ( protocols. into_iter ( ) . map ( |protocol| Self :: ProtocolImpl {
656
667
cls : id. clone ( ) ,
@@ -694,7 +705,7 @@ impl Stmt {
694
705
) ;
695
706
696
707
let ( sendable, mainthreadonly) = parse_attributes ( entity, context) ;
697
- if sendable . is_some ( ) {
708
+ if let Some ( sendable ) = sendable {
698
709
error ! ( ?sendable, "sendable on category" ) ;
699
710
}
700
711
if mainthreadonly {
@@ -710,7 +721,18 @@ impl Stmt {
710
721
711
722
let superclasses: Vec < _ > = parse_superclasses ( entity, context)
712
723
. into_iter ( )
713
- . map ( |( id, generics, _) | ( id, generics) )
724
+ . map ( |( id, generics, entity) | {
725
+ let ( sendable, mainthreadonly) = parse_attributes ( & entity, context) ;
726
+
727
+ if let Some ( sendable) = sendable {
728
+ error ! ( ?sendable, "sendable on category superclass" ) ;
729
+ }
730
+ if mainthreadonly {
731
+ error ! ( "@UIActor on category superclass" ) ;
732
+ }
733
+
734
+ ( id, generics)
735
+ } )
714
736
. collect ( ) ;
715
737
716
738
let subclass_methods = if let Mutability :: ImmutableWithMutableSubclass ( subclass) =
@@ -719,8 +741,6 @@ impl Stmt {
719
741
let subclass_data = context. class_data . get ( & subclass. name ) ;
720
742
assert ! ( !subclass_data. map( |data| data. skipped) . unwrap_or_default( ) ) ;
721
743
722
- // let (sendable, mainthreadonly) = parse_attributes(entity, context);
723
-
724
744
let ( mut methods, _) = parse_methods (
725
745
entity,
726
746
|name| {
@@ -1320,7 +1340,6 @@ impl fmt::Display for Stmt {
1320
1340
mutability,
1321
1341
skipped,
1322
1342
sendable,
1323
- mainthreadonly : _,
1324
1343
} => {
1325
1344
if * skipped {
1326
1345
return Ok ( ( ) ) ;
@@ -1337,7 +1356,8 @@ impl fmt::Display for Stmt {
1337
1356
Mutability :: Immutable
1338
1357
| Mutability :: Mutable
1339
1358
| Mutability :: ImmutableWithMutableSubclass ( _)
1340
- | Mutability :: InteriorMutable => id. feature ( ) ,
1359
+ | Mutability :: InteriorMutable
1360
+ | Mutability :: MainThreadOnly => id. feature ( ) ,
1341
1361
} ;
1342
1362
1343
1363
let ( superclass, superclasses_rest) = superclasses. split_at ( 1 ) ;
0 commit comments