@@ -2402,7 +2402,18 @@ impl<'a, 'ast> Generator<'a, 'ast> {
24022402 {
24032403 return place;
24042404 }
2405- let Some ( owner) = self . extern_type_name ( & declaring) else {
2405+ // the owner is whichever class up the chain the whitelist
2406+ // has the accessor on (see exposed_owner); a getter, a
2407+ // property setter or a struct field setter all count
2408+ let accessors: Vec < String > = match self . extern_type_name ( & member_type) {
2409+ Some ( value) => vec ! [
2410+ format!( "__get_{}__{value}" , external. name) ,
2411+ format!( "__set_{}__{value}__SystemVoid" , external. name) ,
2412+ format!( "__set_{}__{value}" , external. name) ,
2413+ ] ,
2414+ None => Vec :: new ( ) ,
2415+ } ;
2416+ let Some ( owner) = self . exposed_owner ( & declaring, & accessors) else {
24062417 self . error (
24072418 ctx,
24082419 Message :: key ( "codegen.this_type_is_not_available_on_udon" ) ,
@@ -4745,14 +4756,14 @@ impl<'a, 'ast> Generator<'a, 'ast> {
47454756 } ;
47464757 let name = member. name . replace ( '.' , "" ) ;
47474758 let declaring = self . substitute ( & call. declaring_type , & ctx. key . bindings ) ;
4748- let Some ( owner ) = self . extern_type_name ( & declaring) else {
4759+ if self . extern_type_name ( & declaring) . is_none ( ) {
47494760 self . error (
47504761 ctx,
47514762 Message :: key ( "codegen.this_indexer_s_declaring_type_cannot_be" ) ,
47524763 span,
47534764 ) ;
47544765 return Place :: Error ;
4755- } ;
4766+ }
47564767 let signature = self . substitute_signature ( & call. signature , & ctx. key . bindings ) ;
47574768 let mut indices: Vec < ( DataId , Type ) > = Vec :: new ( ) ;
47584769 for ( position, argument) in arguments. iter ( ) . enumerate ( ) {
@@ -4778,12 +4789,34 @@ impl<'a, 'ast> Generator<'a, 'ast> {
47784789 } ;
47794790 indices. push ( ( value, target) ) ;
47804791 }
4792+ let ty = self . substitute ( & signature. return_type , & ctx. key . bindings ) ;
4793+ // the owner is whichever class up the chain the whitelist has the
4794+ // accessor on (see exposed_owner)
4795+ // (an index type without a spelling is reported when the place is
4796+ // read or written, not here)
4797+ let index_names: Option < Vec < String > > = indices
4798+ . iter ( )
4799+ . map ( |( _, index_type) | self . extern_type_name ( index_type) )
4800+ . collect ( ) ;
4801+ let accessors: Vec < String > = match ( self . extern_type_name ( & ty) , index_names) {
4802+ ( Some ( value) , Some ( parts) ) => {
4803+ let parts = parts. join ( "_" ) ;
4804+ vec ! [
4805+ format!( "__get_{name}__{parts}__{value}" ) ,
4806+ format!( "__set_{name}__{parts}_{value}__SystemVoid" ) ,
4807+ ]
4808+ }
4809+ _ => Vec :: new ( ) ,
4810+ } ;
4811+ let Some ( owner) = self . exposed_owner ( & declaring, & accessors) else {
4812+ return Place :: Error ;
4813+ } ;
47814814 Place :: ExternalIndexer {
47824815 receiver,
47834816 owner,
47844817 name,
47854818 indices,
4786- ty : self . substitute ( & signature . return_type , & ctx . key . bindings ) ,
4819+ ty,
47874820 }
47884821 }
47894822
0 commit comments