diff --git a/src/fsharp/typrelns.fs b/src/fsharp/typrelns.fs index cf3607e0d21..69cd851a997 100644 --- a/src/fsharp/typrelns.fs +++ b/src/fsharp/typrelns.fs @@ -1735,10 +1735,11 @@ type CalledMeth<'T> match epinfos with | [pinfo] when pinfo.HasSetter && not pinfo.IsIndexer -> let pminfo = pinfo.SetterMethod - let pminst = freshenMethInfo m pminfo + let pminst = match minfo with + | MethInfo.FSMeth(_,TType.TType_app(_,types),_,_) -> types + | _ -> freshenMethInfo m pminfo Choice1Of2(AssignedItemSetter(id,AssignedPropSetter(pinfo,pminfo, pminst), e)) - | _ -> - + | _ -> match infoReader.GetILFieldInfosOfType(Some(nm),ad,m,returnedObjTy) with | finfo :: _ -> Choice1Of2(AssignedItemSetter(id,AssignedILFieldSetter(finfo), e)) diff --git a/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/NamedArguments/PropertySetterAfterConstruction02NamedExtensions.fs b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/NamedArguments/PropertySetterAfterConstruction02NamedExtensions.fs new file mode 100644 index 00000000000..0cd9de5123c --- /dev/null +++ b/tests/fsharpqa/Source/Conformance/DeclarationElements/MemberDefinitions/NamedArguments/PropertySetterAfterConstruction02NamedExtensions.fs @@ -0,0 +1,40 @@ +// #Regression #Conformance #DeclarationElements #MemberDefinitions #NamedArguments +#light + +// FSB 1368, named arguments implicitly using property setters for generic class do not typecheck correctly + +module GenericClass = + type S<'a,'b> = + class + val mutable x : 'a + val mutable y : 'b + member obj.X with set(v) = obj.x <- v + member obj.Y with set(v) = obj.y <- v + new(a,b) = { x=a; y=b } + end + type S<'a,'b> with + member x.XProxyIntrinsic with set (v:'a) = x.X <- v + member x.YProxyIntrinsic with set (v:'b) = x.Y <- v + module Extensions = + type S<'a,'b> with + member x.XProxyOptional with set (v:'a) = x.X <- v + member x.YProxyOptional with set (v:'b) = x.Y <- v + + open Extensions + + // Standard construction + let x1 = S(1,"1", XProxyIntrinsic = 42, YProxyIntrinsic = "42") + if x1.x <> 42 then exit 1 + if x1.y <> "42" then exit 1 + + let x2 = S<_,_>(1,"1") + x2.XProxyOptional <- 43 + x2.YProxyOptional <- "43" + if x2.x <> 43 then exit 1 + if x2.y <> "43" then exit 1 + + let x3 = S<_,_>(1,"1", XProxyOptional = 44, YProxyOptional = "44") + if x3.x <> 44 then exit 1 + if x3.y <> "44" then exit 1 + exit 0 +