diff --git a/src/fsharp/creflect.fs b/src/fsharp/creflect.fs index 370b86fa80c..b1f9e39fb01 100644 --- a/src/fsharp/creflect.fs +++ b/src/fsharp/creflect.fs @@ -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 @@ -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 diff --git a/tests/fsharp/core/quotes/test.fsx b/tests/fsharp/core/quotes/test.fsx index 6aeb71c58d6..66bb16e988a 100644 --- a/tests/fsharp/core/quotes/test.fsx +++ b/tests/fsharp/core/quotes/test.fsx @@ -2684,6 +2684,44 @@ module NestedQuotations = runAll() +module ExtensionMembersWithSameName = + + type System.Object with + [] + member this.Add(x) = x + [] + member this.Add(x, y) = x + y + [] + static member SAdd(x) = x + [] + 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)