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

Commiteb75fcc

Browse files
authored
Fix de-duplication of module names (dotnet#6086)
* possible fix for signature issue* fix de-duplication
1 parent03e8aa5 commiteb75fcc

File tree

8 files changed

+136
-114
lines changed

8 files changed

+136
-114
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,34 +3520,37 @@ let PostParseModuleSpecs (defaultNamespace, filename, isLastCompiland, ParsedSig
35203520

35213521
ParsedInput.SigFile(ParsedSigFileInput(filename, qualName, scopedPragmas, hashDirectives, specs))
35223522

3523+
typeModuleNamesDict= Map<string,Map<string,QualifiedNameOfFile>>
3524+
35233525
/// Checks if a module name is already given and deduplicates the name if needed.
3524-
letDeduplicateModuleName(moduleNamesDict:IDictionary<string,Set<string>>)(paths:Set<string>)path(qualifiedNameOfFile:QualifiedNameOfFile)=
3525-
letcount=if paths.Contains paththen paths.Countelse paths.Count+1
3526-
moduleNamesDict.[qualifiedNameOfFile.Text]<- Set.add path paths
3527-
letid= qualifiedNameOfFile.Id
3528-
if count=1then qualifiedNameOfFileelse QualifiedNameOfFile(Ident(id.idText+"___"+ count.ToString(), id.idRange))
3526+
letDeduplicateModuleName(moduleNamesDict:ModuleNamesDict)fileName(qualNameOfFile:QualifiedNameOfFile)=
3527+
letpath= Path.GetDirectoryName fileName
3528+
letpath=if FileSystem.IsPathRootedShim paththentry FileSystem.GetFullPathShim pathwith_-> pathelse path
3529+
match moduleNamesDict.TryGetValue qualNameOfFile.Textwith
3530+
|true, paths->
3531+
if paths.ContainsKey paththen
3532+
paths.[path], moduleNamesDict
3533+
else
3534+
letcount= paths.Count+1
3535+
letid= qualNameOfFile.Id
3536+
letqualNameOfFileT=if count=1then qualNameOfFileelse QualifiedNameOfFile(Ident(id.idText+"___"+ count.ToString(), id.idRange))
3537+
letmoduleNamesDictT= moduleNamesDict.Add(qualNameOfFile.Text, paths.Add(path, qualNameOfFileT))
3538+
qualNameOfFileT, moduleNamesDictT
3539+
|_->
3540+
letmoduleNamesDictT= moduleNamesDict.Add(qualNameOfFile.Text, Map.empty.Add(path, qualNameOfFile))
3541+
qualNameOfFile, moduleNamesDictT
35293542

35303543
/// Checks if a ParsedInput is using a module name that was already given and deduplicates the name if needed.
3531-
letDeduplicateParsedInputModuleName(moduleNamesDict:IDictionary<string,Set<string>>)input=
3544+
letDeduplicateParsedInputModuleName(moduleNamesDict:ModuleNamesDict)input=
35323545
match inputwith
3533-
| ParsedInput.ImplFile(ParsedImplFileInput.ParsedImplFileInput(fileName, isScript, qualifiedNameOfFile, scopedPragmas, hashDirectives, modules,(isLastCompiland, isExe)))->
3534-
letpath= Path.GetDirectoryName fileName
3535-
match moduleNamesDict.TryGetValue qualifiedNameOfFile.Textwith
3536-
|true, paths->
3537-
letqualifiedNameOfFile= DeduplicateModuleName moduleNamesDict paths path qualifiedNameOfFile
3538-
ParsedInput.ImplFile(ParsedImplFileInput.ParsedImplFileInput(fileName, isScript, qualifiedNameOfFile, scopedPragmas, hashDirectives, modules,(isLastCompiland, isExe)))
3539-
|_->
3540-
moduleNamesDict.[qualifiedNameOfFile.Text]<- Set.singleton path
3541-
input
3542-
| ParsedInput.SigFile(ParsedSigFileInput.ParsedSigFileInput(fileName, qualifiedNameOfFile, scopedPragmas, hashDirectives, modules))->
3543-
letpath= Path.GetDirectoryName fileName
3544-
match moduleNamesDict.TryGetValue qualifiedNameOfFile.Textwith
3545-
|true, paths->
3546-
letqualifiedNameOfFile= DeduplicateModuleName moduleNamesDict paths path qualifiedNameOfFile
3547-
ParsedInput.SigFile(ParsedSigFileInput.ParsedSigFileInput(fileName, qualifiedNameOfFile, scopedPragmas, hashDirectives, modules))
3548-
|_->
3549-
moduleNamesDict.[qualifiedNameOfFile.Text]<- Set.singleton path
3550-
input
3546+
| ParsedInput.ImplFile(ParsedImplFileInput.ParsedImplFileInput(fileName, isScript, qualNameOfFile, scopedPragmas, hashDirectives, modules,(isLastCompiland, isExe)))->
3547+
letqualNameOfFileT,moduleNamesDictT= DeduplicateModuleName moduleNamesDict fileName qualNameOfFile
3548+
letinputT= ParsedInput.ImplFile(ParsedImplFileInput.ParsedImplFileInput(fileName, isScript, qualNameOfFileT, scopedPragmas, hashDirectives, modules,(isLastCompiland, isExe)))
3549+
inputT, moduleNamesDictT
3550+
| ParsedInput.SigFile(ParsedSigFileInput.ParsedSigFileInput(fileName, qualNameOfFile, scopedPragmas, hashDirectives, modules))->
3551+
letqualNameOfFileT,moduleNamesDictT= DeduplicateModuleName moduleNamesDict fileName qualNameOfFile
3552+
letinputT= ParsedInput.SigFile(ParsedSigFileInput.ParsedSigFileInput(fileName, qualNameOfFileT, scopedPragmas, hashDirectives, modules))
3553+
inputT, moduleNamesDictT
35513554

35523555
letParseInput(lexer,errorLogger:ErrorLogger,lexbuf:UnicodeLexing.Lexbuf,defaultNamespace,filename,isLastCompiland)=
35533556
// The assert below is almost ok, but it fires in two cases:

‎src/fsharp/CompileOps.fsi‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ val ComputeQualifiedNameOfFileFromUniquePath: range * string list -> Ast.Qualifi
5959

6060
val PrependPathToInput: Ast.Ident list-> Ast.ParsedInput-> Ast.ParsedInput
6161

62-
///Checks if amodulename is already given and deduplicates the name if needed.
63-
val DeduplicateModuleName: IDictionary<string,Set<string>>-> Set<string>-> string-> Ast.QualifiedNameOfFile-> Ast.QualifiedNameOfFile
62+
///State used to de-deuplicatemodulenames along a list of file names
63+
type ModuleNamesDict=Map<string,Map<string,QualifiedNameOfFile>>
6464

6565
/// Checks if a ParsedInput is using a module name that was already given and deduplicates the name if needed.
66-
val DeduplicateParsedInputModuleName:IDictionary<string,Set<string>>-> Ast.ParsedInput-> Ast.ParsedInput
66+
valDeduplicateParsedInputModuleName:ModuleNamesDict->Ast.ParsedInput->Ast.ParsedInput* ModuleNamesDict
6767

68+
/// Parse a single input(A signature file or implementation file)
6869
val ParseInput:(UnicodeLexing.Lexbuf-> Parser.token)* ErrorLogger* UnicodeLexing.Lexbuf* string option* string* isLastCompiland:(bool* bool)-> Ast.ParsedInput
6970

7071
//----------------------------------------------------------------------------

‎src/fsharp/TypeChecker.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10060,7 +10060,7 @@ and TcMethodApplication
1006010060
| CallerLineNumber, _ when typeEquiv cenv.g currCalledArgTy cenv.g.int_ty ->
1006110061
emptyPreBinder, Expr.Const(Const.Int32(mMethExpr.StartLine), mMethExpr, currCalledArgTy)
1006210062
| CallerFilePath, _ when typeEquiv cenv.g currCalledArgTy cenv.g.string_ty ->
10063-
emptyPreBinder, Expr.Const(Const.String(System.IO.Path.GetFullPath(mMethExpr.FileName)), mMethExpr, currCalledArgTy)
10063+
emptyPreBinder, Expr.Const(Const.String(FileSystem.GetFullPathShim(mMethExpr.FileName)), mMethExpr, currCalledArgTy)
1006410064
| CallerMemberName, Some(callerName) when (typeEquiv cenv.g currCalledArgTy cenv.g.string_ty) ->
1006510065
emptyPreBinder, Expr.Const(Const.String(callerName), mMethExpr, currCalledArgTy)
1006610066
| _ ->
@@ -10099,7 +10099,7 @@ and TcMethodApplication
1009910099
let lineExpr = Expr.Const(Const.Int32(mMethExpr.StartLine), mMethExpr, calledNonOptTy)
1010010100
emptyPreBinder, mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [lineExpr], mMethExpr)
1010110101
| CallerFilePath, _ when typeEquiv cenv.g calledNonOptTy cenv.g.string_ty ->
10102-
let filePathExpr = Expr.Const(Const.String(System.IO.Path.GetFullPath(mMethExpr.FileName)), mMethExpr, calledNonOptTy)
10102+
let filePathExpr = Expr.Const(Const.String(FileSystem.GetFullPathShim(mMethExpr.FileName)), mMethExpr, calledNonOptTy)
1010310103
emptyPreBinder, mkUnionCaseExpr(mkSomeCase cenv.g, [calledNonOptTy], [filePathExpr], mMethExpr)
1010410104
| CallerMemberName, Some(callerName) when typeEquiv cenv.g calledNonOptTy cenv.g.string_ty ->
1010510105
let memberNameExpr = Expr.Const(Const.String(callerName), mMethExpr, calledNonOptTy)

‎src/fsharp/fsc.fs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,11 +1773,9 @@ let main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemor
17731773
errorRecoveryNoRange e
17741774
exiter.Exit1
17751775

1776-
letinputs=
1777-
// Deduplicate module names
1778-
letmoduleNamesDict= ConcurrentDictionary<string,Set<string>>()
1779-
inputs
1780-
|> List.map(fun(input,x)-> DeduplicateParsedInputModuleName moduleNamesDict input,x)
1776+
letinputs,_=
1777+
(Map.empty, inputs)
1778+
||> List.mapFold(fun state(input,x)->letinputT,stateT= DeduplicateParsedInputModuleName state inputin(inputT,x), stateT)
17811779

17821780
if tcConfig.parseOnlythen exiter.Exit0
17831781
ifnot tcConfig.continueAfterParseFailurethen
@@ -2036,7 +2034,7 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, tcImports: TcImports, t
20362034

20372035
DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok
20382036

2039-
letpdbfile= pdbfile|> Option.map(tcConfig.MakePathAbsolute>>Path.GetFullPath)
2037+
letpdbfile= pdbfile|> Option.map(tcConfig.MakePathAbsolute>>FileSystem.GetFullPathShim)
20402038

20412039
letnormalizeAssemblyRefs(aref:ILAssemblyRef)=
20422040
match tcImports.TryFindDllInfo(ctok, Range.rangeStartup, aref.Name, lookupOnly=false)with

‎src/fsharp/range.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ type range(code1:int64, code2: int64) =
197197

198198
letmkRange f b e=
199199
// remove relative parts from full path
200-
letnormalizedFilePath=ifPath.IsPathRooted fthentryPath.GetFullPath fwith_-> felse f
200+
letnormalizedFilePath=ifFileSystem.IsPathRootedShim fthentryFileSystem.GetFullPathShim fwith_-> felse f
201201
range(fileIndexOfFile normalizedFilePath, b, e)
202202

203203
letmkFileIndexRange fi b e= range(fi, b, e)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp