Skip to content

Commit b3d46d4

Browse files
dsymeDon Syme
and
Don Syme
authored
Printing updates (#12072)
* printing updates * printing updates * fix tests * fix tests * Print 'abstract' instead of 'abstract member' * Print 'abstract' instead of 'abstract member' * update tests * simplify code for laying out type definitions * adjust tests * fix printing of backtick and operator identifiers * update tests * update more tests * multi-line curried signature formatting * don't print literals twice * fix tests * fix tests * fix names in completion list * systematize the demangling (DisplayNameCore) and addition of parens/backticks (DisplayName) * fix a test case * update baseline * fix signature generation and re-enable tests * fix list completion * fix list completion * always show [<Struct>] * always show [<Struct>] Co-authored-by: Don Syme <donsyme@fastmail.com>
1 parent 2d4cc88 commit b3d46d4

File tree

318 files changed

+9200
-9573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+9200
-9573
lines changed

FSharp.sln

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ EndProject
2525
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}"
2626
EndProject
2727
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
28+
ProjectSection(ProjectDependencies) = postProject
29+
{D0E98C0D-490B-4C61-9329-0862F6E87645} = {D0E98C0D-490B-4C61-9329-0862F6E87645}
30+
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B} = {8B3E283D-B5FE-4055-9D80-7E3A32F3967B}
31+
{C94C257C-3C0A-4858-B5D8-D746498D1F08} = {C94C257C-3C0A-4858-B5D8-D746498D1F08}
32+
EndProjectSection
2833
EndProject
2934
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
3035
EndProject

VisualFSharp.sln

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ EndProject
8787
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}"
8888
EndProject
8989
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
90+
ProjectSection(ProjectDependencies) = postProject
91+
{D0E98C0D-490B-4C61-9329-0862F6E87645} = {D0E98C0D-490B-4C61-9329-0862F6E87645}
92+
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B} = {8B3E283D-B5FE-4055-9D80-7E3A32F3967B}
93+
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236} = {2E60864A-E3FF-4BCC-810F-DC7C34E6B236}
94+
{C94C257C-3C0A-4858-B5D8-D746498D1F08} = {C94C257C-3C0A-4858-B5D8-D746498D1F08}
95+
EndProjectSection
9096
EndProject
9197
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
9298
EndProject

src/fsharp/AttributeChecking.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ let MethInfoIsUnseen g (m: range) (ty: TType) minfo =
434434
isObjTy g minfo.ApparentEnclosingType &&
435435
let tcref = tcrefOfAppTy g ty
436436
match tcref.TypeReprInfo with
437-
| TProvidedTypeExtensionPoint info ->
437+
| TProvidedTypeRepr info ->
438438
info.ProvidedType.PUntaint((fun st -> (st :> IProvidedCustomAttributeProvider).GetHasTypeProviderEditorHideMethodsAttribute(info.ProvidedType.TypeProvider.PUntaintNoFailure(id))), m)
439439
| _ ->
440440
// This attribute check is done by name to ensure compilation doesn't take a dependency

src/fsharp/CheckDeclarations.fs

+28-26
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ module TcRecdUnionAndEnumDeclarations =
455455
let ValidateFieldNames (synFields: SynField list, tastFields: RecdField list) =
456456
let seen = Dictionary()
457457
(synFields, tastFields) ||> List.iter2 (fun sf f ->
458-
match seen.TryGetValue f.Name with
458+
match seen.TryGetValue f.LogicalName with
459459
| true, synField ->
460460
match sf, synField with
461461
| SynField(_, _, Some id, _, _, _, _, _), SynField(_, _, Some _, _, _, _, _, _) ->
@@ -465,7 +465,7 @@ module TcRecdUnionAndEnumDeclarations =
465465
error(Error(FSComp.SR.tcFieldNameConflictsWithGeneratedNameForAnonymousField(id.idText), id.idRange))
466466
| _ -> assert false
467467
| _ ->
468-
seen.Add(f.Name, sf))
468+
seen.Add(f.LogicalName, sf))
469469

