diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66ef25bb5..516db9122 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## master
- Fix issue where using paths of the form `./something` would show multiple copies of the same file in vscode.
+- When hovering on a field access, show the instantiated type of the field.
## 1.2.1
diff --git a/analysis/src/Hover.ml b/analysis/src/Hover.ml
index 32bdfe5a0..fc34f25cd 100644
--- a/analysis/src/Hover.ml
+++ b/analysis/src/Hover.ml
@@ -140,8 +140,8 @@ let newHover ~full:{SharedTypes.file; package} locItem =
|> String.concat ", " |> Printf.sprintf "(%s)"
in
typeString :: codeBlock (txt ^ argsString) :: docstring
- | `Field {typ} ->
- let typeString, docstring = typ |> fromType ~docstring in
+ | `Field ->
+ let typeString, docstring = t |> fromType ~docstring in
typeString :: docstring)
in
Some (String.concat "\n\n" parts)
diff --git a/analysis/src/ProcessCmt.ml b/analysis/src/ProcessCmt.ml
index 2a21079c2..89bf33747 100644
--- a/analysis/src/ProcessCmt.ml
+++ b/analysis/src/ProcessCmt.ml
@@ -765,11 +765,10 @@ struct
| Ldot (_left, name) -> name
| Lapply (_, _) -> assert false
- let addForField recordType item {Asttypes.txt; loc} =
+ let addForField recordType fieldType {Asttypes.txt; loc} =
match (Shared.dig recordType).desc with
| Tconstr (path, _args, _memo) ->
let t = getTypeAtPath ~env path in
- let {Types.lbl_res} = item in
let name = handleConstructor txt in
let nameLoc = Utils.endOfLocation loc (String.length name) in
let locType =
@@ -785,7 +784,7 @@ struct
GlobalReference (moduleName, path, Field name)
| _ -> NotFound
in
- addLocItem extra nameLoc (Typed (name, lbl_res, locType))
+ addLocItem extra nameLoc (Typed (name, fieldType, locType))
| _ -> ()
let addForRecord recordType items =
@@ -1004,8 +1003,8 @@ struct
()
| Texp_construct (lident, constructor, _args) ->
addForConstructor expression.exp_type lident constructor
- | Texp_field (inner, lident, label_description) ->
- addForField inner.exp_type label_description lident
+ | Texp_field (inner, lident, _label_description) ->
+ addForField inner.exp_type expression.exp_type lident
| Texp_let (_, _, _) ->
(* TODO this scope tracking won't work for recursive *)
addScopeExtent expression.exp_loc
diff --git a/analysis/src/References.ml b/analysis/src/References.ml
index 67de8821c..f5f137d1d 100644
--- a/analysis/src/References.ml
+++ b/analysis/src/References.ml
@@ -129,10 +129,7 @@ let definedForLoc ~file ~package locKind =
match getConstructor file stamp name with
| None -> None
| Some constructor -> Some ([], `Constructor constructor))
- | Field name -> (
- match getField file stamp name with
- | None -> None
- | Some field -> Some ([], `Field field))
+ | Field _name -> Some([], `Field)
| _ -> (
maybeLog
("Trying for declared " ^ tipToString tip ^ " " ^ string_of_int stamp
diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res
index 92e6d04e5..ebe1daf30 100644
--- a/analysis/tests/src/Hover.res
+++ b/analysis/tests/src/Hover.res
@@ -87,3 +87,8 @@ let _ =
let _ =
// ^hov
+
+type r<'a> = {i: 'a, f: float}
+
+let _get = r => r.f +. r.i
+// ^hov
diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt
index eb3c16e32..76d322c1a 100644
--- a/analysis/tests/src/expected/Hover.res.txt
+++ b/analysis/tests/src/expected/Hover.res.txt
@@ -52,3 +52,6 @@ Hover tests/src/Hover.res 84:10
Hover tests/src/Hover.res 87:10
{"contents": "```rescript\n{\"children\": React.element} => React.element\n```"}
+Hover tests/src/Hover.res 92:25
+{"contents": "```rescript\nfloat\n```"}
+