diff --git a/src/fsharp/check.fs b/src/fsharp/check.fs index b2aa261e4d3..02aece18860 100644 --- a/src/fsharp/check.fs +++ b/src/fsharp/check.fs @@ -1125,6 +1125,18 @@ let CheckTopBinding cenv env (TBind(v,e,_) as bind) = check false v.DisplayName check false v.CompiledName + // Check if an F# extension member clashes + if v.IsExtensionMember then + tcref.ModuleOrNamespaceType.AllValsAndMembersByLogicalNameUncached.[v.LogicalName] |> List.iter (fun v2 -> + if v2.IsExtensionMember && not (valEq v v2) && v.CompiledName = v2.CompiledName then + let minfo1 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v, Some 0UL) + let minfo2 = FSMeth(cenv.g, generalizedTyconRef tcref, mkLocalValRef v2, Some 0UL) + if tyconRefEq cenv.g v.MemberApparentParent v2.MemberApparentParent && + MethInfosEquivByNameAndSig EraseAll true cenv.g cenv.amap v.Range minfo1 minfo2 then + errorR(Duplicate(kind,v.DisplayName,v.Range))) + + + // Properties get 'get_X', only if there are no args // Properties get 'get_X' match v.ValReprInfo with diff --git a/tests/fsharp/typecheck/sigs/neg23.bsl b/tests/fsharp/typecheck/sigs/neg23.bsl index f5460a6d7cd..1d21a9a9a41 100644 --- a/tests/fsharp/typecheck/sigs/neg23.bsl +++ b/tests/fsharp/typecheck/sigs/neg23.bsl @@ -38,3 +38,11 @@ neg23.fs(92,18,92,21): typecheck error FS0439: The method 'X04' has curried argu neg23.fs(110,21,110,22): typecheck error FS0439: The method 'F' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments. neg23.fs(113,21,113,22): typecheck error FS0439: The method 'F' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments. + +neg23.fs(164,18,164,29): typecheck error FS0037: Two members called 'GroupRowsBy' have the same signature + +neg23.fs(165,18,165,29): typecheck error FS0037: Two members called 'GroupRowsBy' have the same signature + +neg23.fs(168,17,168,20): typecheck error FS0037: Two members called 'Foo' have the same signature + +neg23.fs(169,17,169,20): typecheck error FS0037: Two members called 'Foo' have the same signature diff --git a/tests/fsharp/typecheck/sigs/neg23.fs b/tests/fsharp/typecheck/sigs/neg23.fs index 24cf167bd34..cef3a34ae93 100644 --- a/tests/fsharp/typecheck/sigs/neg23.fs +++ b/tests/fsharp/typecheck/sigs/neg23.fs @@ -155,3 +155,15 @@ module PositiveTests = let y2 : int -> int = c.M2 (3,4) let y3 : int * int -> int -> int = c.M2 + +type Frame = + class + end +module X = + type Frame with + member frame.GroupRowsBy(key) = () + member frame.GroupRowsBy(key) = () + + // Up to erasure + member this.Foo (x:int->int) = printfn "method 1" + member this.Foo (x:FSharpFunc) = printfn "method 2"