Semantic Diff

#9328 Open the declaring file for declarations reached through a functor alias or an include

1 commit

3a3ea2a2d1990e552713d0e31e4749e530290425..pr-9328

c77cd3382 · cknitt + Claude · Nov 19, 2026, 06:11 UTC

Open the declaring file for declarations reached through a functor alias or an include

Why

When a declaration in another file is reached through a local alias of a functor (module Make = Fn.MakeSet, then Make(Fn.IntOrd)) or through an include, go to definition, type definition and the "Type definition" link of hover and signature help find the right line and column but return the current file.

An alias of a functor used in an application is now read as the alias, so paths through it lead to the functor. Finding a declaration's file follows local aliases to the module they name, and type definition and the type links use that file. Hover on an alias chain across files continues in the file each alias leads to.

modifiedDefinition through a functor alias or an include

// Fn.resmodule type Ord = {  type t}module IntOrd = {  type t = int}module MakeSet = (O: Ord) => {  type t = array<O.t>  let add = (x: O.t) => [x]}module Base = {  type base = int} // Use.resmodule Make = Fn.MakeSetmodule Aliased = Make(Fn.IntOrd)let a = Aliased.add(1)let t: Aliased.t = [] // Inc.resmodule M = {  include Fn.Base}let v: M.base = 1
text
Before 0-based lines
After 0-based lines
Definition on Aliased.add: Use.res 8:6Type definition on t: Use.res 7:2Hover on v, type link: Inc.res#L12,3Definition on Aliased.add: Fn.res 8:6Type definition on t: Fn.res 7:2Hover on v, type link: Fn.res#L12,3

Review

  • Which implicit constraints are read as their alias? Only those around a module path. The type checker adds them where an alias can't stay an alias, such as the head of an application, and their signature is the aliased module's. Explicit constraints (module M: S = ...) keep their signature S.
  • Which existing snapshot changes? Hover on module Arr = Belt.Array in Hover.res now shows Belt.Array's contents instead of Belt's modules.