Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 299 - ReflectedDefinition on overloaded extension methods #432

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/fsharp/creflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ let ConvMethodBase cenv env (methName, v:Val) =
let parentTyconR = ConvTyconRef cenv v.TopValActualParent m

match v.MemberInfo with
| Some(vspr) when not v.IsExtensionMember ->
| Some vspr when not v.IsExtensionMember ->

let vref = mkLocalValRef v
let tps,argInfos,retTy,_ = GetTypeOfMemberInMemberForm cenv.g vref
Expand All @@ -1028,6 +1028,22 @@ let ConvMethodBase cenv env (methName, v:Val) =
methRetType = methRetTypeR;
methName = methName;
numGenericArgs=numGenericArgs }

| _ when v.IsExtensionMember ->

let tps,argInfos,retTy,_ = GetTopValTypeInCompiledForm cenv.g v.ValReprInfo.Value v.Type v.Range
let argTys = argInfos |> List.concat |> List.map fst
let envinner = BindFormalTypars env tps
let methArgTypesR = ConvTypes cenv envinner m argTys
let methRetTypeR = ConvReturnType cenv envinner m retTy
let numGenericArgs = tps.Length

QP.MethodBaseData.Method
{ methParent = parentTyconR
methArgTypes = methArgTypesR
methRetType = methRetTypeR
methName = methName
numGenericArgs=numGenericArgs }
| _ ->

QP.MethodBaseData.ModuleDefn
Expand Down
38 changes: 38 additions & 0 deletions tests/fsharp/core/quotes/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,44 @@ module NestedQuotations =

runAll()

module ExtensionMembersWithSameName =

type System.Object with
[<ReflectedDefinition>]
member this.Add(x) = x
[<ReflectedDefinition>]
member this.Add(x, y) = x + y
[<ReflectedDefinition>]
static member SAdd(x) = x
[<ReflectedDefinition>]
static member SAdd(x, y) = x + y

let runAll () =
match <@ obj().Add(2) @> with
| (Patterns.Call(_, m, _)) ->
let text = m |> Expr.TryGetReflectedDefinition |> sprintf "%A"
check "clewwenf094" text "Some Lambda (this, Lambda (x, x))"
| _ -> failwith "unexpected shape"

match <@ obj().Add(2,3) @> with
| (Patterns.Call(_, m, _)) ->
let text = m |> Expr.TryGetReflectedDefinition |> sprintf "%A"
check "clewwenf095" (m.GetParameters().Length) 3
| _ -> failwith "unexpected shape"

match <@ obj.SAdd(2) @> with
| (Patterns.Call(_, m, _)) ->
let text = m |> Expr.TryGetReflectedDefinition |> sprintf "%A"
check "clewwenf096" text "Some Lambda (x, x)"
| _ -> failwith "unexpected shape"

match <@ obj.SAdd(2,3) @> with
| (Patterns.Call(_, m, _)) ->
let text = m |> Expr.TryGetReflectedDefinition |> sprintf "%A"
check "clewwenf097" (m.GetParameters().Length) 2
| _ -> failwith "unexpected shape"

runAll()

let aa =
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
Expand Down