Fix return type of WebIDL indexing getters (#1789)

* Wrap the return type of indexing getters as Option<T> if necessary.

* Update tests for indexing getters

* Fix typo

* Add comments describing what the code segment is doing

* Update indexing getter usage

* Revert "Add comments describing what the code segment is doing"

This reverts commit 624a14c0fffb78e8eaed21658ddddbad70b2462d.

* Revert "Fix typo"

This reverts commit 487fc307bc08c2a7778b2117fb03f0f5eb5a3c18.

* Revert "Wrap the return type of indexing getters as Option<T> if necessary."

This reverts commit 547f3dd36c1182928ff728a8452591a492b65e21.

* Update the return signatures of WebIDL indexing getters
This commit is contained in:
Jay D
2019-10-04 07:48:37 +07:00
committed by Alex Crichton
parent 085924567f
commit 0e3b696fb7
4 changed files with 35 additions and 4 deletions

View File

@ -580,6 +580,20 @@ impl<'src> FirstPassRecord<'src> {
let structural =
force_structural || is_structural(signature.orig.attrs.as_ref(), container_attrs);
let catch = force_throws || throws(&signature.orig.attrs);
let ret_ty = if id == &OperationId::IndexingGetter {
// All indexing getters should return optional values (or
// otherwise be marked with catch).
match ret_ty {
IdlType::Nullable(_) => ret_ty,
ref ty @ _ => if catch {
ret_ty
} else {
IdlType::Nullable(Box::new(ty.clone()))
},
}
} else {
ret_ty
};
let variadic = signature.args.len() == signature.orig.args.len()
&& signature
.orig