Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a43e09

Browse files
authored
Merge pull requestfsharp#811 from ninjarobot/integrate
integration from visualfsharp master
2 parentsfb2f8aa +7790c4d commit9a43e09

28 files changed

+109
-131
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,5 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
236236
/tests/fcs/
237237
/fcs/.paket/Paket.Restore.targets
238238
msbuild.binlog
239+
/fcs/FSharp.Compiler.Service.netstandard/*.fs
240+
/fcs/FSharp.Compiler.Service.netstandard/*.fsi

‎src/fsharp/FSComp.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ FieldNotContainedMutablesDiffer,"The module contains the field\n %s \nbut
161161
FieldNotContainedLiteralsDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe 'literal' modifiers differ"
162162
FieldNotContainedTypesDiffer,"The module contains the field\n %s \nbut its signature specifies\n %s \nThe types differ"
163163
331,typrelCannotResolveImplicitGenericInstantiation,"The implicit instantiation of a generic construct at or near this point could not be resolved because it could resolve to multiple unrelated types, e.g. '%s' and '%s'. Consider using type annotations to resolve the ambiguity"
164-
332,typrelCannotResolveAmbiguityInOverloadedOperator,"Could not resolve the ambiguity inherent in the use of the operator '%s' at or near this program point. Consider using type annotations to resolve the ambiguity."
165164
333,typrelCannotResolveAmbiguityInPrintf,"Could not resolve the ambiguity inherent in the use of a 'printf'-style format string"
166165
334,typrelCannotResolveAmbiguityInEnum,"Could not resolve the ambiguity in the use of a generic construct with an 'enum' constraint at or near this position"
167166
335,typrelCannotResolveAmbiguityInDelegate,"Could not resolve the ambiguity in the use of a generic construct with a 'delegate' constraint at or near this position"

‎src/fsharp/IlxGen.fs‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,8 +3747,8 @@ and GenClosureTypeDefs cenv (tref:ILTypeRef, ilGenParams, attrs, ilCloFreeVars,
37473747
Properties= emptyILProperties
37483748
Methods= mkILMethods mdefs
37493749
MethodImpls= mkILMethodImpls mimpls
3750-
IsSerializable= cenv.g.attrib_SerializableAttribute.IsSome
3751-
IsComInterop=false
3750+
IsSerializable=true
3751+
IsComInterop=false
37523752
IsSpecialName=true
37533753
NestedTypes=emptyILTypeDefs
37543754
Encoding= ILDefaultPInvokeEncoding.Auto
@@ -3803,8 +3803,8 @@ and GenLambdaClosure cenv (cgbuf:CodeGenBuffer) eenv isLocalTypeFunc selfv expr
38033803
Properties= emptyILProperties
38043804
Methods= mkILMethods ilContractMeths
38053805
MethodImpls= emptyILMethodImpls
3806-
IsSerializable= cenv.g.attrib_SerializableAttribute.IsSome
3807-
IsComInterop=false
3806+
IsSerializable=true
3807+
IsComInterop=false
38083808
IsSpecialName=true
38093809
NestedTypes=emptyILTypeDefs
38103810
Encoding= ILDefaultPInvokeEncoding.Auto
@@ -6563,9 +6563,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon:Tycon) =
65636563
letilFields= mkILFields ilFieldDefs
65646564

65656565
lettdef,tdefDiscards=
6566-
letisSerializable=(TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AutoSerializableAttribute tycon.Attribs<> Some(false))
6567-
&& cenv.g.attrib_SerializableAttribute.IsSome
6568-
6566+
letisSerializable=(TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AutoSerializableAttribute tycon.Attribs<> Some(false))
6567+
65696568
match tycon.TypeReprInfowith
65706569
| TILObjectRepr_->
65716570
lettd= tycon.ILTyconRawMetadata
@@ -6817,11 +6816,10 @@ and GenExnDef cenv mgbuf eenv m (exnc:Tycon) =
68176816
else
68186817
[]
68196818

6820-
68216819
letserializationRelatedMembers=
6822-
// do not emit serialization related members if target framework lacksSerializableAttribute orSerializationInfo
6823-
match cenv.g.attrib_SerializableAttribute, cenv.g.iltyp_SerializationInfo, cenv.g.iltyp_StreamingContextwith
6824-
| Some_, SomeserializationInfoType, Some streamingContextType->
6820+
// do not emit serialization related members if target framework lacksSerializationInfo orStreamingContext
6821+
match cenv.g.iltyp_SerializationInfo, cenv.g.iltyp_StreamingContextwith
6822+
| Some serializationInfoType, Some streamingContextType->
68256823
letilCtorDefForSerialziation=
68266824
mkILCtor(ILMemberAccess.Family,
68276825
[mkILParamNamed("info", serializationInfoType);mkILParamNamed("context",streamingContextType)],
@@ -6880,7 +6878,7 @@ and GenExnDef cenv mgbuf eenv m (exnc:Tycon) =
68806878
emptyILEvents,
68816879
mkILCustomAttrs[mkCompilationMappingAttr cenv.g(int SourceConstructFlags.Exception)],
68826880
ILTypeInit.BeforeField)
6883-
lettdef={ tdefwith IsSerializable=cenv.g.attrib_SerializableAttribute.IsSome}
6881+
lettdef={ tdefwith IsSerializable=true}
68846882
mgbuf.AddTypeDef(tref, tdef,false,false, None)
68856883

68866884

‎src/fsharp/TcGlobals.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
10051005
member valattrib_ProjectionParameterAttribute= mk_MFCore_attrib"ProjectionParameterAttribute"
10061006
member valattrib_CustomOperationAttribute= mk_MFCore_attrib"CustomOperationAttribute"
10071007
member valattrib_NonSerializedAttribute= tryFindSysAttrib"System.NonSerializedAttribute"
1008-
member valattrib_SerializableAttribute= tryFindSysAttrib"System.SerializableAttribute"
10091008

10101009
member valattrib_AutoSerializableAttribute= mk_MFCore_attrib"AutoSerializableAttribute"
10111010
member valattrib_RequireQualifiedAccessAttribute= mk_MFCore_attrib"RequireQualifiedAccessAttribute"

‎src/fsharp/TypeRelations.fs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ let ChooseTyparSolutionAndRange (g: TcGlobals) amap (tp:Typar) =
141141
match tpcwith
142142
| TyparConstraint.CoercesTo(x,m)->
143143
join m x,m
144-
| TyparConstraint.MayResolveMember(TTrait(_,nm,_,_,_,_),m)->
145-
errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInOverloadedOperator(DemangleOperatorName nm),m))
144+
| TyparConstraint.MayResolveMember(TTrait(_,_,_,_,_,_),m)->
146145
maxSoFar,m
147146
| TyparConstraint.SimpleChoice(_,m)->
148147
errorR(Error(FSComp.SR.typrelCannotResolveAmbiguityInPrintf(),m))

‎src/fsharp/fsc.fs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,12 +1968,10 @@ let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcCo
19681968
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.IlxGen
19691969
letilxGenerator= CreateIlxAssemblyGenerator(tcConfig, tcImports, tcGlobals,(LightweightTcValForUsingInBuildMethodCall tcGlobals), generatedCcu)
19701970

1971-
// Check if System.SerializableAttribute exists in mscorlib.dll,
1972-
// so that make sure the compiler only emits "serializable" bit into IL metadata when it is available.
1973-
// Note that SerializableAttribute may be relocated in the future but now resides in mscorlib.
19741971
letcodegenResults= GenerateIlxCode((if Option.isSome dynamicAssemblyCreatorthen IlReflectBackendelse IlWriteBackend), Option.isSome dynamicAssemblyCreator,false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator)
19751972
letcasApplied=new Dictionary<Stamp, bool>()
19761973
letsecurityAttrs,topAssemblyAttrs= topAttrs.assemblyAttrs|> List.partition(fun a-> TypeChecker.IsSecurityAttribute tcGlobals(tcImports.GetImportMap()) casApplied a rangeStartup)
1974+
19771975
// remove any security attributes from the top-level assembly attribute list
19781976
lettopAttrs={topAttrswith assemblyAttrs=topAssemblyAttrs}
19791977
letpermissionSets= ilxGenerator.CreatePermissionSets securityAttrs

‎src/fsharp/service/ServiceUntypedParse.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ module SourceFileImpl =
4141
0= String.Compare(".fsi",ext,StringComparison.OrdinalIgnoreCase)
4242

4343
/// Additional #defines that should be in place when editing a file in a file editor such as VS.
44-
letAdditionalDefinesForUseInEditor(filename)=
45-
ifCompileOps.IsScript(filename)then["INTERACTIVE";"EDITING"]// This is still used by the foreground parse
44+
letAdditionalDefinesForUseInEditor(isInteractive:bool)=
45+
ifisInteractivethen["INTERACTIVE";"EDITING"]// This is still used by the foreground parse
4646
else["COMPILED";"EDITING"]
4747

4848
typeCompletionPath= string list* string option// plid * residue

‎src/fsharp/service/ServiceUntypedParse.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ module public UntypedParseImpl =
112112
// implementation details used by other code in the compiler
113113
module internal SourceFileImpl=
114114
valIsInterfaceFile:string->bool
115-
valAdditionalDefinesForUseInEditor:string->string list
115+
valAdditionalDefinesForUseInEditor:isInteractive:bool->string list
116116

‎src/fsharp/service/service.fs‎

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,14 +1394,13 @@ type TypeCheckInfo
13941394
override__.ToString()="TypeCheckInfo("+ mainInputFileName+")"
13951395

13961396
typeFSharpParsingOptions=
1397-
{
1398-
SourceFiles:string[]
1397+
{ SourceFiles:string[]
13991398
ConditionalCompilationDefines:string list
14001399
ErrorSeverityOptions:FSharpErrorSeverityOptions
1400+
IsInteractive:bool
14011401
LightSyntax:bool option
14021402
CompilingFsLib:bool
1403-
IsExe:bool
1404-
}
1403+
IsExe:bool}
14051404

14061405
memberx.LastFileName=
14071406
Debug.Assert(not(Array.isEmpty x.SourceFiles),"Parsing options don't contain any file")
@@ -1411,26 +1410,26 @@ type FSharpParsingOptions =
14111410
{ SourceFiles= Array.empty
14121411
ConditionalCompilationDefines=[]
14131412
ErrorSeverityOptions= FSharpErrorSeverityOptions.Default
1413+
IsInteractive=false
14141414
LightSyntax= None
14151415
CompilingFsLib=false
1416-
IsExe=false
1417-
}
1416+
IsExe=false}
14181417

1419-
static memberFromTcConfig(tcConfig:TcConfig,sourceFiles)=
1420-
{
1421-
SourceFiles= sourceFiles
1418+
static memberFromTcConfig(tcConfig:TcConfig,sourceFiles,isInteractive:bool)=
1419+
{ SourceFiles= sourceFiles
14221420
ConditionalCompilationDefines= tcConfig.conditionalCompilationDefines
14231421
ErrorSeverityOptions= tcConfig.errorSeverityOptions
1422+
IsInteractive= isInteractive
14241423
LightSyntax= tcConfig.light
14251424
CompilingFsLib= tcConfig.compilingFslib
1426-
IsExe= tcConfig.target.IsExe
1427-
}
1425+
IsExe= tcConfig.target.IsExe}
14281426

1429-
static memberFromTcConfigBuidler(tcConfigB:TcConfigBuilder,sourceFiles)=
1427+
static memberFromTcConfigBuidler(tcConfigB:TcConfigBuilder,sourceFiles,isInteractive:bool)=
14301428
{
14311429
SourceFiles= sourceFiles
14321430
ConditionalCompilationDefines= tcConfigB.conditionalCompilationDefines
14331431
ErrorSeverityOptions= tcConfigB.errorSeverityOptions
1432+
IsInteractive= isInteractive
14341433
LightSyntax= tcConfigB.light
14351434
CompilingFsLib= tcConfigB.compilingFslib
14361435
IsExe= tcConfigB.target.IsExe
@@ -1502,7 +1501,7 @@ module internal Parser =
15021501

15031502
// If we're editing a script then we define INTERACTIVE otherwise COMPILED.
15041503
// Since this parsing for intellisense we always define EDITING.
1505-
letdefines= SourceFileImpl.AdditionalDefinesForUseInEditor(fileName)@ options.ConditionalCompilationDefines
1504+
letdefines=(SourceFileImpl.AdditionalDefinesForUseInEditor options.IsInteractive)@ options.ConditionalCompilationDefines
15061505

15071506
// Note: we don't really attempt to intern strings across a large scope.
15081507
letlexResourceManager=new Lexhelp.LexResourceManager()
@@ -1521,6 +1520,12 @@ module internal Parser =
15211520

15221521
letmatchBraces(source,fileName,options:FSharpParsingOptions,userOpName:string)=
15231522
Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName,"matchBraces", fileName)
1523+
1524+
// Make sure there is an ErrorLogger installed whenever we do stuff that might record errors, even if we ultimately ignore the errors
1525+
letdelayedLogger= CapturingErrorLogger("matchBraces")
1526+
use _unwindEL= PushErrorLoggerPhaseUntilUnwind(fun _-> delayedLogger)
1527+
use _unwindBP= PushThreadBuildPhaseUntilUnwind BuildPhase.Parse
1528+
15241529
letmatchingBraces=new ResizeArray<_>()
15251530
Lexhelp.usingLexbufForParsing(UnicodeLexing.StringAsLexbuf(addNewLine source), fileName)(fun lexbuf->
15261531
leterrHandler= ErrorHandler(false, fileName, options.ErrorSeverityOptions, source)
@@ -2514,7 +2519,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
25142519
let!tcErrors,tcFileResult=
25152520
Parser.CheckOneFile(parseResults, source, fileName, options.ProjectFileName, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports,
25162521
tcPrior.TcState, loadClosure, tcPrior.Errors, reactorOps,(fun()-> builder.IsAlive), textSnapshotInfo, userOpName)
2517-
letparsingOptions= FSharpParsingOptions.FromTcConfig(tcPrior.TcConfig, Array.ofList builder.SourceFiles)
2522+
letparsingOptions= FSharpParsingOptions.FromTcConfig(tcPrior.TcConfig, Array.ofList builder.SourceFiles, options.UseScriptResolutionRules)
25182523
letcheckAnswer= MakeCheckFileAnswer(fileName, tcFileResult, options, builder, Array.ofList tcPrior.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors)
25192524
bc.RecordTypeCheckFileInProjectResults(fileName, options, parsingOptions, parseResults, fileVersion, tcPrior.TimeStamp, Some checkAnswer, source)
25202525
return checkAnswer
@@ -2628,7 +2633,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
26282633
let!tcPrior= execWithReactorAsync<|fun ctok-> builder.GetCheckResultsBeforeFileInProject(ctok, filename)
26292634

26302635
// Do the parsing.
2631-
letparsingOptions= FSharpParsingOptions.FromTcConfig(builder.TcConfig, Array.ofList(builder.SourceFiles))
2636+
letparsingOptions= FSharpParsingOptions.FromTcConfig(builder.TcConfig, Array.ofList(builder.SourceFiles), options.UseScriptResolutionRules)
26322637
letparseErrors,parseTreeOpt,anyErrors= Parser.parseFile(source, filename, parsingOptions, userOpName)
26332638
letparseTreeOpt= parseTreeOpt|> Option.map builder.DeduplicateParsedInputModuleNameInProject
26342639
letparseResults= FSharpParseFileResults(parseErrors, parseTreeOpt, anyErrors, builder.AllDependenciesDeprecated)
@@ -2908,7 +2913,7 @@ type FSharpChecker(legacyReferenceResolver, projectCacheSize, keepAssemblyConten
29082913
memberic.GetParsingOptionsFromProjectOptions(options):FSharpParsingOptions* _=
29092914
letsourceFiles= List.ofArray options.SourceFiles
29102915
letargv= List.ofArray options.OtherOptions
2911-
ic.GetParsingOptionsFromCommandLineArgs(sourceFiles, argv)
2916+
ic.GetParsingOptionsFromCommandLineArgs(sourceFiles, argv, options.UseScriptResolutionRules)
29122917

29132918
memberic.MatchBraces(filename,source,options:FSharpProjectOptions,?userOpName:string)=
29142919
letuserOpName= defaultArg userOpName"Unknown"
@@ -3111,16 +3116,17 @@ type FSharpChecker(legacyReferenceResolver, projectCacheSize, keepAssemblyConten
31113116
ExtraProjectInfo=extraProjectInfo
31123117
Stamp= None}
31133118

3114-
memberic.GetParsingOptionsFromCommandLineArgs(initialSourceFiles,argv)=
3119+
memberic.GetParsingOptionsFromCommandLineArgs(initialSourceFiles,argv,?isInteractive)=
3120+
letisInteractive= defaultArg isInteractivefalse
31153121
use errorScope=new ErrorScope()
31163122
lettcConfigBuilder= TcConfigBuilder.Initial
31173123

31183124
// Apply command-line arguments and collect more source files if they are in the arguments
31193125
letsourceFilesNew= ApplyCommandLineArgs(tcConfigBuilder, initialSourceFiles, argv)
3120-
FSharpParsingOptions.FromTcConfigBuidler(tcConfigBuilder, Array.ofList sourceFilesNew), errorScope.Diagnostics
3126+
FSharpParsingOptions.FromTcConfigBuidler(tcConfigBuilder, Array.ofList sourceFilesNew, isInteractive), errorScope.Diagnostics
31213127

3122-
memberic.GetParsingOptionsFromCommandLineArgs(argv)=
3123-
ic.GetParsingOptionsFromCommandLineArgs([], argv)
3128+
memberic.GetParsingOptionsFromCommandLineArgs(argv,?isInteractive:bool)=
3129+
ic.GetParsingOptionsFromCommandLineArgs([], argv, ?isInteractive=isInteractive)
31243130

31253131
/// Begin background parsing the given project.
31263132
memberic.StartBackgroundCompile(options,?userOpName)=
@@ -3191,7 +3197,7 @@ type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperatio
31913197
letuserOpName= defaultArg userOpName"Unknown"
31923198
letfilename= Path.Combine(tcConfig.implicitIncludeDir,"stdin.fsx")
31933199
// Note: projectSourceFiles is only used to compute isLastCompiland, and is ignored if Build.IsScript(mainInputFileName) is true (which it is in this case).
3194-
letparsingOptions= FSharpParsingOptions.FromTcConfig(tcConfig,[| filename|])
3200+
letparsingOptions= FSharpParsingOptions.FromTcConfig(tcConfig,[| filename|],true)
31953201
letparseErrors,parseTreeOpt,anyErrors= Parser.parseFile(source, filename, parsingOptions, userOpName)
31963202
letdependencyFiles=[||]// interactions have no dependencies
31973203
letparseResults= FSharpParseFileResults(parseErrors, parseTreeOpt, parseHadErrors= anyErrors, dependencyFiles= dependencyFiles)
@@ -3234,8 +3240,8 @@ module CompilerEnvironment =
32343240
letDefaultReferencesForOrphanSources(assumeDotNetFramework)= DefaultReferencesForScriptsAndOutOfProjectSources(assumeDotNetFramework)
32353241

32363242
/// Publish compiler-flags parsing logic. Must be fast because its used by the colorizer.
3237-
letGetCompilationDefinesForEditing(filename:string,parsingOptions:FSharpParsingOptions)=
3238-
SourceFileImpl.AdditionalDefinesForUseInEditor(filename)@
3243+
letGetCompilationDefinesForEditing(parsingOptions:FSharpParsingOptions)=
3244+
SourceFileImpl.AdditionalDefinesForUseInEditor(parsingOptions.IsInteractive)@
32393245
parsingOptions.ConditionalCompilationDefines
32403246

32413247
/// Return true if this is a subcategory of error or warning message that the language service can emit

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp