@@ -1125,31 +1125,7 @@ let is_hack_collection env ty =
11251125
11261126let check_class_get
11271127 env p def_pos cid mid ce (_ , _cid_pos , e ) function_pointer is_method =
1128- let needs_concrete_is_enabled =
1129- TypecheckerOptions. needs_concrete env.genv.tcopt
1130- in
1131- let callee_is_needs_concrete_method =
1132- is_method && get_ce_readonly_prop_or_needs_concrete ce
1133- in
1134- let check_needs_concrete_call (via : [ `Static | `Self | `Parent ] ) : unit =
1135- (* `self` and `parent` forward the referent of `static` so are just as dangerous *)
1136- if
1137- needs_concrete_is_enabled
1138- && callee_is_needs_concrete_method
1139- && not (Env. static_points_to_concrete_class env)
1140- then
1141- Typing_warning_utils. add
1142- env
1143- ( p,
1144- Typing_warning. Call_needs_concrete ,
1145- {
1146- Typing_warning.Call_needs_concrete. call_pos = p;
1147- class_name = cid;
1148- meth_name = mid;
1149- decl_pos = def_pos;
1150- via = (via :> [ `Id | `Static | `Self | `Parent ] );
1151- } )
1152- in
1128+ Typing_needs_concrete. check_class_get env p def_pos cid mid ce e is_method;
11531129 match e with
11541130 | CIself when get_ce_abstract ce -> begin
11551131 match Env. get_self_id env with
@@ -1235,33 +1211,6 @@ let check_class_get
12351211 primary
12361212 @@ Primary. Static_synthetic_method
12371213 { class_name; meth_name = mid; pos = p; decl_pos = def_pos })
1238- | CI _ when needs_concrete_is_enabled && callee_is_needs_concrete_method ->
1239- Env. get_class env cid
1240- |> Decl_entry. to_option
1241- |> Option. iter ~f: (fun class_ ->
1242- let is_concrete =
1243- let is_non_abstract = not (Cls. abstract class_) in
1244- let is_final_non_consistent_construct =
1245- match snd @@ Typing_env. get_construct env class_ with
1246- | FinalClass -> true
1247- | Inconsistent
1248- | ConsistentConstruct ->
1249- false
1250- in
1251- is_non_abstract || is_final_non_consistent_construct
1252- in
1253- if not is_concrete then
1254- Typing_warning_utils. add
1255- env
1256- ( p,
1257- Typing_warning. Call_needs_concrete ,
1258- {
1259- Typing_warning.Call_needs_concrete. call_pos = p;
1260- class_name = cid;
1261- meth_name = mid;
1262- decl_pos = def_pos;
1263- via = `Id ;
1264- } ))
12651214 | CI (_ , class_name ) ->
12661215 (match Env. get_class env class_name with
12671216 | Decl_entry. NotYetAvailable
@@ -1330,32 +1279,11 @@ let check_class_get
13301279 })
13311280 end
13321281 end )
1333- | CIself -> check_needs_concrete_call `Self
1334- | CIparent -> check_needs_concrete_call `Parent
1335- | CIstatic ->
1336- let () = check_needs_concrete_call `Static in
1337- if
1338- needs_concrete_is_enabled
1339- && get_ce_abstract ce
1340- && not (Env. static_points_to_concrete_class env)
1341- then
1342- (* We check for abstract access via `static`
1343- * as part of the "needs concrete" feature, because
1344- * checking for calls to `abstract` functions for
1345- * `self`/`parent`/classname, etc. is already covered by other type
1346- * errors such as Primary.Self_abstract_call, Primary.Parent_abstract_call, etc.
1347- *)
1348- Typing_warning_utils. add
1349- env
1350- ( p,
1351- Typing_warning. Abstract_access_via_static ,
1352- {
1353- Typing_warning.Abstract_access_via_static. access_pos = p;
1354- class_name = cid;
1355- member_name = mid;
1356- decl_pos = def_pos;
1357- } )
1358- | CIexpr _ -> ()
1282+ | CIself
1283+ | CIparent
1284+ | CIstatic
1285+ | CIexpr _ ->
1286+ ()
13591287
13601288module Fun_id : sig
13611289 (* * Synthesize the type of a function identifier. If no type arguments are
@@ -11933,24 +11861,13 @@ end = struct
1193311861 let (env, tal, te, classes) =
1193411862 class_id_for_new ~exact ~is_attribute ~is_catch p env cid explicit_targs
1193511863 in
11864+ Typing_needs_concrete. check_instantiation env p cid;
1193611865 begin
1193711866 match cid with
1193811867 | CIstatic
1193911868 when TypecheckerOptions. needs_concrete env.genv.tcopt
1194011869 && not (Env. static_points_to_concrete_class env) ->
11941- Env. get_self_class env
11942- |> Decl_entry. to_option
11943- |> Option. iter ~f: (fun class_ ->
11944- Typing_warning_utils. add
11945- env
11946- ( p,
11947- Typing_warning. Uninstantiable_class_via_static ,
11948- {
11949- Typing_warning.Uninstantiable_class_via_static. usage_pos =
11950- p;
11951- class_name = Cls. name class_;
11952- decl_pos = Cls. pos class_;
11953- } ))
11870+ ()
1195411871 | _ ->
1195511872 List. iter classes ~f: (function
1195611873 | `Dynamic -> ()
0 commit comments