470470
let TcUnionCaseDecl cenv env parent thisTy thisTyInst tpenv (SynUnionCase(Attributes synAttrs, id, args, xmldoc, vis, m)) =
471471
let attrs = TcAttributes cenv env AttributeTargets.UnionCaseDecl synAttrs // the attributes of a union case decl get attached to the generated "static factory" method
@@ -503,7 +503,7 @@ module TcRecdUnionAndEnumDeclarations =
503503
if not (typeEquiv cenv.g recordTy thisTy) then
504504
error(Error(FSComp.SR.tcReturnTypesForUnionMustBeSameAsType(), m))
505505
rfields, recordTy
506-
let names = rfields |> List.map (fun f -> f.Name)
506+
let names = rfields |> List.map (fun f -> f.DisplayNameCore)
507507
let doc = xmldoc.ToXmlDoc(true, Some names)
508508
Construct.NewUnionCase id rfields recordTy attrs doc vis
509509

@@ -1379,7 +1379,7 @@ module IncrClassChecking =
13791379
[ for b in memberBinds do
13801380
yield b.Var.CompiledName cenv.g.CompilerGlobalState
13811381
yield b.Var.DisplayName
1382-
yield b.Var.CoreDisplayName
1382+
yield b.Var.DisplayNameCoreMangled
13831383
yield b.Var.LogicalName ]
13841384
let reps = IncrClassReprInfo.Empty(g, takenFieldNames)
13851385

@@ -2040,7 +2040,7 @@ module MutRecBindingChecking =
20402040

20412041
if needsSafeStaticInit && hasStaticBindings then
20422042
let rfield = MakeSafeInitField g envForDecls tcref.Range true
2043-
SafeInitField(mkRecdFieldRef tcref rfield.Name, rfield)
2043+
SafeInitField(mkRecdFieldRef tcref rfield.LogicalName, rfield)
20442044
else
20452045
NoSafeInitInfo
20462046

@@ -3147,7 +3147,7 @@ module EstablishTypeDefinitionCores =
31473147
if InstanceMembersNeedSafeInitCheck cenv m thisTy then
31483148
let rfield = MakeSafeInitField cenv.g env m false
31493149
let tcref = tcrefOfAppTy cenv.g thisTy
3150-
SafeInitField (mkRecdFieldRef tcref rfield.Name, rfield)
3150+
SafeInitField (mkRecdFieldRef tcref rfield.LogicalName, rfield)
31513151
else
31523152
NoSafeInitInfo
31533153

