Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions FSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
ProjectSection(ProjectDependencies) = postProject
{D0E98C0D-490B-4C61-9329-0862F6E87645} = {D0E98C0D-490B-4C61-9329-0862F6E87645}
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B} = {8B3E283D-B5FE-4055-9D80-7E3A32F3967B}
{C94C257C-3C0A-4858-B5D8-D746498D1F08} = {C94C257C-3C0A-4858-B5D8-D746498D1F08}
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
EndProject
Expand Down
6 changes: 6 additions & 0 deletions VisualFSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
ProjectSection(ProjectDependencies) = postProject
{D0E98C0D-490B-4C61-9329-0862F6E87645} = {D0E98C0D-490B-4C61-9329-0862F6E87645}
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B} = {8B3E283D-B5FE-4055-9D80-7E3A32F3967B}
{2E60864A-E3FF-4BCC-810F-DC7C34E6B236} = {2E60864A-E3FF-4BCC-810F-DC7C34E6B236}
{C94C257C-3C0A-4858-B5D8-D746498D1F08} = {C94C257C-3C0A-4858-B5D8-D746498D1F08}
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ let MethInfoIsUnseen g (m: range) (ty: TType) minfo =
isObjTy g minfo.ApparentEnclosingType &&
let tcref = tcrefOfAppTy g ty
match tcref.TypeReprInfo with
| TProvidedTypeExtensionPoint info ->
| TProvidedTypeRepr info ->
info.ProvidedType.PUntaint((fun st -> (st :> IProvidedCustomAttributeProvider).GetHasTypeProviderEditorHideMethodsAttribute(info.ProvidedType.TypeProvider.PUntaintNoFailure(id))), m)
| _ ->
// This attribute check is done by name to ensure compilation doesn't take a dependency
Expand Down
54 changes: 28 additions & 26 deletions src/fsharp/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ module TcRecdUnionAndEnumDeclarations =
let ValidateFieldNames (synFields: SynField list, tastFields: RecdField list) =
let seen = Dictionary()
(synFields, tastFields) ||> List.iter2 (fun sf f ->
match seen.TryGetValue f.Name with
match seen.TryGetValue f.LogicalName with
| true, synField ->
match sf, synField with
| SynField(_, _, Some id, _, _, _, _, _), SynField(_, _, Some _, _, _, _, _, _) ->
Expand All @@ -465,7 +465,7 @@ module TcRecdUnionAndEnumDeclarations =
error(Error(FSComp.SR.tcFieldNameConflictsWithGeneratedNameForAnonymousField(id.idText), id.idRange))
| _ -> assert false
| _ ->
seen.Add(f.Name, sf))
seen.Add(f.LogicalName, sf))

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

Expand Down Expand Up @@ -1379,7 +1379,7 @@ module IncrClassChecking =
[ for b in memberBinds do
yield b.Var.CompiledName cenv.g.CompilerGlobalState
yield b.Var.DisplayName
yield b.Var.CoreDisplayName
yield b.Var.DisplayNameCoreMangled
yield b.Var.LogicalName ]
let reps = IncrClassReprInfo.Empty(g, takenFieldNames)

Expand Down Expand Up @@ -2040,7 +2040,7 @@ module MutRecBindingChecking =

if needsSafeStaticInit && hasStaticBindings then
let rfield = MakeSafeInitField g envForDecls tcref.Range true
SafeInitField(mkRecdFieldRef tcref rfield.Name, rfield)
SafeInitField(mkRecdFieldRef tcref rfield.LogicalName, rfield)
else
NoSafeInitInfo

Expand Down Expand Up @@ -3147,7 +3147,7 @@ module EstablishTypeDefinitionCores =
if InstanceMembersNeedSafeInitCheck cenv m thisTy then
let rfield = MakeSafeInitField cenv.g env m false
let tcref = tcrefOfAppTy cenv.g thisTy
SafeInitField (mkRecdFieldRef tcref rfield.Name, rfield)
SafeInitField (mkRecdFieldRef tcref rfield.LogicalName, rfield)
else
NoSafeInitInfo

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

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

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

