Skip to content

Commit ef28e25

Browse files
committed
update tests
2 parents e2ff74d + 0cb21b7 commit ef28e25

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/fsharp/vs/Symbols.fs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff 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 () ->

tests/service/ProjectAnalysisTests.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4752,7 +4752,9 @@ type A<'XX, 'YY>() =
47524752
[<Test>]
47534753
let ``Test project38 abstract slot information`` () =
47544754
let printAbstractSignature (s: FSharpAbstractSignature) =
4755-
let printType (t: FSharpType) = (string t).[5 ..]
4755+
let printType (t: FSharpType) =
4756+
hash t |> ignore // smoke test to check hash code doesn't loop
4757+
(string t).[5 ..]
47564758
let args =
47574759
(s.AbstractArguments |> Seq.concat |> Seq.map (fun a ->
47584760
(match a.Name with Some n -> n + ":" | _ -> "") + printType a.Type) |> String.concat " * ")

0 commit comments

Comments
 (0)