@@ -3321,7 +3321,7 @@ module EstablishTypeDefinitionCores =
33213321
if not inSig && not hasMeasureAttr then
33223322
errorR(Error(FSComp.SR.tcTypeRequiresDefinition(), m))
33233323
if hasMeasureAttr then
3324-
TFSharpObjectRepr { fsobjmodel_kind = TTyconClass
3324+
TFSharpObjectRepr { fsobjmodel_kind = TFSharpClass
33253325
fsobjmodel_vslots = []
33263326
fsobjmodel_rfields = Construct.MakeRecdFieldsTable [] }
33273327
else
@@ -3353,7 +3353,7 @@ module EstablishTypeDefinitionCores =
33533353
InferTyconKind cenv.g (SynTypeDefnKind.Record, attrs, [], [], inSig, true, m) |> ignore
33543354

33553355
// Note: the table of record fields is initially empty
3356-
TRecdRepr (Construct.MakeRecdFieldsTable [])
3356+
TFSharpRecdRepr (Construct.MakeRecdFieldsTable [])
33573357

33583358
| SynTypeDefnSimpleRepr.General (kind, _, slotsigs, fields, isConcrete, _, _, _) ->
33593359
let kind = InferTyconKind cenv.g (kind, attrs, slotsigs, fields, inSig, isConcrete, m)
@@ -3363,10 +3363,10 @@ module EstablishTypeDefinitionCores =
33633363
| _ ->
33643364
let kind =
33653365
match kind with
3366-
| SynTypeDefnKind.Class -> TTyconClass
3367-
| SynTypeDefnKind.Interface -> TTyconInterface
3368-
| SynTypeDefnKind.Delegate _ -> TTyconDelegate (MakeSlotSig("Invoke", cenv.g.unit_ty, [], [], [], None))
3369-
| SynTypeDefnKind.Struct -> TTyconStruct
3366+
| SynTypeDefnKind.Class -> TFSharpClass
3367+
| SynTypeDefnKind.Interface -> TFSharpInterface
3368+
| SynTypeDefnKind.Delegate _ -> TFSharpDelegate (MakeSlotSig("Invoke", cenv.g.unit_ty, [], [], [], None))
3369+
| SynTypeDefnKind.Struct -> TFSharpStruct
33703370
| _ -> error(InternalError("should have inferred tycon kind", m))
33713371

33723372
let repr =
@@ -3377,7 +3377,7 @@ module EstablishTypeDefinitionCores =
33773377
TFSharpObjectRepr repr
33783378

33793379
| SynTypeDefnSimpleRepr.Enum _ ->
3380-
let kind = TTyconEnum
3380+
let kind = TFSharpEnum
33813381
let repr =
33823382
{ fsobjmodel_kind = kind
33833383
fsobjmodel_vslots = []
@@ -3413,7 +3413,7 @@ module EstablishTypeDefinitionCores =
34133413

34143414
let typeBeforeArguments =
34153415
match tcrefBeforeStaticArguments.TypeReprInfo with
3416-
| TProvidedTypeExtensionPoint info -> info.ProvidedType
3416+
| TProvidedTypeRepr info -> info.ProvidedType
34173417
| _ -> failwith "unreachable"
34183418

34193419
if IsGeneratedTypeDirectReference (typeBeforeArguments, m) then
@@ -3443,7 +3443,7 @@ module EstablishTypeDefinitionCores =
34433443
checkTypeName()
34443444
let resolutionEnvironment =
34453445
match tcrefForContainer.TypeReprInfo with
3446-
| TProvidedTypeExtensionPoint info -> info.ResolutionEnvironment
3446+
| TProvidedTypeRepr info -> info.ResolutionEnvironment
34473447
| _ -> failwith "unreachable"
34483448
resolutionEnvironment
34493449

@@ -3848,7 +3848,7 @@ module EstablishTypeDefinitionCores =
38483848
for fspec in fields do
38493849
if not fspec.IsCompilerGenerated then
38503850
let info = RecdFieldInfo(thisTyInst, thisTyconRef.MakeNestedRecdFieldRef fspec)
3851-
let nenv' = AddFakeNameToNameEnv fspec.Name nenv (Item.RecdField info)
3851+
let nenv' = AddFakeNameToNameEnv fspec.LogicalName nenv (Item.RecdField info)
38523852
// Name resolution gives better info for tooltips
38533853
let item = Item.RecdField(FreshenRecdFieldRef cenv.nameResolver m (thisTyconRef.MakeNestedRecdFieldRef fspec))
38543854
CallNameResolutionSink cenv.tcSink (fspec.Range, nenv, item, emptyTyparInst, ItemOccurence.Binding, ad)
@@ -3879,7 +3879,7 @@ module EstablishTypeDefinitionCores =
38793879
hiddenReprChecks false
38803880
noAllowNullLiteralAttributeCheck()
38813881
if hasMeasureAttr then
3882-
let repr = TFSharpObjectRepr { fsobjmodel_kind=TTyconClass
3882+
let repr = TFSharpObjectRepr { fsobjmodel_kind=TFSharpClass
38833883
fsobjmodel_vslots=[]
38843884
fsobjmodel_rfields= Construct.MakeRecdFieldsTable [] }
38853885
repr, None, NoSafeInitInfo
@@ -3928,12 +3928,13 @@ module EstablishTypeDefinitionCores =
39283928
let unionCases = TcRecdUnionAndEnumDeclarations.TcUnionCaseDecls cenv envinner innerParent thisTy thisTyInst tpenv unionCases
39293929

39303930
if tycon.IsStructRecordOrUnionTycon && unionCases.Length > 1 then
3931-
let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield ft.Name ]
3931+
let fieldNames = [ for uc in unionCases do for ft in uc.FieldTable.TrueInstanceFieldsAsList do yield ft.LogicalName ]
39323932
if fieldNames |> List.distinct |> List.length <> fieldNames.Length then
39333933
errorR(Error(FSComp.SR.tcStructUnionMultiCaseDistinctFields(), m))
39343934

39353935
writeFakeUnionCtorsToSink unionCases
3936-
Construct.MakeUnionRepr unionCases, None, NoSafeInitInfo
3936+
let repr = Construct.MakeUnionRepr unionCases
3937+
repr, None, NoSafeInitInfo
39373938

39383939
| SynTypeDefnSimpleRepr.Record (_, fields, _) ->
39393940
noMeasureAttributeCheck()
@@ -3944,7 +3945,8 @@ module EstablishTypeDefinitionCores =
39443945
let recdFields = TcRecdUnionAndEnumDeclarations.TcNamedFieldDecls cenv envinner innerParent false tpenv fields
39453946
recdFields |> CheckDuplicates (fun f -> f.Id) "field" |> ignore
39463947
writeFakeRecordFieldsToSink recdFields
3947-
TRecdRepr (Construct.MakeRecdFieldsTable recdFields), None, NoSafeInitInfo
3948+
let repr = TFSharpRecdRepr (Construct.MakeRecdFieldsTable recdFields)
3949+
repr, None, NoSafeInitInfo
39483950

39493951
| SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (s, _) ->
39503952
let s = (s :?> ILType)
@@ -4005,20 +4007,20 @@ module EstablishTypeDefinitionCores =
40054007
errorR (Error(FSComp.SR.tcStructTypesCannotContainAbstractMembers(), m))
40064008
structLayoutAttributeCheck true
40074009

4008-
TTyconStruct
4010+
TFSharpStruct
40094011
| SynTypeDefnKind.Interface ->
40104012
if hasSealedAttr = Some true then errorR (Error(FSComp.SR.tcInterfaceTypesCannotBeSealed(), m))
40114013
noCLIMutableAttributeCheck()
40124014
structLayoutAttributeCheck false
40134015
noAbstractClassAttributeCheck()
40144016
allowNullLiteralAttributeCheck()
40154017
noFieldsCheck userFields
4016-
TTyconInterface
4018+
TFSharpInterface
40174019
| SynTypeDefnKind.Class ->
40184020
noCLIMutableAttributeCheck()
40194021
structLayoutAttributeCheck(not isIncrClass)
40204022
allowNullLiteralAttributeCheck()
4021-
TTyconClass
4023+
TFSharpClass
40224024
| SynTypeDefnKind.Delegate (ty, arity) ->
40234025
noCLIMutableAttributeCheck()
40244026
noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedDelegate
@@ -4032,7 +4034,7 @@ module EstablishTypeDefinitionCores =
40324034
if curriedArgInfos.Length > 1 then error(Error(FSComp.SR.tcDelegatesCannotBeCurried(), m))
40334035
let ttps = thisTyconRef.Typars m
40344036
let fparams = curriedArgInfos.Head |> List.map MakeSlotParam
4035-
TTyconDelegate (MakeSlotSig("Invoke", thisTy, ttps, [], [fparams], returnTy))
4037+
TFSharpDelegate (MakeSlotSig("Invoke", thisTy, ttps, [], [fparams], returnTy))
40364038
| _ ->
40374039
error(InternalError("should have inferred tycon kind", m))
40384040

@@ -4080,7 +4082,7 @@ module EstablishTypeDefinitionCores =
40804082

40814083
| SynTypeDefnSimpleRepr.Enum (decls, m) ->
40824084
let fieldTy, fields' = TcRecdUnionAndEnumDeclarations.TcEnumDecls cenv envinner innerParent thisTy decls
4083-
let kind = TTyconEnum
4085+
let kind = TFSharpEnum
40844086
structLayoutAttributeCheck false
40854087
noCLIMutableAttributeCheck()
40864088
noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedEnum
@@ -4390,7 +4392,7 @@ module EstablishTypeDefinitionCores =
43904392

43914393
// Phase 1B. Establish the kind of each type constructor
43924394
// Here we run InferTyconKind and record partial information about the kind of the type constructor.
4393-
// This means TyconObjModelKind is set, which means isSealedTy, isInterfaceTy etc. give accurate results.
4395+
// This means TyconFSharpObjModelKind is set, which means isSealedTy, isInterfaceTy etc. give accurate results.
43944396
let withAttrs =
43954397
(envMutRecPrelim, withEnvs) ||> MutRecShapes.mapTyconsWithEnv (fun envForDecls (origInfo, tyconOpt) ->
43964398
let res =

0 commit comments

Comments
 (0)