From 0ab32aa75d5e94e4eab1876bb737f57086de4814 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 4 Jul 2016 16:37:44 +0100 Subject: [PATCH 1/4] Fix 1311 --- VisualFSharp.sln | 3 -- src/fsharp/CompileOps.fs | 11 ++++--- src/fsharp/NameResolution.fs | 47 ++++++++++++++++++------------ src/fsharp/TypeChecker.fs | 7 ++++- src/fsharp/vs/IncrementalBuild.fsi | 16 ++++++++-- 5 files changed, 53 insertions(+), 31 deletions(-) diff --git a/VisualFSharp.sln b/VisualFSharp.sln index 002dbd63f6b..6409c1433e2 100644 --- a/VisualFSharp.sln +++ b/VisualFSharp.sln @@ -126,9 +126,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProjectSection EndProject Global - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index f820d62d023..b537193c1fb 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -5076,12 +5076,11 @@ let GetInitialTcEnv (thisAssemblyName:string, initm:range, tcConfig:TcConfig, tc let tcEnv = CreateInitialTcEnv(tcGlobals, amap, initm, thisAssemblyName, ccus) - let tcEnv = - if tcConfig.checkOverflow then - TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName)) - else - tcEnv - tcEnv + if tcConfig.checkOverflow then + try TcOpenDecl TcResultsSink.NoSink tcGlobals amap initm initm tcEnv (pathToSynLid initm (splitNamespace FSharpLib.CoreOperatorsCheckedName)) + with e -> errorRecovery e initm; tcEnv + else + tcEnv //---------------------------------------------------------------------------- // Fault injection diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 52345ff8c43..98c73945dc0 100755 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -409,28 +409,37 @@ let private GetCSharpStyleIndexedExtensionMembersForTyconRef (amap:Import.Import // We don't use the index for the IL extension method for tuple of F# function types (e.g. if extension // methods for tuple occur in C# code) let thisTyconRef = - match metadataOfTycon tcrefOfStaticClass.Deref, minfo with - | ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) -> - match ilMethod.ParameterTypes with - | firstTy :: _ -> - match firstTy with - | ILType.Boxed tspec | ILType.Value tspec -> - let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m - if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None - else Some tcref + try + let rs = + match metadataOfTycon tcrefOfStaticClass.Deref, minfo with + | ILTypeMetadata (scoref,_), ILMeth(_,ILMethInfo(_,_,_,ilMethod,_),_) -> + match ilMethod.ParameterTypes with + | firstTy :: _ -> + match firstTy with + | ILType.Boxed tspec | ILType.Value tspec -> + let tcref = (tspec |> rescopeILTypeSpec scoref).TypeRef |> Import.ImportILTypeRef amap m + if isCompiledTupleTyconRef g tcref || tyconRefEq g tcref g.fastFunc_tcr then None + else Some tcref + | _ -> None | _ -> None - | _ -> None - | _ -> - // The results are indexed by the TyconRef of the first 'this' argument, if any. - // So we need to go and crack the type of the 'this' argument. - let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head - match thisTy with - | AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended - | _ -> None + | _ -> + // The results are indexed by the TyconRef of the first 'this' argument, if any. + // So we need to go and crack the type of the 'this' argument. + let thisTy = minfo.GetParamTypes(amap,m,generalizeTypars minfo.FormalMethodTypars).Head.Head + match thisTy with + | AppTy amap.g (tcrefOfTypeExtended, _) -> Some tcrefOfTypeExtended + | _ -> None + + Some rs + + with e -> // Import of the ILType may fail, if so report the error and skip on + errorRecovery e m + None match thisTyconRef with - | Some tcref -> yield Choice1Of2(tcref, ilExtMem) - | _ -> yield Choice2Of2 ilExtMem ] + | None -> () + | Some (Some tcref) -> yield Choice1Of2(tcref, ilExtMem) + | Some None -> yield Choice2Of2 ilExtMem ] else [] diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index b5da2a0281b..410c293bf27 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -16464,7 +16464,12 @@ let AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible) env let CreateInitialTcEnv(g,amap,scopem,assemblyName,ccus) = - List.fold (fun env (ccu,autoOpens,internalsVisible) -> AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible)) (emptyTcEnv g) ccus + (emptyTcEnv g, ccus) ||> List.fold (fun env (ccu,autoOpens,internalsVisible) -> + try + AddCcuToTcEnv(g,amap,scopem,env,assemblyName,ccu,autoOpens,internalsVisible) + with e -> + errorRecovery e scopem + env) type ConditionalDefines = string list diff --git a/src/fsharp/vs/IncrementalBuild.fsi b/src/fsharp/vs/IncrementalBuild.fsi index f78637d67bb..4e9c9835dc1 100755 --- a/src/fsharp/vs/IncrementalBuild.fsi +++ b/src/fsharp/vs/IncrementalBuild.fsi @@ -76,15 +76,27 @@ type internal CompilationErrorLogger = /// Represents the state in the incremental graph assocaited with checking a file type internal PartialCheckResults = - { TcState : TcState + { /// This field is None if a major unrecoverd error occured when preparing the initial state + TcState : TcState TcImports: TcImports TcGlobals: TcGlobals TcConfig: TcConfig - TcEnvAtEnd : TypeChecker.TcEnv + + /// This field is None if a major unrecoverd error occured when preparing the initial state + TcEnvAtEnd : TypeChecker.TcEnv + + /// Represents the collected errors from type checking Errors : (PhasedError * FSharpErrorSeverity) list + + /// Represents the collected name resolutions from type checking TcResolutions: TcResolutions list + + /// Represents the collected uses of symbols from type checking TcSymbolUses: TcSymbolUses list + + /// Represents the collected attributes to apply to the module of assuembly generates TopAttribs: TypeChecker.TopAttribs option + TimeStamp: DateTime } /// Manages an incremental build graph for the build of an F# project From 9f1116841eb9de5adf99dbe044ecced2fb64493b Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 4 Jul 2016 17:09:16 +0100 Subject: [PATCH 2/4] extend fix so reference is not needed --- src/fsharp/CompileOps.fs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index b537193c1fb..be6324c7905 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1612,25 +1612,27 @@ let GetFsiLibraryName () = "FSharp.Compiler.Interactive.Settings" // -- for orphaned files (files in VS without a project context) // -- for files given on a command line without --noframework set let DefaultBasicReferencesForOutOfProjectSources = - [ yield "System" + [ // These are .NET-Framework -style references + yield "System" yield "System.Xml" yield "System.Runtime.Remoting" yield "System.Runtime.Serialization.Formatters.Soap" yield "System.Data" yield "System.Drawing" - - // Don't reference System.Core for .NET 2.0 compilations. - // - // We only use a default reference to System.Core if one exists which we can load it into the compiler process. - // Note: this is not a partiuclarly good technique as it relying on the environment the compiler is executing in - // to determine the default references. However, System.Core will only fail to load on machines with only .NET 2.0, - // in which case the compiler will also be running as a .NET 2.0 process. - // - // NOTE: it seems this can now be removed now that .NET 4.x is minimally assumed when using this toolchain - if (try System.Reflection.Assembly.Load(new System.Reflection.AssemblyName("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")) |> ignore; true with _ -> false) then - yield "System.Core" + yield "System.Core" + + // These are the Portable-profile and .NET Core dependencies of FSharp.Core.dll. These are needed + // when an F# sript references an F# profile 7, 78, 259 or .NET Core component which in turn refers + // to FSharp.Core for profile 7, 78, 259 or .NET Core. + yield "System.Runtime" // lots of types + yield "System.Linq" // System.Linq.Expressions.Expression + yield "System.Reflection" // System.Reflection.ParameterInfo + yield "System.Linq.Expressions" // System.Linq.IQueryable + yield "System.Threading.Tasks" // valuetype [System.Threading.Tasks]System.Threading.CancellationToken + yield "System.IO" // System.IO.TextWriter + yield "System.Collections" // System.Collections.Generic.List + yield "System.Threading" // OperationCanceledException - yield "System.Runtime" yield "System.Web" yield "System.Web.Services" yield "System.Windows.Forms" ] From 5585e5509c480bf77ffcc5ea7d4723f71b5ae001 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Mon, 18 Jul 2016 11:17:10 +0100 Subject: [PATCH 3/4] Update CompileOps.fs --- src/fsharp/CompileOps.fs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index be6324c7905..0a30cf651ba 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1613,6 +1613,7 @@ let GetFsiLibraryName () = "FSharp.Compiler.Interactive.Settings" // -- for files given on a command line without --noframework set let DefaultBasicReferencesForOutOfProjectSources = [ // These are .NET-Framework -style references +#if !TODO_REWORK_ASSEMBLY_LOAD yield "System" yield "System.Xml" yield "System.Runtime.Remoting" @@ -1620,22 +1621,29 @@ let DefaultBasicReferencesForOutOfProjectSources = yield "System.Data" yield "System.Drawing" yield "System.Core" +#endif - // These are the Portable-profile and .NET Core dependencies of FSharp.Core.dll. These are needed - // when an F# sript references an F# profile 7, 78, 259 or .NET Core component which in turn refers - // to FSharp.Core for profile 7, 78, 259 or .NET Core. + // These are the Portable-profile and .NET Standard 1.6 dependencies of FSharp.Core.dll. These are needed + // when an F# sript references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers + // to FSharp.Core for profile 7, 78, 259 or .NET Standard. yield "System.Runtime" // lots of types yield "System.Linq" // System.Linq.Expressions.Expression yield "System.Reflection" // System.Reflection.ParameterInfo yield "System.Linq.Expressions" // System.Linq.IQueryable yield "System.Threading.Tasks" // valuetype [System.Threading.Tasks]System.Threading.CancellationToken yield "System.IO" // System.IO.TextWriter + yield "System.Console" // System.Console.Out etc. + yield "System.Net.Requests" // System.Net.WebResponse etc. yield "System.Collections" // System.Collections.Generic.List + yield "System.Runtime.Numerics" // BigInteger yield "System.Threading" // OperationCanceledException +#if !TODO_REWORK_ASSEMBLY_LOAD yield "System.Web" yield "System.Web.Services" - yield "System.Windows.Forms" ] + yield "System.Windows.Forms" +#endif + ] // Extra implicit references for .NET 4.0 let DefaultBasicReferencesForOutOfProjectSources40 = From 74474a1aad34baf585b1e4a6c109b9c2699e648a Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 21 Jul 2016 17:14:06 +0100 Subject: [PATCH 4/4] remove System.Console since facade not part of .NET 4.5.x or 4.6.x --- src/fsharp/CompileOps.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 2bc71616e1e..a457b874841 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1632,7 +1632,7 @@ let DefaultBasicReferencesForOutOfProjectSources = yield "System.Linq.Expressions" // System.Linq.IQueryable yield "System.Threading.Tasks" // valuetype [System.Threading.Tasks]System.Threading.CancellationToken yield "System.IO" // System.IO.TextWriter - yield "System.Console" // System.Console.Out etc. + //yield "System.Console" // System.Console.Out etc. yield "System.Net.Requests" // System.Net.WebResponse etc. yield "System.Collections" // System.Collections.Generic.List yield "System.Runtime.Numerics" // BigInteger