let repr =
Expand All @@ -3377,7 +3377,7 @@ module EstablishTypeDefinitionCores =
TFSharpObjectRepr repr

| SynTypeDefnSimpleRepr.Enum _ ->
let kind = TTyconEnum
let kind = TFSharpEnum
let repr =
{ fsobjmodel_kind = kind
fsobjmodel_vslots = []
Expand Down Expand Up @@ -3413,7 +3413,7 @@ module EstablishTypeDefinitionCores =

let typeBeforeArguments =
match tcrefBeforeStaticArguments.TypeReprInfo with
| TProvidedTypeExtensionPoint info -> info.ProvidedType
| TProvidedTypeRepr info -> info.ProvidedType
| _ -> failwith "unreachable"

if IsGeneratedTypeDirectReference (typeBeforeArguments, m) then
Expand Down Expand Up @@ -3443,7 +3443,7 @@ module EstablishTypeDefinitionCores =
checkTypeName()
let resolutionEnvironment =
match tcrefForContainer.TypeReprInfo with
| TProvidedTypeExtensionPoint info -> info.ResolutionEnvironment
| TProvidedTypeRepr info -> info.ResolutionEnvironment
| _ -> failwith "unreachable"
resolutionEnvironment

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

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

writeFakeUnionCtorsToSink unionCases
Construct.MakeUnionRepr unionCases, None, NoSafeInitInfo
let repr = Construct.MakeUnionRepr unionCases
repr, None, NoSafeInitInfo

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

| SynTypeDefnSimpleRepr.LibraryOnlyILAssembly (s, _) ->
let s = (s :?> ILType)
Expand Down Expand Up @@ -4005,20 +4007,20 @@ module EstablishTypeDefinitionCores =
errorR (Error(FSComp.SR.tcStructTypesCannotContainAbstractMembers(), m))
structLayoutAttributeCheck true

TTyconStruct
TFSharpStruct
| SynTypeDefnKind.Interface ->
if hasSealedAttr = Some true then errorR (Error(FSComp.SR.tcInterfaceTypesCannotBeSealed(), m))
noCLIMutableAttributeCheck()
structLayoutAttributeCheck false
noAbstractClassAttributeCheck()
allowNullLiteralAttributeCheck()
noFieldsCheck userFields
TTyconInterface
TFSharpInterface
| SynTypeDefnKind.Class ->
noCLIMutableAttributeCheck()
structLayoutAttributeCheck(not isIncrClass)
allowNullLiteralAttributeCheck()
TTyconClass
TFSharpClass
| SynTypeDefnKind.Delegate (ty, arity) ->
noCLIMutableAttributeCheck()
noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedDelegate
Expand All @@ -4032,7 +4034,7 @@ module EstablishTypeDefinitionCores =
if curriedArgInfos.Length > 1 then error(Error(FSComp.SR.tcDelegatesCannotBeCurried(), m))
let ttps = thisTyconRef.Typars m
let fparams = curriedArgInfos.Head |> List.map MakeSlotParam
TTyconDelegate (MakeSlotSig("Invoke", thisTy, ttps, [], [fparams], returnTy))
TFSharpDelegate (MakeSlotSig("Invoke", thisTy, ttps, [], [fparams], returnTy))
| _ ->
error(InternalError("should have inferred tycon kind", m))

Expand Down Expand Up @@ -4080,7 +4082,7 @@ module EstablishTypeDefinitionCores =

| SynTypeDefnSimpleRepr.Enum (decls, m) ->
let fieldTy, fields' = TcRecdUnionAndEnumDeclarations.TcEnumDecls cenv envinner innerParent thisTy decls
let kind = TTyconEnum
let kind = TFSharpEnum
structLayoutAttributeCheck false
noCLIMutableAttributeCheck()
noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedEnum
Expand Down Expand Up @@ -4390,7 +4392,7 @@ module EstablishTypeDefinitionCores =

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