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.
10 use crate::errors::HackError;
11 use crate::typing::typing_error::Result;
12 use crate::typing_ctx::TypingCtx;
13 use crate::typing_toplevel::TypingToplevel;
14 use ty::reason::Reason;
18 pub struct TypingCheckJob;
21 pub fn type_fun<R: Reason>(
22 ctx: Rc<TypingCtx<R>>,
24 ) -> Result<(tast::Def<R>, Vec<HackError<R>>)> {
25 let (def, typing_errors) = TypingToplevel::fun_def(ctx, ast)?;
26 let def = oxidized::aast::Def::Fun(Box::new(def));
27 Ok((def, typing_errors.into_iter().map(Into::into).collect()))
30 pub fn type_class<R: Reason>(
31 ctx: Rc<TypingCtx<R>>,
33 ) -> Result<(tast::Def<R>, Vec<HackError<R>>)> {
34 let (def, typing_errors) = TypingToplevel::class_def(ctx, ast)?;
35 let def = oxidized::aast::Def::Class(Box::new(def));
36 Ok((def, typing_errors.into_iter().map(Into::into).collect()))
39 pub fn type_typedef<R: Reason>(
40 _ctx: Rc<TypingCtx<R>>,
42 ) -> Result<(tast::Def<R>, Vec<HackError<R>>)> {
46 pub fn type_const<R: Reason>(
47 _ctx: Rc<TypingCtx<R>>,
49 ) -> Result<(tast::Def<R>, Vec<HackError<R>>)> {