1 // Copyright (c) Facebook, Inc. and its affiliates.
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
7 use crate::alloc::Allocator;
8 use crate::decl_defs::DeclTy;
9 use crate::reason::{Reason, ReasonImpl};
10 use crate::typing_defs::Ty;
11 use crate::typing_env::TEnv;
14 pub struct TypingReturn;
16 #[derive(Debug, Clone)]
17 pub struct TypingReturnInfo<R: Reason> {
22 pub fn make_default_return<R: Reason>(
28 let reason = R::mk(|| ReasonImpl::Rwitness(fpos.clone()));
29 if is_method && fname == env.ctx.special_names.members.__construct {
30 env.ctx.alloc.ty_void(reason)
32 env.ctx.alloc.tany(reason)
36 pub fn make_return_type<R: Reason>(
38 localize: &dyn Fn(&TEnv<R>, DeclTy<R>) -> Ty<R>,
45 pub fn make_info<R: Reason>(
48 _fun_kind: &oxidized::ast_defs::FunKind,
49 _attributes: &[oxidized::aast::UserAttribute<(), ()>],
52 _decl_ty: Option<DeclTy<R>>,
53 ) -> TypingReturnInfo<R> {
54 // TODO(hrust): everything
61 impl<R: Reason> TypingReturnInfo<R> {
62 pub fn placeholder(alloc: &Allocator<R>) -> Self {
63 // TODO(hrust): Tunion []
65 return_type: alloc.tany(R::mk(|| ReasonImpl::Rnone)),