@@ -368,6 +368,8 @@ type CompileLocation =
368368 Enclosing: string list
369369
370370 QualifiedNameOfFile: string
371+
372+ Range: range
371373 }
372374
373375//--------------------------------------------------------------------------
@@ -388,6 +390,7 @@ let CompLocForFragment fragName (ccu: CcuThunk) =
388390 Scope = ccu.ILScopeRef
389391 Namespace = None
390392 Enclosing = []
393+ Range = range0
391394 }
392395
393396let CompLocForCcu (ccu: CcuThunk) = CompLocForFragment ccu.AssemblyName ccu
@@ -406,7 +409,7 @@ let CompLocForSubModuleOrNamespace cloc (submod: ModuleOrNamespace) =
406409 Namespace = Some(mkTopName cloc.Namespace n)
407410 }
408411
409- let CompLocForFixedPath fragName qname (CompPath(sref, _, cpath)) =
412+ let CompLocForFixedPath fragName qname m (CompPath(sref, _, cpath)) =
410413 let ns, t =
411414 cpath
412415 |> List.takeUntil (fun (_, mkind) ->
@@ -425,10 +428,11 @@ let CompLocForFixedPath fragName qname (CompPath(sref, _, cpath)) =
425428 Scope = sref
426429 Namespace = ns
427430 Enclosing = encl
431+ Range = m
428432 }
429433
430434let CompLocForFixedModule fragName qname (mspec: ModuleOrNamespace) =
431- let cloc = CompLocForFixedPath fragName qname mspec.CompilationPath
435+ let cloc = CompLocForFixedPath fragName qname mspec.Range mspec. CompilationPath
432436 let cloc = CompLocForSubModuleOrNamespace cloc mspec
433437 cloc
434438
@@ -2333,8 +2337,11 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf
23332337 MemoizationTable<CompileLocation * int, ILTypeSpec>(
23342338 "rawDataValueTypeGenerator",
23352339 (fun (cloc, size) ->
2336- let name =
2337- CompilerGeneratedName("T" + string (newUnique ()) + "_" + string size + "Bytes") // Type names ending ...$T<unique>_37Bytes
2340+
2341+ let unique =
2342+ g.CompilerGlobalState.Value.IlxGenNiceNameGenerator.IncrementOnly("@T", cloc.Range)
2343+
2344+ let name = CompilerGeneratedName $"T{unique}_{size}Bytes" // Type names ending ...$T<unique>_37Bytes
23382345
23392346 let vtdef = mkRawDataValueTypeDef g.iltyp_ValueType (name, size, 0us)
23402347 let vtref = NestedTypeRefForCompLoc cloc vtdef.Name
@@ -2390,7 +2397,12 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf
23902397 // Byte array literals require a ValueType of size the required number of bytes.
23912398 // With fsi.exe, S.R.Emit TypeBuilder CreateType has restrictions when a ValueType VT is nested inside a type T, and T has a field of type VT.
23922399 // To avoid this situation, these ValueTypes are generated under the private implementation rather than in the current cloc. [was bug 1532].
2393- let cloc = CompLocForPrivateImplementationDetails cloc
2400+ let cloc =
2401+ if cenv.options.isInteractive then
2402+ CompLocForPrivateImplementationDetails cloc
2403+ else
2404+ cloc
2405+
23942406 rawDataValueTypeGenerator.Apply((cloc, size))
23952407
23962408 member _.GenerateAnonType(genToStringMethod, anonInfo: AnonRecdTypeInfo) =
@@ -2754,7 +2766,11 @@ let GenConstArray cenv (cgbuf: CodeGenBuffer) eenv ilElementType (data: 'a[]) (w
27542766 CG.EmitInstrs cgbuf (pop 0) (Push [ ilArrayType ]) [ mkLdcInt32 0; I_newarr(ILArrayShape.SingleDimensional, ilElementType) ]
27552767 else
27562768 let vtspec = cgbuf.mgbuf.GenerateRawDataValueType(eenv.cloc, bytes.Length)
2757- let ilFieldName = CompilerGeneratedName("field" + string (newUnique ()))
2769+ //let fi = eenv.cloc.Range.FileIndex
2770+ let unique =
2771+ g.CompilerGlobalState.Value.IlxGenNiceNameGenerator.IncrementOnly("@field", eenv.cloc.Range)
2772+
2773+ let ilFieldName = CompilerGeneratedName $"field{unique}"
27582774 let fty = ILType.Value vtspec
27592775
27602776 let ilFieldDef =
@@ -10417,6 +10433,7 @@ and GenImplFile cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (implFile: Checke
1041710433 cloc =
1041810434 { eenv.cloc with
1041910435 TopImplQualifiedName = qname.Text
10436+ Range = m
1042010437 }
1042110438 }
1042210439
0 commit comments