File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -551,7 +551,19 @@ impl<'a> IdlType<'a> {
551
551
552
552
IdlType :: Nullable ( idl_type) => {
553
553
match * * idl_type {
554
- IdlType :: Union ( ..) => idl_type. to_syn_type ( pos) ,
554
+ IdlType :: Union ( ref idl_types) =>
555
+ if idl_types
556
+ . iter ( )
557
+ . all ( |idl_type|
558
+ match idl_type {
559
+ IdlType :: Interface ( ..) => true ,
560
+ _ => false ,
561
+ }
562
+ ) {
563
+ IdlType :: Nullable ( Box :: new ( IdlType :: Object ) ) . to_syn_type ( pos)
564
+ } else {
565
+ IdlType :: Any . to_syn_type ( pos)
566
+ } ,
555
567
_ => Some ( option_ty ( idl_type. to_syn_type ( pos) ?) )
556
568
}
557
569
} ,
@@ -567,11 +579,22 @@ impl<'a> IdlType<'a> {
567
579
}
568
580
}
569
581
IdlType :: Record ( _idl_type_from, _idl_type_to) => None ,
570
- IdlType :: Union ( _idl_types ) => {
582
+ IdlType :: Union ( idl_types ) => {
571
583
// Handles union types in all places except operation argument types.
572
- // Currently treats them as any type .
584
+ // Currently treats them as object or any types .
573
585
// TODO: add better support for union types here?
574
- IdlType :: Any . to_syn_type ( pos)
586
+ if idl_types
587
+ . iter ( )
588
+ . all ( |idl_type|
589
+ match idl_type {
590
+ IdlType :: Interface ( ..) => true ,
591
+ _ => false ,
592
+ }
593
+ ) {
594
+ IdlType :: Object . to_syn_type ( pos)
595
+ } else {
596
+ IdlType :: Any . to_syn_type ( pos)
597
+ }
575
598
} ,
576
599
577
600
IdlType :: Any => {
You can’t perform that action at this time.
0 commit comments