@@ -2260,6 +2260,9 @@ type TyparOptionalData =
22602260
22612261 /// Set to true if the typar is contravariant, i.e. declared as <in T> in C#
22622262 mutable typar_is_contravariant: bool
2263+
2264+ /// The declared name of the type parameter.
2265+ mutable typar_declared_name: string option
22632266 }
22642267
22652268 [<DebuggerBrowsable( DebuggerBrowsableState.Never) >]
@@ -2361,10 +2364,10 @@ type Typar =
23612364 member x.SetAttribs attribs =
23622365 match attribs, x.typar_ opt_ data with
23632366 | [], None -> ()
2364- | [], Some { typar_ il_ name = None; typar_ xmldoc = doc; typar_ constraints = []; typar_ is_ contravariant = false } when doc.IsEmpty ->
2367+ | [], Some { typar_ il_ name = None; typar_ xmldoc = doc; typar_ constraints = []; typar_ is_ contravariant = false ; typar _ declared _ name = None } when doc.IsEmpty ->
23652368 x.typar_ opt_ data <- None
23662369 | _, Some optData -> optData.typar_ attribs <- attribs
2367- | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = attribs; typar_ is_ contravariant = false }
2370+ | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = attribs; typar_ is_ contravariant = false ; typar _ declared _ name = None }
23682371
23692372 /// Get the XML documentation for the type parameter
23702373 member x.XmlDoc =
@@ -2382,7 +2385,20 @@ type Typar =
23822385 member x.SetILName il_name =
23832386 match x.typar_ opt_ data with
23842387 | Some optData -> optData.typar_ il_ name <- il_ name
2385- | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = il_ name; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = []; typar_ is_ contravariant = false }
2388+ | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = il_ name; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = []; typar_ is_ contravariant = false ; typar_ declared_ name = None}
2389+
2390+ /// Get the declared name of the type parameter
2391+ member x.DeclaredName =
2392+ match x.typar_ opt_ data with
2393+ | Some optData -> optData.typar_ declared_ name
2394+ | _ -> None
2395+
2396+ /// Save the name as the declared name of the type parameter if it is not already set
2397+ member x.PreserveDeclaredName () =
2398+ match x.typar_ opt_ data with
2399+ | Some optData when optData.typar_ declared_ name = None -> optData.typar_ declared_ name <- Some x.Name
2400+ | None -> x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = []; typar_ is_ contravariant = false ; typar_ declared_ name = Some x.Name }
2401+ | _ -> ()
23862402
23872403 /// Indicates the display name of a type variable
23882404 member x.DisplayName = if x.Name = " ?" then " ?" + string x.Stamp else x.Name
@@ -2391,17 +2407,17 @@ type Typar =
23912407 member x.SetConstraints cs =
23922408 match cs, x.typar_ opt_ data with
23932409 | [], None -> ()
2394- | [], Some { typar_ il_ name = None; typar_ xmldoc = doc; typar_ attribs = []; typar_ is_ contravariant = false } when doc.IsEmpty ->
2410+ | [], Some { typar_ il_ name = None; typar_ xmldoc = doc; typar_ attribs = []; typar_ is_ contravariant = false ; typar _ declared _ name = None } when doc.IsEmpty ->
23952411 x.typar_ opt_ data <- None
23962412 | _, Some optData -> optData.typar_ constraints <- cs
2397- | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = cs; typar_ attribs = []; typar_ is_ contravariant = false }
2413+ | _ -> x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = cs; typar_ attribs = []; typar_ is_ contravariant = false ; typar _ declared _ name = None }
23982414
23992415 /// Marks the typar as being contravariant
24002416 member x.MarkAsContravariant () =
24012417 match x.typar_ opt_ data with
24022418 | Some optData -> optData.typar_ is_ contravariant <- true
24032419 | _ ->
2404- x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = []; typar_ is_ contravariant = true }
2420+ x.typar_ opt_ data <- Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = []; typar_ is_ contravariant = true ; typar _ declared _ name = None }
24052421
24062422 /// Creates a type variable that contains empty data, and is not yet linked. Only used during unpickling of F# metadata.
24072423 static member NewUnlinked () : Typar =
@@ -2423,7 +2439,7 @@ type Typar =
24232439 x.typar_ solution <- tg.typar_ solution
24242440 match tg.typar_ opt_ data with
24252441 | Some tg ->
2426- let optData = { typar_ il_ name = tg.typar_ il_ name; typar_ xmldoc = tg.typar_ xmldoc; typar_ constraints = tg.typar_ constraints; typar_ attribs = tg.typar_ attribs; typar_ is_ contravariant = tg.typar_ is_ contravariant }
2442+ let optData = { typar_ il_ name = tg.typar_ il_ name; typar_ xmldoc = tg.typar_ xmldoc; typar_ constraints = tg.typar_ constraints; typar_ attribs = tg.typar_ attribs; typar_ is_ contravariant = tg.typar_ is_ contravariant; typar _ declared _ name = tg.typar _ declared _ name }
24272443 x.typar_ opt_ data <- Some optData
24282444 | None -> ()
24292445
@@ -6183,7 +6199,7 @@ type Construct() =
61836199 typar_ opt_ data =
61846200 match attribs with
61856201 | [] -> None
6186- | _ -> Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = attribs; typar_ is_ contravariant = false } }
6202+ | _ -> Some { typar_ il_ name = None; typar_ xmldoc = XmlDoc.Empty; typar_ constraints = []; typar_ attribs = attribs; typar_ is_ contravariant = false ; typar _ declared _ name = None } }
61876203
61886204 /// Create a new type parameter node for a declared type parameter
61896205 static member NewRigidTypar nm m =
0 commit comments