@@ -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,88 @@ 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 A(i:int) =
4423+ member x.Value = i
4424+
4425+ type B(i:int) as b =
4426+ inherit A(i*2)
4427+ let a = b.Overload(i)
4428+ member x.Overload() = a
4429+ member x.Overload(y: int) = y + y
4430+ member x.BaseValue = base.Value
4431+
4432+ let [<Literal>] lit = 1.0
4433+ let notLit = 1.0
4434+ let callToOverload = B(5).Overload(4)
4435+ """
4436+ File.WriteAllText( fileName1, fileSource1)
4437+ let cleanFileName a = if a = fileName1 then " file1" else " ??"
4438+
4439+ let fileNames = [ fileName1]
4440+ let args = mkProjectCommandLineArgs ( dllName, fileNames)
4441+ let keepAssemblyContentsChecker = FSharpChecker.Create( keepAssemblyContents= true )
4442+ let options = keepAssemblyContentsChecker.GetProjectOptionsFromCommandLineArgs ( projFileName, args)
4443+ let wholeProjectResults =
4444+ keepAssemblyContentsChecker.ParseAndCheckProject( options)
4445+ |> Async.RunSynchronously
4446+ let declarations =
4447+ let checkedFile = wholeProjectResults.AssemblyContents.ImplementationFiles.[ 0 ]
4448+ match checkedFile.Declarations.[ 0 ] with
4449+ | FSharpImplementationFileDeclaration.Entity (_, subDecls) -> subDecls
4450+ | _ -> failwith " unexpected declaration"
4451+ let getExpr exprIndex =
4452+ match declarations.[ exprIndex] with
4453+ | FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(_,_, e) -> e
4454+ | FSharpImplementationFileDeclaration.InitAction e -> e
4455+ | _ -> failwith " unexpected declaration"
4456+
4457+ [<Test>]
4458+ let ``Test project36 FSharpMemberOrFunctionOrValue.IsBaseValue`` () =
4459+ Project36.wholeProjectResults.GetAllUsesOfAllSymbols()
4460+ |> Async.RunSynchronously
4461+ |> Array.pick ( fun ( su : FSharpSymbolUse ) ->
4462+ if su.Symbol.DisplayName = " base"
4463+ then Some ( su.Symbol :?> FSharpMemberOrFunctionOrValue)
4464+ else None)
4465+ |> fun baseSymbol -> shouldEqual true baseSymbol.IsBaseValue
4466+
4467+ [<Test>]
4468+ let ``Test project36 FSharpMemberOrFunctionOrValue.IsConstructorThisValue & IsMemberThisValue`` () =
4469+ // Instead of checking the symbol uses directly, walk the typed tree to check
4470+ // the correct values are also visible from there. Also note you cannot use
4471+ // BasicPatterns.ThisValue in these cases, this is only used when the symbol
4472+ // is implicit in the constructor
4473+ match Project36.getExpr 4 with
4474+ | BasicPatterns.Let(( b,_),_) ->
4475+ b.IsConstructorThisValue && not b.IsMemberThisValue
4476+ | _ -> failwith " unexpected expression"
4477+ |> shouldEqual true
4478+
4479+ match Project36.getExpr 5 with
4480+ | BasicPatterns.FSharpFieldGet( Some( BasicPatterns.Value x),_,_) ->
4481+ x.IsMemberThisValue && not x.IsConstructorThisValue
4482+ | _ -> failwith " unexpected expression"
4483+ |> shouldEqual true
4484+
4485+ match Project36.getExpr 6 with
4486+ | BasicPatterns.Call(_,_,_,_,[ BasicPatterns.Value s;_]) ->
4487+ not s.IsMemberThisValue && not s.IsConstructorThisValue
4488+ | _ -> failwith " unexpected expression"
4489+ |> shouldEqual true
4490+
4491+ [<Test>]
4492+ let ``Test project36 FSharpMemberOrFunctionOrValue.LiteralValue`` () =
4493+ let project36Module = Project36.wholeProjectResults.AssemblySignature.Entities.[ 0 ]
4494+ let lit = project36Module.MembersFunctionsAndValues.[ 0 ]
4495+ shouldEqual true ( lit.LiteralValue.Value |> unbox |> (=) 1. )
4496+
4497+ let notLit = project36Module.MembersFunctionsAndValues.[ 1 ]
4498+ shouldEqual true notLit.LiteralValue.IsNone
0 commit comments