Skip to content

Commit eca5ce8

Browse files
Fix PR according to @dungpa comments
1 parent 3fcc393 commit eca5ce8

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

src/fsharp/vs/Symbols.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,14 +1504,14 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
15041504
if isUnresolved() then false else
15051505
match d with
15061506
| M _ | P _ | E _ -> false
1507-
| V v -> match v.BaseOrThisInfo with CtorThisVal -> true | _ -> false
1507+
| V v -> v.BaseOrThisInfo = CtorThisVal
15081508

15091509
/// Is this the "x" in "member x.M = ..."
15101510
member __.IsMemberThisValue =
15111511
if isUnresolved() then false else
15121512
match d with
15131513
| M _ | P _ | E _ -> false
1514-
| V v -> match v.BaseOrThisInfo with MemberThisVal -> true | _ -> false
1514+
| V v -> v.BaseOrThisInfo = MemberThisVal
15151515

15161516
/// Is this a [<Literal>] value, and if so what value? (may be null)
15171517
member __.LiteralValue =

tests/service/ProjectAnalysisTests.fs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,44 +4442,38 @@ let callToOverload = B(5).Overload(4)
44424442
let checkedFile = wholeProjectResults.AssemblyContents.ImplementationFiles.[0]
44434443
match checkedFile.Declarations.[0] with
44444444
| FSharpImplementationFileDeclaration.Entity (_, subDecls) -> subDecls
4445-
| _ -> failwith "unexpected"
4445+
| _ -> failwith "unexpected declaration"
44464446
let getExpr exprIndex =
44474447
match declarations.[exprIndex] with
44484448
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(_,_,e) -> e
44494449
| FSharpImplementationFileDeclaration.InitAction e -> e
4450-
| _ -> failwith "unexpected"
4450+
| _ -> failwith "unexpected declaration"
44514451

44524452
[<Test>]
4453-
let ``Test project36 FSharpMemberOrFunctionOrValue properties`` () =
4453+
let ``Test project36 FSharpMemberOrFunctionOrValue.IsConstructorThisValue & IsMemberThisValue`` () =
44544454
match Project36.getExpr 1 with
4455-
| BasicPatterns.Let((b,_),_)
4456-
when b.IsConstructorThisValue && not b.IsMemberThisValue -> ()
4457-
| _ -> failwith "val b in type B constructor must be ConstructorThis"
4455+
| BasicPatterns.Let((b,_),_) ->
4456+
b.IsConstructorThisValue && not b.IsMemberThisValue
4457+
| _ -> failwith "unexpected expression"
4458+
|> shouldEqual true
44584459

44594460
match Project36.getExpr 2 with
4460-
| BasicPatterns.FSharpFieldGet(Some(BasicPatterns.Value x),_,_)
4461-
when x.IsMemberThisValue && not x.IsConstructorThisValue -> ()
4462-
| _ -> failwith "val x in B.Overload() must be MemberThis"
4461+
| BasicPatterns.FSharpFieldGet(Some(BasicPatterns.Value x),_,_) ->
4462+
x.IsMemberThisValue && not x.IsConstructorThisValue
4463+
| _ -> failwith "unexpected expression"
4464+
|> shouldEqual true
44634465

44644466
match Project36.getExpr 3 with
4465-
| BasicPatterns.Call(_,_,_,_,[BasicPatterns.Value s;_])
4466-
when not s.IsMemberThisValue && not s.IsConstructorThisValue -> ()
4467-
| _ -> failwith "val s in B.Overload(s) must not be MemberThis"
4467+
| BasicPatterns.Call(_,_,_,_,[BasicPatterns.Value s;_]) ->
4468+
not s.IsMemberThisValue && not s.IsConstructorThisValue
4469+
| _ -> failwith "unexpected expression"
4470+
|> shouldEqual true
44684471

4472+
[<Test>]
4473+
let ``Test project36 FSharpMemberOrFunctionOrValue.LiteralValue`` () =
44694474
let project36Module = Project36.wholeProjectResults.AssemblySignature.Entities.[0]
44704475
let lit = project36Module.MembersFunctionsAndValues.[0]
4471-
let notLit = project36Module.MembersFunctionsAndValues.[1]
4472-
if lit.LiteralValue.IsNone || notLit.LiteralValue.IsSome then
4473-
failwith "val lit must be LiteralValue while notLit musn't"
4476+
shouldEqual true (lit.LiteralValue.Value |> unbox |> (=) 1.)
44744477

4475-
[<Test>]
4476-
let ``Test project36 FSharpMemberOrFunctionOrValue.Overloads(false)`` () =
4477-
match Project36.getExpr 6 with
4478-
| BasicPatterns.Call(_,meth,_,_,_)->
4479-
if meth.Overloads(false).IsSome then ()
4480-
else failwithf "Cannot check method %s is overloaded from typed expression" meth.FullName
4481-
| _ -> failwith "unexpected"
4482-
4483-
let typeB = Project36.wholeProjectResults.AssemblySignature.Entities.[0].NestedEntities.[0]
4484-
if typeB.MembersFunctionsAndValues.[2].Overloads(false).Value.Count < 2 then
4485-
failwith "type B has two overloaded methods named Overload"
4478+
let notLit = project36Module.MembersFunctionsAndValues.[1]
4479+
shouldEqual true notLit.LiteralValue.IsNone

0 commit comments

Comments
 (0)