diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index cfe592e1c27..bdb4fd8bdce 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -1225,12 +1225,12 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) permitWeakResolution ndeep let calledMethGroup = minfos // curried members may not be used to satisfy constraints - |> List.filter (fun minfo -> not minfo.IsCurried) - |> List.map (fun minfo -> - let callerArgs = argtys |> List.map (fun argty -> CallerArg(argty,m,false,dummyExpr)) - let minst = FreshenMethInfo m minfo - let objtys = minfo.GetObjArgTypes(amap, m, minst) - CalledMeth(csenv.InfoReader,None,false,FreshenMethInfo,m,AccessibleFromEverywhere,minfo,minst,minst,None,objtys,[(callerArgs,[])],false,false,None)) + |> List.choose (fun minfo -> + if minfo.IsCurried then None else + let callerArgs = argtys |> List.map (fun argty -> CallerArg(argty,m,false,dummyExpr)) + let minst = FreshenMethInfo m minfo + let objtys = minfo.GetObjArgTypes(amap, m, minst) + Some(CalledMeth(csenv.InfoReader,None,false,FreshenMethInfo,m,AccessibleFromEverywhere,minfo,minst,minst,None,objtys,[(callerArgs,[])],false,false,None))) let methOverloadResult,errors = CollectThenUndo (fun trace -> ResolveOverloading csenv (WithTrace(trace)) nm ndeep true (0,0) AccessibleFromEverywhere calledMethGroup false (Some rty)) @@ -1803,8 +1803,7 @@ and SolveTypRequiresDefaultConstructor (csenv:ConstraintSolverEnv) ndeep m2 trac CompleteD elif GetIntrinsicConstructorInfosOfType csenv.InfoReader m ty - |> List.filter (IsMethInfoAccessible amap m AccessibleFromEverywhere) - |> List.exists (fun x -> x.IsNullary) + |> List.exists (fun x -> IsMethInfoAccessible amap m AccessibleFromEverywhere x && x.IsNullary) then if (isAppTy g ty && HasFSharpAttribute g g.attrib_AbstractClassAttribute (tcrefOfAppTy g ty).Attribs) then ErrorD (ConstraintSolverError(FSComp.SR.csGenericConstructRequiresNonAbstract(NicePrint.minimalStringOfType denv typ),m,m2)) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index fbe0205101e..f44e90cc2a0 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -5913,7 +5913,7 @@ and TcCtorCall isNaked cenv env tpenv overallTy objTy mObjTyOpt item superInit a // TcRecordConstruction //------------------------------------------------------------------------- -// Check a record consutrction expression +// Check a record construction expression and TcRecordConstruction cenv overallTy env tpenv optOrigExpr objTy fldsList m = let tcref = tcrefOfAppTy cenv.g objTy let tycon = tcref.Deref @@ -5953,9 +5953,10 @@ and TcRecordConstruction cenv overallTy env tpenv optOrigExpr objTy fldsList m = // Effect order - mutable fields may get modified by other bindings... let fieldNameUnbound nom = List.forall (fun (name,_) -> name <> nom) fldsList fspecs - |> List.filter (fun rfld -> rfld.Name |> fieldNameUnbound) - |> List.filter (fun f -> not f.IsZeroInit) - |> List.map (fun fspec ->fspec.Name, mkRecdFieldGet cenv.g (oldve',tcref.MakeNestedRecdFieldRef fspec,tinst,m)) + |> List.choose (fun rfld -> + if fieldNameUnbound rfld.Name && not rfld.IsZeroInit + then Some(rfld.Name, mkRecdFieldGet cenv.g (oldve',tcref.MakeNestedRecdFieldRef rfld,tinst,m)) + else None) let fldsList = fldsList @ oldFldsList @@ -6683,8 +6684,8 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let customOperationMethods = AllMethInfosOfTypeInScope cenv.infoReader env.NameEnv (None,ad) IgnoreOverrides mBuilderVal builderTy - |> List.filter (IsMethInfoAccessible cenv.amap mBuilderVal ad) |> List.choose (fun methInfo -> + if not (IsMethInfoAccessible cenv.amap mBuilderVal ad methInfo) then None else let nameSearch = TryBindMethInfoAttribute cenv.g mBuilderVal cenv.g.attrib_CustomOperationAttribute methInfo (fun _ -> None) // We do not respect this attribute for IL methods @@ -8847,9 +8848,8 @@ and TcMethodApplication let GenerateMatchingSimpleArgumentTypes (calledMeth:MethInfo) = let curriedMethodArgAttribs = calledMeth.GetParamAttribs(cenv.amap, mItem) - curriedMethodArgAttribs - |> List.map (List.filter isSimpleFormalArg) - |> List.map (NewInferenceTypes) + curriedMethodArgAttribs + |> List.map (List.filter isSimpleFormalArg >> NewInferenceTypes) let UnifyMatchingSimpleArgumentTypes exprTy (calledMeth:MethInfo) = let curriedArgTys = GenerateMatchingSimpleArgumentTypes calledMeth @@ -9043,8 +9043,7 @@ and TcMethodApplication let resultMinfo = result.Method let overridingInfo = overriding - |> List.filter (fun (minfo,_) -> minfo.IsVirtual) - |> List.tryFind (fun (minfo,_) -> MethInfosEquivByNameAndSig EraseNone true cenv.g cenv.amap range0 resultMinfo minfo) + |> List.tryFind (fun (minfo,_) -> minfo.IsVirtual && MethInfosEquivByNameAndSig EraseNone true cenv.g cenv.amap range0 resultMinfo minfo) match overridingInfo with | Some r -> r |> callSink | None -> (result.Method,result.AssociatedPropertyInfo) |> callSink @@ -11341,7 +11340,9 @@ let TcOpenDecl tcSink g amap m scopem env (longId : Ident list) = let modrefs = ForceRaise (TcModuleOrNamespaceLidAndPermitAutoResolve env amap longId) // validate opened namespace names - longId |> List.filter (fun id -> id.idText <> MangledGlobalName) |> List.iter (CheckNamespaceModuleOrTypeName g) + for id in longId do + if id.idText <> MangledGlobalName then + CheckNamespaceModuleOrTypeName g id let IsPartiallyQualifiedNamespace (modref: ModuleOrNamespaceRef) = let (CompPath(_,p)) = modref.CompilationPath @@ -12674,9 +12675,8 @@ module TyconBindingChecking = begin defnCs |> List.exists (function | PassCIncrClassBindings groups -> groups |> List.exists (function - | IncrClassBindingGroup(binds,isStatic,_) -> - let nonMethodBinds = binds |> List.filter (IncrClassReprInfo.IsMethodRepr cenv >> not) - isStatic && not nonMethodBinds.IsEmpty + | IncrClassBindingGroup(binds,isStatic,_) -> + isStatic && (binds |> List.exists (IncrClassReprInfo.IsMethodRepr cenv >> not)) | _ -> false) | _ -> false) @@ -14201,14 +14201,15 @@ module EstablishTypeDefinitionCores = begin let writeFakeRecordFieldsToSink (fields:RecdField list) = let nenv = envinner.NameEnv // Record fields should be visible from IntelliSense, so add fake names for them (similarly to "let a = ..") - for fspec in (fields |> List.filter (fun fspec -> not fspec.IsCompilerGenerated)) do - let info = RecdFieldInfo(thisTyInst, thisTyconRef.MakeNestedRecdFieldRef fspec) - let nenv' = AddFakeNameToNameEnv fspec.Name nenv (Item.RecdField info) - // Name resolution gives better info for tooltips - let item = FreshenRecdFieldRef cenv.nameResolver m (thisTyconRef.MakeNestedRecdFieldRef fspec) - CallNameResolutionSink cenv.tcSink (fspec.Range,nenv,item,item,ItemOccurence.Binding,envinner.DisplayEnv,ad) - // Environment is needed for completions - CallEnvSink cenv.tcSink (fspec.Range, nenv', ad) + for fspec in fields do + if not fspec.IsCompilerGenerated then + let info = RecdFieldInfo(thisTyInst, thisTyconRef.MakeNestedRecdFieldRef fspec) + let nenv' = AddFakeNameToNameEnv fspec.Name nenv (Item.RecdField info) + // Name resolution gives better info for tooltips + let item = FreshenRecdFieldRef cenv.nameResolver m (thisTyconRef.MakeNestedRecdFieldRef fspec) + CallNameResolutionSink cenv.tcSink (fspec.Range,nenv,item,item,ItemOccurence.Binding,envinner.DisplayEnv,ad) + // Environment is needed for completions + CallEnvSink cenv.tcSink (fspec.Range, nenv', ad) // Notify the Language Service about constructors in discriminated union declaration let writeFakeUnionCtorsToSink (unionCases: UnionCase list) =