Skip to content

Commit

Permalink
Extract computeMangledNameWithoutDefaultArgValues to make it testable
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Feb 4, 2015
1 parent bbdd2a3 commit be2d157
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/fsharp/PrettyNaming.fs
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,16 @@ module internal Microsoft.FSharp.Compiler.PrettyNaming
nonDefaultArgs
|> Array.map mangleStaticStringArg
|> String.concat ","
typeLogicalName+","+nonDefaultArgsText
typeLogicalName+","+nonDefaultArgsText


let computeMangledNameWithoutDefaultArgValues(nm,staticArgs,defaultArgValues) =
let nonDefaultArgs =
(staticArgs,defaultArgValues)
||> Array.zip
|> Array.choose (fun (staticArg, (defaultArgName, defaultArgValue)) ->
let actualArgValue = string staticArg
match defaultArgValue with
| Some v when v = actualArgValue -> None
| _ -> Some (defaultArgName, actualArgValue))
mangleProvidedTypeName (nm, nonDefaultArgs)
11 changes: 1 addition & 10 deletions src/fsharp/est.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,16 +1262,7 @@ module internal ExtensionTyping =
staticParams.PApply((fun ps -> ps |> Array.map (fun sp -> sp.Name, (if sp.IsOptional then Some (string sp.RawDefaultValue) else None ))),range=m)

let defaultArgValues = defaultArgValues.PUntaint(id,m)

let nonDefaultArgs =
(staticArgs,defaultArgValues)
||> Array.zip
|> Array.choose (fun (staticArg, (defaultArgName, defaultArgValue)) ->
let actualArgValue = string staticArg
match defaultArgValue with
| Some v when v = actualArgValue -> None
| _ -> Some (defaultArgName, actualArgValue))
PrettyNaming.mangleProvidedTypeName (nm, nonDefaultArgs)
PrettyNaming.computeMangledNameWithoutDefaultArgValues(nm,staticArgs,defaultArgValues)

/// Apply the given provided method to the given static arguments (the arguments are assumed to have been sorted into application order)
let TryApplyProvidedMethod(methBeforeArgs:Tainted<ProvidedMethodBase>, staticArgs:obj[], m:range) =
Expand Down

0 comments on commit be2d157

Please sign in to comment.