Skip to content

Commit

Permalink
[typer] fix module static resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn authored and 0b1kn00b committed Jan 25, 2024
1 parent 561907e commit 4b2d8de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/typing/fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,17 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) =
)
| _ -> raise Not_found
in
let type_field_by_module e t = match e.eexpr with
let type_field_by_module e t =
match e.eexpr with
| TTypeExpr mt ->
let infos = t_infos mt in
if snd infos.mt_path <> snd infos.mt_module.m_path then raise Not_found;
(* TODO: This duplicates some code from typerDotPath.ml *)
begin match infos.mt_module.m_statics with
| Some c when PMap.mem i c.cl_statics ->
let cf = PMap.find i c.cl_statics in
(* We cannot use e here because in the case of module statics the type could be different (issue #11385). *)
let e = type_module_type ctx (TClassDecl c) e.epos in
field_access e cf (FHStatic c)
| _ ->
let t = Typeload.find_type_in_module infos.mt_module i in
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/src/unit/issues/Issue11385.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package unit.issues;

import unit.issues.misc.Issue11385LibraryData;

class Issue11385 extends Test {
function test() {
eq("Hello World", Issue11385LibraryData.isCommitHash());
}
}
7 changes: 7 additions & 0 deletions tests/unit/src/unit/issues/misc/Issue11385LibraryData.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package unit.issues.misc;

class Issue11385LibraryData {}

function isCommitHash() {
return "Hello World";
}

0 comments on commit 4b2d8de

Please sign in to comment.