This commit is contained in:
Shunsuke Shibayama 2022-12-14 07:38:28 +09:00
parent e67f1b9c1b
commit 3ff1675770
3 changed files with 6 additions and 13 deletions

View file

@ -1119,7 +1119,7 @@ impl Context {
generic_module.register_trait(g_module_t.clone(), generic_module_eq);
let Path = mono_q_tp("Path", instanceof(Str));
let module_t = module(Path.clone());
let py_module_t = py_module(Path, self.cfg.python_compatible_mode);
let py_module_t = py_module(Path);
let mut module = Self::builtin_poly_class("Module", vec![PS::named_nd("Path", Str)], 2);
module.register_superclass(g_module_t.clone(), &generic_module);
let mut py_module =
@ -1849,7 +1849,7 @@ impl Context {
let t_pyimport = nd_func(
vec![anon(tp_enum(Str, set! {Path.clone()}))],
None,
py_module(Path, self.cfg.python_compatible_mode),
py_module(Path),
)
.quantify();
let t_pycompile = nd_func(

View file

@ -65,13 +65,8 @@ pub fn module(path: TyParam) -> Type {
}
#[inline]
pub fn py_module(path: TyParam, py_comp_mode: bool) -> Type {
let name = if py_comp_mode {
"ModuleType"
} else {
"PyModule"
};
poly(name, vec![path])
pub fn py_module(path: TyParam) -> Type {
poly("PyModule", vec![path])
}
pub fn module_from_path<P: Into<PathBuf>>(path: P) -> Type {

View file

@ -1646,9 +1646,7 @@ impl Type {
match self {
Self::FreeVar(fv) if fv.is_linked() => fv.crack().is_module(),
Self::Refinement(refine) => refine.t.is_module(),
Self::Poly { name, .. } => {
&name[..] == "PyModule" || &name[..] == "Module" || &name[..] == "ModuleType"
}
Self::Poly { name, .. } => &name[..] == "PyModule" || &name[..] == "Module",
_ => false,
}
}
@ -1657,7 +1655,7 @@ impl Type {
match self {
Self::FreeVar(fv) if fv.is_linked() => fv.crack().is_py_module(),
Self::Refinement(refine) => refine.t.is_py_module(),
Self::Poly { name, .. } => &name[..] == "PyModule" || &name[..] == "ModuleType",
Self::Poly { name, .. } => &name[..] == "PyModule",
_ => false,
}
}