From 4126b29970690b64ab171ffae6468c78bd4b1180 Mon Sep 17 00:00:00 2001 From: Vassil Mladenov Date: Wed, 6 Oct 2021 11:51:58 -0700 Subject: [PATCH] Remove Aast.TCPartiallyAbstract Summary: Removes the Aast structure for partially abstract type constants. Now, any constant without abstract lowers into `TCConcrete`. I moved the definition error to the parser but retained the code / error message as we may want to allow `as` constraints back on concrete type constants now that the concept of partially abstract type constants has been eliminated. Reviewed By: andrewjkennedy Differential Revision: D31328780 fbshipit-source-id: 923172c6dc0c7567ee1b5e894ee845eb2a8cb703 --- hphp/hack/src/annotated_ast/aast.ml | 8 ------ hphp/hack/src/decl/shallow_decl.ml | 1 - hphp/hack/src/errors/errors.ml | 6 ----- hphp/hack/src/errors/errors.mli | 2 -- hphp/hack/src/hhbc/hhbc_by_ref/emit_class.rs | 2 -- hphp/hack/src/naming/naming.ml | 6 ----- .../src/naming/naming_elaborate_namespaces_endo.ml | 1 - hphp/hack/src/naming/nast.ml | 3 --- .../src/oxidized/aast_visitor/node_impl_gen.rs | 24 +----------------- .../src/oxidized/aast_visitor/node_mut_impl_gen.rs | 24 +----------------- hphp/hack/src/oxidized/aast_visitor/visitor.rs | 9 +------ hphp/hack/src/oxidized/aast_visitor/visitor_mut.rs | 9 +------ hphp/hack/src/oxidized/gen/aast.rs | 23 +---------------- hphp/hack/src/oxidized/impl_gen/aast_impl_gen.rs | 29 +--------------------- hphp/hack/src/oxidized/manual/errors_impl.rs | 12 +++++++++ hphp/hack/src/oxidized_by_ref/gen/aast.rs | 28 +-------------------- hphp/hack/src/parser/lowerer/lowerer.rs | 16 ++++++------ hphp/hack/src/server/serverExtractStandalone.ml | 2 -- .../src/typing/nast_check/class_tparams_check.ml | 5 +--- hphp/hack/src/typing/nast_check/interface_check.ml | 7 ------ .../hack/src/typing/tast_check/type_const_check.ml | 8 ------ hphp/hack/src/typing/typing_toplevel.ml | 14 ----------- hphp/hack/src/typing/typing_type_wellformedness.ml | 3 --- .../typing/write_symbol_info/symbol_add_fact.ml | 1 - .../typing/write_symbol_info/symbol_build_json.ml | 1 - hphp/hack/test/tast/typeconsts.php.exp | 4 +-- .../hack/test/typecheck/tconst/tconst_cstr.php.exp | 6 ----- 27 files changed, 29 insertions(+), 225 deletions(-) diff --git a/hphp/hack/src/annotated_ast/aast.ml b/hphp/hack/src/annotated_ast/aast.ml index 8291aedb12e..17ab19c7448 100644 --- a/hphp/hack/src/annotated_ast/aast.ml +++ b/hphp/hack/src/annotated_ast/aast.ml @@ -898,17 +898,9 @@ and class_abstract_typeconst = { and class_concrete_typeconst = { c_tc_type: hint } -(* A partially abstract type constant always has a constraint * - * and always has a value. *) -and class_partially_abstract_typeconst = { - c_patc_constraint: hint; - c_patc_type: hint; -} - and class_typeconst = | TCAbstract of class_abstract_typeconst | TCConcrete of class_concrete_typeconst - | TCPartiallyAbstract of class_partially_abstract_typeconst and ('ex, 'en) class_typeconst_def = { c_tconst_user_attributes: ('ex, 'en) user_attribute list; diff --git a/hphp/hack/src/decl/shallow_decl.ml b/hphp/hack/src/decl/shallow_decl.ml index 383396c3707..7394a7b0374 100644 --- a/hphp/hack/src/decl/shallow_decl.ml +++ b/hphp/hack/src/decl/shallow_decl.ml @@ -133,7 +133,6 @@ let typeconst env c tc = atc_super_constraint = Option.map ~f:(Decl_hint.hint env) s; atc_default = Option.map ~f:(Decl_hint.hint env) d; } - | Aast.TCPartiallyAbstract { c_patc_constraint = _; c_patc_type = t } | Aast.TCConcrete { c_tc_type = t } -> Typing_defs.TCConcrete { tc_type = Decl_hint.hint env t } in diff --git a/hphp/hack/src/errors/errors.ml b/hphp/hack/src/errors/errors.ml index 8df74a919ce..44e81e7da20 100644 --- a/hphp/hack/src/errors/errors.ml +++ b/hphp/hack/src/errors/errors.ml @@ -2080,12 +2080,6 @@ let interface_with_partial_typeconst tconst_pos = tconst_pos "An interface cannot contain a partially abstract type constant" -let partially_abstract_typeconst_definition pos = - add - (NastCheck.err_code NastCheck.PartiallyAbstractTypeconstDefinition) - pos - "`as` constraints are only legal on abstract type constants" - let mk_multiple_xhp_category pos = { code = NastCheck.err_code NastCheck.MultipleXhpCategory; diff --git a/hphp/hack/src/errors/errors.mli b/hphp/hack/src/errors/errors.mli index 48520871411..d81cfba336a 100644 --- a/hphp/hack/src/errors/errors.mli +++ b/hphp/hack/src/errors/errors.mli @@ -1189,8 +1189,6 @@ val generics_not_allowed : Pos.t -> unit val interface_with_partial_typeconst : Pos.t -> unit -val partially_abstract_typeconst_definition : Pos.t -> unit - val multiple_xhp_category : Pos.t -> unit val mk_multiple_xhp_category : Pos.t -> error diff --git a/hphp/hack/src/hhbc/hhbc_by_ref/emit_class.rs b/hphp/hack/src/hhbc/hhbc_by_ref/emit_class.rs index 8548820de86..31e91998452 100644 --- a/hphp/hack/src/hhbc/hhbc_by_ref/emit_class.rs +++ b/hphp/hack/src/hhbc/hhbc_by_ref/emit_class.rs @@ -191,7 +191,6 @@ fn from_type_constant<'a, 'arena, 'decl>( default: Some(init), .. }) - | TCPartiallyAbstract(ast::ClassPartiallyAbstractTypeconst { type_: init, .. }) | TCConcrete(ast::ClassConcreteTypeconst { c_tc_type: init }) => { // TODO: Deal with the constraint // Type constants do not take type vars hence tparams:[] @@ -230,7 +229,6 @@ fn from_ctx_constant<'a, 'arena>( TCAbstract(ast::ClassAbstractTypeconst { default: None, .. }) => { (Slice::empty(), Slice::empty()) } - TCPartiallyAbstract(_) => (Slice::empty(), Slice::empty()), // does not parse TCAbstract(ast::ClassAbstractTypeconst { default: Some(hint), .. diff --git a/hphp/hack/src/naming/naming.ml b/hphp/hack/src/naming/naming.ml index 71d21da7f5e..ae6f01b17ba 100644 --- a/hphp/hack/src/naming/naming.ml +++ b/hphp/hack/src/naming/naming.ml @@ -1458,12 +1458,6 @@ and typeconst env t = c_atc_default = Option.map ~f:(hint env) c_atc_default; } | TCConcrete { c_tc_type } -> TCConcrete { c_tc_type = hint env c_tc_type } - | TCPartiallyAbstract { c_patc_constraint; c_patc_type } -> - TCPartiallyAbstract - { - c_patc_constraint = hint env c_patc_constraint; - c_patc_type = hint env c_patc_type; - } in let attrs = user_attributes env t.Aast.c_tconst_user_attributes in N. diff --git a/hphp/hack/src/naming/naming_elaborate_namespaces_endo.ml b/hphp/hack/src/naming/naming_elaborate_namespaces_endo.ml index ef79c3fcc7c..8b4f39f1d5d 100644 --- a/hphp/hack/src/naming/naming_elaborate_namespaces_endo.ml +++ b/hphp/hack/src/naming/naming_elaborate_namespaces_endo.ml @@ -152,7 +152,6 @@ class ['a, 'b, 'c, 'd] generic_elaborator = c_atc_super_constraint = super; c_atc_default = default; } - | TCPartiallyAbstract _ -> failwith "unreachable" method! on_class_typeconst_def env tc = if tc.c_tconst_is_ctx then diff --git a/hphp/hack/src/naming/nast.ml b/hphp/hack/src/naming/nast.ml index e97720927f5..a9207f3cf58 100644 --- a/hphp/hack/src/naming/nast.ml +++ b/hphp/hack/src/naming/nast.ml @@ -1090,9 +1090,6 @@ module Visitor_DEPRECATED = struct | Some d -> this#on_hint acc d | None -> acc) | TCConcrete { c_tc_type } -> this#on_hint acc c_tc_type - | TCPartiallyAbstract { c_patc_constraint; c_patc_type } -> - let acc = this#on_hint acc c_patc_constraint in - this#on_hint acc c_patc_type method on_class_c_const acc c_const = let acc = diff --git a/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs b/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs index cbc1def90ae..820314c05d8 100644 --- a/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs +++ b/hphp/hack/src/oxidized/aast_visitor/node_impl_gen.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<<9214d8d7c8e198b6ceaee795b9a37086>> +// @generated SignedSource<<44b35184334ac717e3f8f09f1b568f14>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -409,24 +409,6 @@ impl Node

for ClassId_ { } } } -impl Node

