File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -1839,13 +1839,27 @@ and FSharpType(cenv, typ:TType) =
18391839 member private typ.AdjustType ( t ) =
18401840 FSharpType( typ.cenv, t)
18411841
1842+ // Note: This equivalence relation is modulo type abbreviations
18421843 override x.Equals ( other : obj ) =
18431844 box x === other ||
18441845 match other with
18451846 | :? FSharpType as t -> typeEquiv cenv.g typ t.V
18461847 | _ -> false
18471848
1848- override x.GetHashCode () = hash x
1849+ // Note: This equivalence relation is modulo type abbreviations. The hash is less than perfect.
1850+ override x.GetHashCode () =
1851+ let rec hashType typ =
1852+ let typ = stripTyEqnsWrtErasure EraseNone cenv.g typ
1853+ match typ with
1854+ | TType_ forall _ -> 10000
1855+ | TType_ var tp -> 10100 + int32 tp.Stamp
1856+ | TType_ app ( tc1, b1) -> 10200 + int32 tc1.Stamp + List.sumBy hashType b1
1857+ | TType_ ucase _ -> 10300 // shouldn't occur in symbols
1858+ | TType_ tuple l1 -> 10400 + List.sumBy hashType l1
1859+ | TType_ fun ( dty, rty) -> 10500 + hashType dty + hashType rty
1860+ | TType_ measure _ -> 10600
1861+ hashType typ
1862+
18491863
18501864 member x.Format ( denv : FSharpDisplayContext ) =
18511865 protect <| fun () ->
Original file line number Diff line number Diff line change @@ -4691,7 +4691,9 @@ type A<'XX, 'YY>() =
46914691[<Test>]
46924692let ``Test project38 abstract slot information`` () =
46934693 let printAbstractSignature ( s : FSharpAbstractSignature ) =
4694- let printType ( t : FSharpType ) = ( string t).[ 5 ..]
4694+ let printType ( t : FSharpType ) =
4695+ hash t |> ignore // smoke test to check hash code doesn't loop
4696+ ( string t).[ 5 ..]
46954697 let args =
46964698 ( s.AbstractArguments |> Seq.concat |> Seq.map ( fun a ->
46974699 ( match a.Name with Some n -> n + " :" | _ -> " " ) + printType a.Type) |> String.concat " * " )
You can’t perform that action at this time.
0 commit comments