@@ -88,6 +88,9 @@ let attribsOfSymbol (s:FSharpSymbol) =
8888 if v.IsMutable then yield " mutable"
8989 if v.IsOverrideOrExplicitInterfaceImplementation then yield " overridemem"
9090 if v.IsExplicitInterfaceImplementation then yield " intfmem"
91+ // if v.IsConstructorThisValue then yield "ctorthis"
92+ // if v.IsMemberThisValue then yield "this"
93+ // if v.LiteralValue.IsSome then yield "literal"
9194 | _ -> () ]
9295
9396module Project1 =
@@ -4408,3 +4411,75 @@ let ``Test project35 CurriedParameterGroups should be available for nested funct
44084411
44094412 | _ -> failwith " Unexpected symbol type"
44104413
4414+ module Project36 =
4415+ open System.IO
4416+
4417+ let fileName1 = Path.ChangeExtension( Path.GetTempFileName(), " .fs" )
4418+ let base2 = Path.GetTempFileName()
4419+ let dllName = Path.ChangeExtension( base2, " .dll" )
4420+ let projFileName = Path.ChangeExtension( base2, " .fsproj" )
4421+ let fileSource1 = """
4422+ type B(i:int) as b =
4423+ let a = b.Overload(i)
4424+ member x.Overload() = a
4425+ member x.Overload(y: int) = y + y
4426+
4427+ let [<Literal>] lit = 1.0
4428+ let notLit = 1.0
4429+ let callToOverload = B(5).Overload(4)
4430+ """
4431+ File.WriteAllText( fileName1, fileSource1)
4432+ let cleanFileName a = if a = fileName1 then " file1" else " ??"
4433+
4434+ let fileNames = [ fileName1]
4435+ let args = mkProjectCommandLineArgs ( dllName, fileNames)
4436+ let keepAssemblyContentsChecker = FSharpChecker.Create( keepAssemblyContents= true )
4437+ let options = keepAssemblyContentsChecker.GetProjectOptionsFromCommandLineArgs ( projFileName, args)
4438+ let wholeProjectResults =
4439+ keepAssemblyContentsChecker.ParseAndCheckProject( options)
4440+ |> Async.RunSynchronously
4441+ let declarations =
4442+ let checkedFile = wholeProjectResults.AssemblyContents.ImplementationFiles.[ 0 ]
4443+ match checkedFile.Declarations.[ 0 ] with
4444+ | FSharpImplementationFileDeclaration.Entity (_, subDecls) -> subDecls
4445+ | _ -> failwith " unexpected"
4446+ let getExpr exprIndex =
4447+ match declarations.[ exprIndex] with
4448+ | FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(_,_, e) -> e
4449+ | FSharpImplementationFileDeclaration.InitAction e -> e
4450+ | _ -> failwith " unexpected"
4451+
4452+ [<Test>]
4453+ let ``Test project36 FSharpMemberOrFunctionOrValue properties`` () =
4454+ 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"
4458+
4459+ 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"
4463+
4464+ 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"
4468+
4469+ let project36Module = Project36.wholeProjectResults.AssemblySignature.Entities.[ 0 ]
4470+ 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"
4474+
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"
0 commit comments