for ClassPartiallyAbstractTypeconst { - fn accept<'node>( - &'node self, - c: &mut P::Context, - v: &mut dyn Visitor<'node, P = P>, - ) -> Result<(), P::Error> { - v.visit_class_partially_abstract_typeconst(c, self) - } - fn recurse<'node>( - &'node self, - c: &mut P::Context, - v: &mut dyn Visitor<'node, P = P>, - ) -> Result<(), P::Error> { - self.constraint.accept(c, v)?; - self.type_.accept(c, v)?; - Ok(()) - } -} impl Node

for ClassTypeconst { fn accept<'node>( &'node self, @@ -449,10 +431,6 @@ impl Node

for ClassTypeconst { a0.accept(c, v)?; Ok(()) } - ClassTypeconst::TCPartiallyAbstract(a0) => { - a0.accept(c, v)?; - Ok(()) - } } } } diff --git a/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs b/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs index 247ac75c416..d907b512dc5 100644 --- a/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs +++ b/hphp/hack/src/oxidized/aast_visitor/node_mut_impl_gen.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<> +// @generated SignedSource<<654be04114c2526ac99b3b69f53c9383>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -409,24 +409,6 @@ impl NodeMut

for ClassId_ { } } } -impl NodeMut

for ClassPartiallyAbstractTypeconst { - fn accept<'node>( - &'node mut self, - c: &mut P::Context, - v: &mut dyn VisitorMut<'node, P = P>, - ) -> Result<(), P::Error> { - v.visit_class_partially_abstract_typeconst(c, self) - } - fn recurse<'node>( - &'node mut self, - c: &mut P::Context, - v: &mut dyn VisitorMut<'node, P = P>, - ) -> Result<(), P::Error> { - self.constraint.accept(c, v)?; - self.type_.accept(c, v)?; - Ok(()) - } -} impl NodeMut

for ClassTypeconst { fn accept<'node>( &'node mut self, @@ -449,10 +431,6 @@ impl NodeMut

for ClassTypeconst { a0.accept(c, v)?; Ok(()) } - ClassTypeconst::TCPartiallyAbstract(a0) => { - a0.accept(c, v)?; - Ok(()) - } } } } diff --git a/hphp/hack/src/oxidized/aast_visitor/visitor.rs b/hphp/hack/src/oxidized/aast_visitor/visitor.rs index da6b63bdb35..571a6803fad 100644 --- a/hphp/hack/src/oxidized/aast_visitor/visitor.rs +++ b/hphp/hack/src/oxidized/aast_visitor/visitor.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<<820e429a867b0e377b57a09e74fc37e5>> +// @generated SignedSource<<40c7ae3771821c272e326c38b2aa733e>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -148,13 +148,6 @@ pub trait Visitor<'node> { ) -> Result<(), ::Error> { p.recurse(c, self.object()) } - fn visit_class_partially_abstract_typeconst( - &mut self, - c: &mut ::Context, - p: &'node ClassPartiallyAbstractTypeconst, - ) -> Result<(), ::Error> { - p.recurse(c, self.object()) - } fn visit_class_typeconst( &mut self, c: &mut ::Context, diff --git a/hphp/hack/src/oxidized/aast_visitor/visitor_mut.rs b/hphp/hack/src/oxidized/aast_visitor/visitor_mut.rs index 68b2d58953a..edaa3d53641 100644 --- a/hphp/hack/src/oxidized/aast_visitor/visitor_mut.rs +++ b/hphp/hack/src/oxidized/aast_visitor/visitor_mut.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<> +// @generated SignedSource<<03157c2f0dc63be231501d1db300f003>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -148,13 +148,6 @@ pub trait VisitorMut<'node> { ) -> Result<(), ::Error> { p.recurse(c, self.object()) } - fn visit_class_partially_abstract_typeconst( - &mut self, - c: &mut ::Context, - p: &'node mut ClassPartiallyAbstractTypeconst, - ) -> Result<(), ::Error> { - p.recurse(c, self.object()) - } fn visit_class_typeconst( &mut self, c: &mut ::Context, diff --git a/hphp/hack/src/oxidized/gen/aast.rs b/hphp/hack/src/oxidized/gen/aast.rs index 0c310fa71c1..1e7b7ea58bb 100644 --- a/hphp/hack/src/oxidized/gen/aast.rs +++ b/hphp/hack/src/oxidized/gen/aast.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<> +// @generated SignedSource<> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -1540,30 +1540,9 @@ pub struct ClassConcreteTypeconst { ToOcamlRep )] #[repr(C)] -pub struct ClassPartiallyAbstractTypeconst { - pub constraint: Hint, - pub type_: Hint, -} - -#[derive( - Clone, - Debug, - Deserialize, - Eq, - FromOcamlRep, - Hash, - NoPosHash, - Ord, - PartialEq, - PartialOrd, - Serialize, - ToOcamlRep -)] -#[repr(C)] pub enum ClassTypeconst { TCAbstract(ClassAbstractTypeconst), TCConcrete(ClassConcreteTypeconst), - TCPartiallyAbstract(ClassPartiallyAbstractTypeconst), } #[derive( diff --git a/hphp/hack/src/oxidized/impl_gen/aast_impl_gen.rs b/hphp/hack/src/oxidized/impl_gen/aast_impl_gen.rs index 8a09ee144b2..5ccc6983193 100644 --- a/hphp/hack/src/oxidized/impl_gen/aast_impl_gen.rs +++ b/hphp/hack/src/oxidized/impl_gen/aast_impl_gen.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<<6aaa66ccf75edd3963c94ea1878e273a>> +// @generated SignedSource<<5bfb4c781ebab43cd0fb74db3c5b55ab>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -2955,9 +2955,6 @@ impl ClassTypeconst { pub fn mk_tcconcrete(p0: ClassConcreteTypeconst) -> Self { ClassTypeconst::TCConcrete(p0) } - pub fn mk_tcpartially_abstract(p0: ClassPartiallyAbstractTypeconst) -> Self { - ClassTypeconst::TCPartiallyAbstract(p0) - } pub fn is_tcabstract(&self) -> bool { match self { ClassTypeconst::TCAbstract(..) => true, @@ -2970,12 +2967,6 @@ impl ClassTypeconst { _ => false, } } - pub fn is_tcpartially_abstract(&self) -> bool { - match self { - ClassTypeconst::TCPartiallyAbstract(..) => true, - _ => false, - } - } pub fn as_tcabstract(&self) -> Option<&ClassAbstractTypeconst> { match self { ClassTypeconst::TCAbstract(p0) => Some(p0), @@ -2988,12 +2979,6 @@ impl ClassTypeconst { _ => None, } } - pub fn as_tcpartially_abstract(&self) -> Option<&ClassPartiallyAbstractTypeconst> { - match self { - ClassTypeconst::TCPartiallyAbstract(p0) => Some(p0), - _ => None, - } - } pub fn as_tcabstract_mut(&mut self) -> Option<&mut ClassAbstractTypeconst> { match self { ClassTypeconst::TCAbstract(p0) => Some(p0), @@ -3006,12 +2991,6 @@ impl ClassTypeconst { _ => None, } } - pub fn as_tcpartially_abstract_mut(&mut self) -> Option<&mut ClassPartiallyAbstractTypeconst> { - match self { - ClassTypeconst::TCPartiallyAbstract(p0) => Some(p0), - _ => None, - } - } pub fn as_tcabstract_into(self) -> Option { match self { ClassTypeconst::TCAbstract(p0) => Some(p0), @@ -3024,12 +3003,6 @@ impl ClassTypeconst { _ => None, } } - pub fn as_tcpartially_abstract_into(self) -> Option { - match self { - ClassTypeconst::TCPartiallyAbstract(p0) => Some(p0), - _ => None, - } - } } impl Def { pub fn mk_fun(p0: FunDef) -> Self { diff --git a/hphp/hack/src/oxidized/manual/errors_impl.rs b/hphp/hack/src/oxidized/manual/errors_impl.rs index e1c77ea1749..874a23ef841 100644 --- a/hphp/hack/src/oxidized/manual/errors_impl.rs +++ b/hphp/hack/src/oxidized/manual/errors_impl.rs @@ -245,4 +245,16 @@ impl NastCheck { vec![], ) } + + pub fn partially_abstract_typeconst_definition(p: Pos) -> Error { + Error::new( + Self::PartiallyAbstractTypeconstDefinition as isize, + ( + p, + "`as` constraints are only legal on abstract type constants".into(), + ), + vec![], + vec![], + ) + } } diff --git a/hphp/hack/src/oxidized_by_ref/gen/aast.rs b/hphp/hack/src/oxidized_by_ref/gen/aast.rs index 6e4b23d5d8b..e4b3e3a4286 100644 --- a/hphp/hack/src/oxidized_by_ref/gen/aast.rs +++ b/hphp/hack/src/oxidized_by_ref/gen/aast.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<<1f13eed7265275161cfef000590c0303>> +// @generated SignedSource<<223a361031f0b3d0726a753205a29337>> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -1925,30 +1925,6 @@ arena_deserializer::impl_deserialize_in_arena!(ClassConcreteTypeconst<'arena>); #[derive( Clone, - Debug, - Deserialize, - Eq, - FromOcamlRepIn, - Hash, - NoPosHash, - Ord, - PartialEq, - PartialOrd, - Serialize, - ToOcamlRep -)] -#[repr(C)] -pub struct ClassPartiallyAbstractTypeconst<'a> { - #[serde(deserialize_with = "arena_deserializer::arena", borrow)] - pub constraint: &'a Hint<'a>, - #[serde(deserialize_with = "arena_deserializer::arena", borrow)] - pub type_: &'a Hint<'a>, -} -impl<'a> TrivialDrop for ClassPartiallyAbstractTypeconst<'a> {} -arena_deserializer::impl_deserialize_in_arena!(ClassPartiallyAbstractTypeconst<'arena>); - -#[derive( - Clone, Copy, Debug, Deserialize, @@ -1968,8 +1944,6 @@ pub enum ClassTypeconst<'a> { TCAbstract(&'a ClassAbstractTypeconst<'a>), #[serde(deserialize_with = "arena_deserializer::arena", borrow)] TCConcrete(&'a ClassConcreteTypeconst<'a>), - #[serde(deserialize_with = "arena_deserializer::arena", borrow)] - TCPartiallyAbstract(&'a ClassPartiallyAbstractTypeconst<'a>), } impl<'a> TrivialDrop for ClassTypeconst<'a> {} arena_deserializer::impl_deserialize_in_arena!(ClassTypeconst<'arena>); diff --git a/hphp/hack/src/parser/lowerer/lowerer.rs b/hphp/hack/src/parser/lowerer/lowerer.rs index 09bf630b16a..4d88ededa7e 100644 --- a/hphp/hack/src/parser/lowerer/lowerer.rs +++ b/hphp/hack/src/parser/lowerer/lowerer.rs @@ -4439,7 +4439,7 @@ where Ok(class.consts.append(&mut class_consts)) } TypeConstDeclaration(c) => { - use ast::ClassTypeconst::{TCAbstract, TCConcrete, TCPartiallyAbstract}; + use ast::ClassTypeconst::{TCAbstract, TCConcrete}; if !c.type_parameters.is_missing() { Self::raise_parsing_error(node, env, &syntax_error::tparams_in_tconst); } @@ -4459,15 +4459,13 @@ where default: type__, }) } else if let Some(type_) = type__ { - match as_constraint { - None => TCConcrete(ast::ClassConcreteTypeconst { c_tc_type: type_ }), - Some(constraint) => { - TCPartiallyAbstract(ast::ClassPartiallyAbstractTypeconst { - constraint, - type_, - }) - } + if as_constraint.is_some() { + Self::raise_hh_error( + env, + NastCheck::partially_abstract_typeconst_definition(name.0.clone()), + ); } + TCConcrete(ast::ClassConcreteTypeconst { c_tc_type: type_ }) } else { Self::raise_hh_error( env, diff --git a/hphp/hack/src/server/serverExtractStandalone.ml b/hphp/hack/src/server/serverExtractStandalone.ml index f0a182fd88e..1a9446d5c7f 100644 --- a/hphp/hack/src/server/serverExtractStandalone.ml +++ b/hphp/hack/src/server/serverExtractStandalone.ml @@ -2299,8 +2299,6 @@ end = struct Aast.( match c_tconst_kind with | TCAbstract { c_atc_as_constraint = c; _ } -> (true, None, c) - | TCPartiallyAbstract { c_patc_constraint = c; c_patc_type = t } -> - (false, Some t, Some c) | TCConcrete { c_tc_type = t } -> (false, Some t, None)) in EltTypeConst diff --git a/hphp/hack/src/typing/nast_check/class_tparams_check.ml b/hphp/hack/src/typing/nast_check/class_tparams_check.ml index df81ae59c7d..0bb6d739cfa 100644 --- a/hphp/hack/src/typing/nast_check/class_tparams_check.ml +++ b/hphp/hack/src/typing/nast_check/class_tparams_check.ml @@ -52,8 +52,5 @@ let handler = Option.iter a ~f:on_hint; Option.iter s ~f:on_hint; Option.iter d ~f:on_hint - | TCConcrete { c_tc_type = t } -> on_hint t - | TCPartiallyAbstract { c_patc_constraint = c; c_patc_type = t } -> - on_hint c; - on_hint t) + | TCConcrete { c_tc_type = t } -> on_hint t) end diff --git a/hphp/hack/src/typing/nast_check/interface_check.ml b/hphp/hack/src/typing/nast_check/interface_check.ml index 8fb6eed6ab6..c7c7665a45e 100644 --- a/hphp/hack/src/typing/nast_check/interface_check.ml +++ b/hphp/hack/src/typing/nast_check/interface_check.ml @@ -35,13 +35,6 @@ let check_interface c = | _ -> () end; - (* make sure interfaces do not contain partially abstract type constants *) - List.iter c.c_typeconsts ~f:(fun tc -> - match tc.c_tconst_kind with - | TCPartiallyAbstract _ -> - Errors.interface_with_partial_typeconst (fst tc.c_tconst_name) - | _ -> ()); - (* make sure that interfaces only have empty public methods *) List.iter ~f:enforce_no_body c.c_methods diff --git a/hphp/hack/src/typing/tast_check/type_const_check.ml b/hphp/hack/src/typing/tast_check/type_const_check.ml index 7bc6b7d4c62..0f175d44139 100644 --- a/hphp/hack/src/typing/tast_check/type_const_check.ml +++ b/hphp/hack/src/typing/tast_check/type_const_check.ml @@ -37,14 +37,6 @@ let handler = name | _ -> () end; - (if - TypecheckerOptions.disallow_partially_abstract_typeconst_definitions - (Tast_env.get_tcopt env) - then - match c_tconst_kind with - | TCPartiallyAbstract _ -> - Errors.partially_abstract_typeconst_definition p - | _ -> ()); begin match Cls.get_typeconst cls name with | None -> () diff --git a/hphp/hack/src/typing/typing_toplevel.ml b/hphp/hack/src/typing/typing_toplevel.ml index f956ee7917d..38633989424 100644 --- a/hphp/hack/src/typing/typing_toplevel.ml +++ b/hphp/hack/src/typing/typing_toplevel.ml @@ -1376,18 +1376,6 @@ let typeconst_def | None -> env in env - | TCPartiallyAbstract { c_patc_constraint = cstr; c_patc_type = ty } -> - let (env, cstr) = - Phase.localize_hint_no_subst ~ignore_errors:false env cstr - in - let (env, ty) = - Phase.localize_hint_no_subst - ~ignore_errors:false - ~report_cycle:(pos, name) - env - ty - in - Type.sub_type pos Reason.URtypeconst_cstr env ty cstr Errors.unify_error | TCConcrete { c_tc_type = ty } -> let (env, _ty) = Phase.localize_hint_no_subst @@ -1405,8 +1393,6 @@ let typeconst_def let env = match c_tconst_kind with | TCConcrete { c_tc_type = (pos, Hshape { nsi_field_map; _ }) } - | TCPartiallyAbstract - { c_patc_type = (pos, Hshape { nsi_field_map; _ }); _ } | TCAbstract { c_atc_default = Some (pos, Hshape { nsi_field_map; _ }); _ } -> let get_name sfi = sfi.sfi_name in diff --git a/hphp/hack/src/typing/typing_type_wellformedness.ml b/hphp/hack/src/typing/typing_type_wellformedness.ml index e634743fe51..a32b9eb2a53 100644 --- a/hphp/hack/src/typing/typing_type_wellformedness.ml +++ b/hphp/hack/src/typing/typing_type_wellformedness.ml @@ -283,9 +283,6 @@ let typeconst (env, _) tconst = maybe hint env c_atc_super_constraint; maybe hint env c_atc_default | TCConcrete { c_tc_type } -> hint env c_tc_type - | TCPartiallyAbstract { c_patc_constraint; c_patc_type } -> - hint env c_patc_constraint; - hint env c_patc_type let class_var env cv = let tenv = diff --git a/hphp/hack/src/typing/write_symbol_info/symbol_add_fact.ml b/hphp/hack/src/typing/write_symbol_info/symbol_add_fact.ml index a04d0a51ba8..f88d6be8fb3 100644 --- a/hphp/hack/src/typing/write_symbol_info/symbol_add_fact.ml +++ b/hphp/hack/src/typing/write_symbol_info/symbol_add_fact.ml @@ -280,7 +280,6 @@ let add_type_const_defn_fact ctx source_map tc decl_id progress = * as a value here *) match tc.c_tconst_kind with | TCConcrete { c_tc_type = h } - | TCPartiallyAbstract { c_patc_type = h; _ } | TCAbstract { c_atc_default = Some h; _ } -> let ty = get_type_from_hint ctx h in ("type", build_type_json_nested ty) :: base_fields diff --git a/hphp/hack/src/typing/write_symbol_info/symbol_build_json.ml b/hphp/hack/src/typing/write_symbol_info/symbol_build_json.ml index c448bc7e3b0..1774a2fc3c8 100644 --- a/hphp/hack/src/typing/write_symbol_info/symbol_build_json.ml +++ b/hphp/hack/src/typing/write_symbol_info/symbol_build_json.ml @@ -244,7 +244,6 @@ let build_type_const_kind_json kind = match kind with | TCAbstract _ -> 0 | TCConcrete _ -> 1 - | TCPartiallyAbstract _ -> 2 in JSON_Number (string_of_int num) diff --git a/hphp/hack/test/tast/typeconsts.php.exp b/hphp/hack/test/tast/typeconsts.php.exp index f33635d59e8..2724967db65 100644 --- a/hphp/hack/test/tast/typeconsts.php.exp +++ b/hphp/hack/test/tast/typeconsts.php.exp @@ -20,8 +20,8 @@ Errors: { c_tconst_user_attributes = []; c_tconst_name = ([7:23-27], "Tacd"); c_tconst_kind = (TCAbstract { c_atc_as_constraint = (Some ([7:31-34], (Hprim Tnum))); c_atc_super_constraint = None; c_atc_default = (Some ([7:37-40], (Hprim Tint))) }); c_tconst_span = [7:3-41]; c_tconst_doc_comment = None; c_tconst_is_ctx = false }; - { c_tconst_user_attributes = []; c_tconst_name = ([8:14-17], "Tpa"); - c_tconst_kind = (TCPartiallyAbstract { c_patc_constraint = ([8:21-24], (Hprim Tnum)); c_patc_type = ([8:27-30], (Hprim Tint)) }); + { c_tconst_user_attributes = []; c_tconst_name = ([8:14-17], "Tpa"); + c_tconst_kind = (TCConcrete { c_tc_type = ([8:27-30], (Hprim Tint)) }); c_tconst_span = [8:3-31]; c_tconst_doc_comment = None; c_tconst_is_ctx = false }; { c_tconst_user_attributes = []; c_tconst_name = ([9:14-16], "Tc"); c_tconst_kind = (TCConcrete { c_tc_type = ([9:19-22], (Hprim Tint)) }); diff --git a/hphp/hack/test/typecheck/tconst/tconst_cstr.php.exp b/hphp/hack/test/typecheck/tconst/tconst_cstr.php.exp index c024e5fd3cb..7f5d931628b 100644 --- a/hphp/hack/test/typecheck/tconst/tconst_cstr.php.exp +++ b/hphp/hack/test/typecheck/tconst/tconst_cstr.php.exp @@ -1,8 +1,2 @@ File "tconst_cstr.php", line 4, characters 14-14: `as` constraints are only legal on abstract type constants (NastCheck[3093]) -File "tconst_cstr.php", line 4, characters 14-14: -Unable to satisfy constraint on this type constant (Typing[4110]) - File "tconst_cstr.php", line 4, characters 19-26: - Expected `arraykey` - File "tconst_cstr.php", line 4, characters 30-34: - But got `mixed` -- 2.11.4.GIT