From e0f1634014503fafa0124e112f90f78172f0457b Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 30 Jan 2024 11:09:44 +0100 Subject: [PATCH] Nullness - reading+writing metadata for 'inherits' and interface implementations (#16597) --- Directory.Build.props | 6 +- azure-pipelines.yml | 27 +- .../.FSharp.Compiler.Service/8.0.300.md | 5 +- eng/Build.ps1 | 18 ++ eng/Version.Details.xml | 4 +- global.json | 2 +- src/Compiler/AbstractIL/il.fs | 11 +- src/Compiler/AbstractIL/il.fsi | 6 +- src/Compiler/AbstractIL/ilread.fs | 21 +- src/Compiler/AbstractIL/ilwrite.fs | 16 +- src/Compiler/Checking/TypeHierarchy.fs | 21 +- src/Compiler/CodeGen/EraseClosures.fs | 2 + src/Compiler/CodeGen/EraseUnions.fs | 1 + src/Compiler/CodeGen/IlxGen.fs | 46 ++- .../GraphChecking/FileContentMapping.fs | 7 +- .../Driver/GraphChecking/GraphProcessing.fs | 10 +- src/Compiler/Service/SynExpr.fs | 10 +- .../EmittedIL/Nullness/NullableInheritance.fs | 24 ++ .../NullableInheritance.fs.il.net472.bsl | 275 ++++++++++++++++++ .../NullableInheritance.fs.il.netcore.bsl | 209 +++++++++++++ .../EmittedIL/Nullness/NullnessMetadata.fs | 5 + .../Graph/FileContentMappingTests.fs | 43 ++- ...ervice.SurfaceArea.netstandard20.debug.bsl | 22 +- ...vice.SurfaceArea.netstandard20.release.bsl | 22 +- .../HistoricalBenchmark.Runner.fsproj | 1 + .../BackgroundCompilerBenchmarks.fs | 2 +- tests/scripts/update-baselines.fsx | 4 +- .../service/ModuleReaderCancellationTests.fs | 2 +- .../LanguageService/WorkspaceExtensions.fs | 2 +- .../RemoveUnnecessaryParenthesesTests.fs | 18 ++ 30 files changed, 755 insertions(+), 87 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.net472.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.netcore.bsl diff --git a/Directory.Build.props b/Directory.Build.props index 10c53909035..a1b18784e91 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,10 +16,6 @@ true - - true - - true @@ -28,6 +24,8 @@ + true + true false true true diff --git a/azure-pipelines.yml b/azure-pipelines.yml index afd393f8200..df00f0bc2c2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,4 +1,4 @@ -# CI and PR triggers +# CI and PR triggers trigger: branches: include: @@ -110,13 +110,10 @@ stages: demands: ImageOverride -equals windows.vs2022preview.amd64 timeoutInMinutes: 300 variables: - - group: DotNet-Blob-Feed - group: DotNet-Symbol-Server-Pats - group: DotNet-DevDiv-Insertion-Workflow-Variables - name: _SignType value: Real - - name: _DotNetPublishToBlobFeed - value: true steps: - checkout: self clean: true @@ -131,9 +128,6 @@ stages: /p:MicroBuild_SigningEnabled=true /p:OverridePackageSource=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json /p:TeamName=$(_TeamName) - /p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1) - /p:DotNetPublishBlobFeedUrl=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json - /p:DotNetPublishToBlobFeed=true /p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines) /p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory) /p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat) @@ -724,25 +718,10 @@ stages: steps: - checkout: self clean: true - - script: dotnet --list-sdks - displayName: Report dotnet SDK versions - - task: UseDotNet@2 - displayName: install SDK - inputs: - packageType: sdk - useGlobalJson: true - includePreviewVersions: true - workingDirectory: $(Build.SourcesDirectory) - installationPath: $(Agent.ToolsDirectory)/dotnet - - script: dotnet build -c $(_BuildConfig) .\FSharp.Benchmarks.sln /bl:\"artifacts/log/$(_BuildConfig)/BenchmarkBuild.binlog\" - workingDirectory: $(Build.SourcesDirectory) - displayName: Plain build of FSharp.Benchmarks.sln + - script: eng\CIBuild.cmd -configuration $(_BuildConfig) -testBenchmarks + displayName: Smoke test fast benchmarks continueOnError: true condition: always() - - script: .\Build.cmd -c $(_BuildConfig) - - pwsh: ./SmokeTestBenchmarks.ps1 - workingDirectory: $(Build.SourcesDirectory)/tests/benchmarks - displayName: Smoke test fast benchmarks # Test trimming on Windows - job: Build_And_Test_Trimming_Windows diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md index 54ce6d6be5d..ee3affe24f9 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -2,13 +2,14 @@ * Code generated files with > 64K methods and generated symbols crash when loaded. Use infered sequence points for debugging. ([Issue #16399](https://github.com/dotnet/fsharp/issues/16399), [#PR 16514](https://github.com/dotnet/fsharp/pull/16514)) * `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550)) -* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575)) +* Graph Based Checking doesn't throw on invalid parsed input so it can be used for IDE scenarios ([PR #16575](https://github.com/dotnet/fsharp/pull/16575), [PR #16588](https://github.com/dotnet/fsharp/pull/16588)) +* Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578)) ### Added * Support for nullable reference types ([PR #15181](https://github.com/dotnet/fsharp/pull/15181)) -* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583)) +* The stackguard depth for ILPdbWriter.unshadowScopes can be modified via the environment variable `FSHARP_ILPdb_UnshadowScopes_StackGuardDepth`([PR #16583](https://github.com/dotnet/fsharp/pull/16583)) * Parser recovers on complex primary constructor patterns, better tree representation for primary constructor patterns. ([PR #16425](https://github.com/dotnet/fsharp/pull/16425)) * Name resolution: keep type vars in subsequent checks ([PR #16456](https://github.com/dotnet/fsharp/pull/16456)) * Higher-order-function-based API for working with the untyped abstract syntax tree. ([PR #16462](https://github.com/dotnet/fsharp/pull/16462)) diff --git a/eng/Build.ps1 b/eng/Build.ps1 index b713a86effa..fe7eb56a5b1 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -62,6 +62,7 @@ param ( [switch]$testAllButIntegration, [switch]$testpack, [switch]$testAOT, + [switch]$testBenchmarks, [string]$officialSkipTests = "false", [switch]$noVisualStudio, [switch]$sourceBuild, @@ -111,6 +112,7 @@ function Print-Usage() { Write-Host " -testVs Run F# editor unit tests" Write-Host " -testpack Verify built packages" Write-Host " -testAOT Run AOT/Trimming tests" + Write-Host " -testBenchmarks Build and Run Benchmark suite" Write-Host " -officialSkipTests Set to 'true' to skip running tests" Write-Host "" Write-Host "Advanced settings:" @@ -176,6 +178,7 @@ function Process-Arguments() { $script:testVs = $False $script:testpack = $False $script:testAOT = $False + $script:testBenchmarks = $False $script:verifypackageshipstatus = $True } @@ -211,6 +214,10 @@ function Process-Arguments() { $script:pack = $True; } + if ($testBenchmarks) { + $script:testBenchmarks = $True + } + foreach ($property in $properties) { if (!$property.StartsWith("/p:", "InvariantCultureIgnoreCase")) { Write-Host "Invalid argument: $property" @@ -541,12 +548,17 @@ try { } } + if ($testBenchmarks) { + BuildSolution "FSharp.Benchmarks.sln" $False + } + if ($pack) { $properties_storage = $properties $properties += "/p:GenerateSbom=false" BuildSolution "Microsoft.FSharp.Compiler.sln" $True $properties = $properties_storage } + if ($build) { VerifyAssemblyVersionsAndSymbols } @@ -662,6 +674,12 @@ try { Pop-Location } + if ($testBenchmarks) { + Push-Location "$RepoRoot\tests\benchmarks" + ./SmokeTestBenchmarks.ps1 + Pop-Location + } + # verify nupkgs have access to the source code $nupkgtestFailed = $false if ($testpack) { diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 732b37657ea..4be35244cae 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -29,9 +29,9 @@ - + https://github.com/dotnet/arcade - 4c941e2e3ae61502bd4ffd711930f662fd808375 + 07cf24f27ee58b5d1a9662334a101d84bd1e07e5 diff --git a/global.json b/global.json index 56134e06fd6..60ffcefc016 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.0.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24073.2", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24075.5", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 3b7df226c9f..4859f510c01 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -2612,6 +2612,7 @@ type ILTypeDef attributes: TypeAttributes, layout: ILTypeDefLayout, implements: ILTypes, + implementsCustomAttrs: (ILAttributesStored * int) list option, genericParams: ILGenericParameterDefs, extends: ILType option, methods: ILMethodDefs, @@ -2632,6 +2633,7 @@ type ILTypeDef attributes, layout, implements, + implementsCustomAttrs, genericParams, extends, methods, @@ -2648,6 +2650,7 @@ type ILTypeDef attributes, layout, implements, + implementsCustomAttrs, genericParams, extends, methods, @@ -2674,6 +2677,8 @@ type ILTypeDef member _.Implements = implements + member _.ImplementsCustomAttrs = implementsCustomAttrs + member _.Extends = extends member _.Methods = methods @@ -2710,7 +2715,8 @@ type ILTypeDef ?properties, ?isKnownToBeAttribute, ?customAttrs, - ?securityDecls + ?securityDecls, + ?implementsCustomAttrs ) = ILTypeDef( name = defaultArg name x.Name, @@ -2719,6 +2725,7 @@ type ILTypeDef genericParams = defaultArg genericParams x.GenericParams, nestedTypes = defaultArg nestedTypes x.NestedTypes, implements = defaultArg implements x.Implements, + implementsCustomAttrs = defaultArg implementsCustomAttrs x.ImplementsCustomAttrs, extends = defaultArg extends x.Extends, methods = defaultArg methods x.Methods, securityDecls = defaultArg securityDecls x.SecurityDecls, @@ -4192,6 +4199,7 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes attributes = attributes, genericParams = genparams, implements = impl, + implementsCustomAttrs = None, layout = ILTypeDefLayout.Auto, extends = Some extends, methods = methods, @@ -4216,6 +4224,7 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) = ||| TypeAttributes.BeforeFieldInit ||| TypeAttributes.AnsiClass), implements = [], + implementsCustomAttrs = None, extends = Some iltyp_ValueType, layout = ILTypeDefLayout.Explicit { Size = Some size; Pack = Some pack }, methods = emptyILMethods, diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 8ae223081ac..bb503932b86 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -1507,6 +1507,7 @@ type ILTypeDef = attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * + implementsCustomAttrs: (ILAttributesStored * int) list option * genericParams: ILGenericParameterDefs * extends: ILType option * methods: ILMethodDefs * @@ -1527,6 +1528,7 @@ type ILTypeDef = attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * + implementsCustomAttrs: (ILAttributesStored * int) list option * genericParams: ILGenericParameterDefs * extends: ILType option * methods: ILMethodDefs * @@ -1546,6 +1548,7 @@ type ILTypeDef = member Layout: ILTypeDefLayout member NestedTypes: ILTypeDefs member Implements: ILTypes + member ImplementsCustomAttrs: (ILAttributesStored * int) list option member Extends: ILType option member Methods: ILMethodDefs member SecurityDecls: ILSecurityDecls @@ -1604,7 +1607,8 @@ type ILTypeDef = ?properties: ILPropertyDefs * ?isKnownToBeAttribute: bool * ?customAttrs: ILAttributes * - ?securityDecls: ILSecurityDecls -> + ?securityDecls: ILSecurityDecls * + ?implementsCustomAttrs: (ILAttributesStored * int) list option -> ILTypeDef /// Represents a prefix of information for ILTypeDef. diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 6dcc4ee33c6..08c82f9b270 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -1180,6 +1180,7 @@ type ILMetadataReader = customAttrsReader_Module: ILAttributesStored customAttrsReader_Assembly: ILAttributesStored customAttrsReader_TypeDef: ILAttributesStored + customAttrsReader_InterfaceImpl: ILAttributesStored customAttrsReader_GenericParam: ILAttributesStored customAttrsReader_FieldDef: ILAttributesStored customAttrsReader_MethodDef: ILAttributesStored @@ -1450,11 +1451,16 @@ let seekReadParamRow (ctxt: ILMetadataReader) mdv idx = (flags, seq, nameIdx) /// Read Table InterfaceImpl. -let seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx = +let private seekReadInterfaceImplRow (ctxt: ILMetadataReader) mdv idx = let mutable addr = ctxt.rowAddr TableNames.InterfaceImpl idx let tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr let intfIdx = seekReadTypeDefOrRefOrSpecIdx ctxt mdv &addr - (tidx, intfIdx) + + struct {| + TypeIdx = tidx + IntfIdx = intfIdx + IntImplIdx = idx + |} /// Read Table MemberRef. let seekReadMemberRefRow (ctxt: ILMetadataReader) mdv idx = @@ -2144,7 +2150,10 @@ and typeDefReader ctxtH : ILTypeDefStored = let mdefs = seekReadMethods ctxt numTypars methodsIdx endMethodsIdx let fdefs = seekReadFields ctxt (numTypars, hasLayout) fieldsIdx endFieldsIdx let nested = seekReadNestedTypeDefs ctxt idx - let impls = seekReadInterfaceImpls ctxt mdv numTypars idx + + let impls, intImplsAttrs = + seekReadInterfaceImpls ctxt mdv numTypars idx |> List.unzip + let mimpls = seekReadMethodImpls ctxt numTypars idx let props = seekReadProperties ctxt numTypars idx let events = seekReadEvents ctxt numTypars idx @@ -2156,6 +2165,7 @@ and typeDefReader ctxtH : ILTypeDefStored = layout = layout, nestedTypes = nested, implements = impls, + implementsCustomAttrs = Some intImplsAttrs, extends = super, methods = mdefs, securityDeclsStored = ctxt.securityDeclsReader_TypeDef, @@ -2192,10 +2202,10 @@ and seekReadInterfaceImpls (ctxt: ILMetadataReader) mdv numTypars tidx = seekReadIndexedRows ( ctxt.getNumRows TableNames.InterfaceImpl, seekReadInterfaceImplRow ctxt mdv, - fst, + (fun x -> x.TypeIdx), simpleIndexCompare tidx, isSorted ctxt TableNames.InterfaceImpl, - (snd >> seekReadTypeDefOrRef ctxt numTypars AsObject []) + (fun x -> (seekReadTypeDefOrRef ctxt numTypars AsObject [] x.IntfIdx), (ctxt.customAttrsReader_InterfaceImpl, x.IntImplIdx)) ) and seekReadGenericParams ctxt numTypars (a, b) : ILGenericParameterDefs = @@ -4487,6 +4497,7 @@ let openMetadataReader customAttrsReader_Module = customAttrsReader ctxtH hca_Module customAttrsReader_Assembly = customAttrsReader ctxtH hca_Assembly customAttrsReader_TypeDef = customAttrsReader ctxtH hca_TypeDef + customAttrsReader_InterfaceImpl = customAttrsReader ctxtH hca_InterfaceImpl customAttrsReader_GenericParam = customAttrsReader ctxtH hca_GenericParam customAttrsReader_FieldDef = customAttrsReader ctxtH hca_FieldDef customAttrsReader_MethodDef = customAttrsReader ctxtH hca_MethodDef diff --git a/src/Compiler/AbstractIL/ilwrite.fs b/src/Compiler/AbstractIL/ilwrite.fs index f41c8aaa08d..c4c43f6a5fc 100644 --- a/src/Compiler/AbstractIL/ilwrite.fs +++ b/src/Compiler/AbstractIL/ilwrite.fs @@ -554,6 +554,8 @@ type cenv = methodDefIdxs: Dictionary + implementsIdxs: Dictionary + propertyDefs: MetadataTable eventDefs: MetadataTable @@ -1281,7 +1283,7 @@ and GetTypeAsImplementsRow cenv env tidx ty = TypeDefOrRefOrSpec (tdorTag, tdorRow) |] and GenImplementsPass2 cenv env tidx ty = - AddUnsharedRow cenv TableNames.InterfaceImpl (GetTypeAsImplementsRow cenv env tidx ty) |> ignore + AddUnsharedRow cenv TableNames.InterfaceImpl (GetTypeAsImplementsRow cenv env tidx ty) and GetKeyForEvent tidx (x: ILEventDef) = EventKey (tidx, x.Name) @@ -1317,7 +1319,8 @@ and GenTypeDefPass2 pidx enc cenv (tdef: ILTypeDef) = // Now generate or assign index numbers for tables referenced by the maps. // Don't yet generate contents of these tables - leave that to pass3, as // code may need to embed these entries. - tdef.Implements |> List.iter (GenImplementsPass2 cenv env tidx) + cenv.implementsIdxs[tidx] <- tdef.Implements |> List.map (GenImplementsPass2 cenv env tidx) + tdef.Fields.AsList() |> List.iter (GenFieldDefPass2 tdef cenv tidx) tdef.Methods |> Seq.iter (GenMethodDefPass2 tdef cenv tidx) // Generation of property & event definitions for **ref assemblies** is checking existence of generated method definitions. @@ -2866,6 +2869,14 @@ let rec GenTypeDefPass3 enc cenv (tdef: ILTypeDef) = try let env = envForTypeDef tdef let tidx = GetIdxForTypeDef cenv (TdKey(enc, tdef.Name)) + + match tdef.ImplementsCustomAttrs with + | None -> () + | Some attrList -> + attrList + |> List.zip cenv.implementsIdxs[tidx] + |> List.iter (fun (impIdx,(attrs,metadataIdx)) -> GenCustomAttrsPass3Or4 cenv (hca_InterfaceImpl,impIdx) (attrs.GetCustomAttrs metadataIdx)) + tdef.Properties.AsList() |> List.iter (GenPropertyPass3 cenv env) tdef.Events.AsList() |> List.iter (GenEventPass3 cenv env) tdef.Fields.AsList() |> List.iter (GenFieldDefPass3 tdef cenv env) @@ -3130,6 +3141,7 @@ let generateIL ( methodDefIdxsByKey = MetadataTable<_>.New("method defs", EqualityComparer.Default) // This uses reference identity on ILMethodDef objects methodDefIdxs = Dictionary<_, _>(100, HashIdentity.Reference) + implementsIdxs = Dictionary<_, _>(100, HashIdentity.Structural) propertyDefs = MetadataTable<_>.New("property defs", EqualityComparer.Default) eventDefs = MetadataTable<_>.New("event defs", EqualityComparer.Default) typeDefs = MetadataTable<_>.New("type defs", EqualityComparer.Default) diff --git a/src/Compiler/Checking/TypeHierarchy.fs b/src/Compiler/Checking/TypeHierarchy.fs index a629857245a..69c1924f3d7 100644 --- a/src/Compiler/Checking/TypeHierarchy.fs +++ b/src/Compiler/Checking/TypeHierarchy.fs @@ -9,6 +9,7 @@ open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Import +open FSharp.Compiler.Import.Nullness open FSharp.Compiler.Features open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTreeOps @@ -56,7 +57,10 @@ let GetSuperTypeOfType g amap m ty = match tdef.Extends with | None -> None // 'inherit' cannot refer to a nullable type - | Some ilTy -> Some (RescopeAndImportILTypeSkipNullness scoref amap m tinst ilTy) + | Some ilTy -> + let typeAttrs = AttributesFromIL(tdef.MetadataIndex,tdef.CustomAttrsStored) + let nullness = {DirectAttributes = typeAttrs; Fallback = FromClass typeAttrs} + Some (RescopeAndImportILType scoref amap m tinst nullness ilTy) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> if isFSharpObjModelTy g ty || isFSharpExceptionTy g ty then @@ -114,10 +118,17 @@ let GetImmediateInterfacesOfMetadataType g amap m skipUnref ty (tcref: TyconRef) // succeeded with more reported. There are pathological corner cases where this // doesn't apply: e.g. for mscorlib interfaces like IComparable, but we can always // assume those are present. - for intfTy in tdef.Implements do - if skipUnref = SkipUnrefInterfaces.No || CanRescopeAndImportILType scoref amap m intfTy then - // Implementing an interface cannot refer to a nullable type - RescopeAndImportILTypeSkipNullness scoref amap m tinst intfTy + match tdef.ImplementsCustomAttrs with + | Some attrsList when g.langFeatureNullness && g.checkNullness -> + for (attrs,attrsIdx),intfTy in tdef.Implements |> List.zip attrsList do + if skipUnref = SkipUnrefInterfaces.No || CanRescopeAndImportILType scoref amap m intfTy then + let typeAttrs = AttributesFromIL(attrsIdx,attrs) + let nullness = {DirectAttributes = typeAttrs; Fallback = FromClass typeAttrs} + RescopeAndImportILType scoref amap m tinst nullness intfTy + | _ -> + for intfTy in tdef.Implements do + if skipUnref = SkipUnrefInterfaces.No || CanRescopeAndImportILType scoref amap m intfTy then + RescopeAndImportILTypeSkipNullness scoref amap m tinst intfTy | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> for intfTy in tcref.ImmediateInterfaceTypesOfFSharpTycon do instType (mkInstForAppTy g ty) intfTy ] diff --git a/src/Compiler/CodeGen/EraseClosures.fs b/src/Compiler/CodeGen/EraseClosures.fs index cf1499f0c30..7e5d0df8810 100644 --- a/src/Compiler/CodeGen/EraseClosures.fs +++ b/src/Compiler/CodeGen/EraseClosures.fs @@ -573,6 +573,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = genericParams = td.GenericParams, attributes = td.Attributes, implements = [], + implementsCustomAttrs = None, nestedTypes = emptyILTypeDefs, layout = ILTypeDefLayout.Auto, extends = Some cenv.mkILTyFuncTy, @@ -707,6 +708,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = genericParams = td.GenericParams, attributes = td.Attributes, implements = [], + implementsCustomAttrs = None, layout = ILTypeDefLayout.Auto, nestedTypes = emptyILTypeDefs, extends = Some nowEnvParentClass, diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index c500f8ae511..508855f67a8 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1565,6 +1565,7 @@ let mkClassUnionDef attributes = enum 0, layout = ILTypeDefLayout.Auto, implements = [], + implementsCustomAttrs = None, extends = Some g.ilg.typ_Object, methods = emptyILMethods, securityDecls = emptyILSecurityDecls, diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 66245cfe58f..569457f27fe 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -6186,6 +6186,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel methodImpls = mkILMethodImpls mimpls, nestedTypes = emptyILTypeDefs, implements = ilInterfaceTys, + implementsCustomAttrs = None, extends = Some super, isKnownToBeAttribute = false, securityDecls = emptyILSecurityDecls @@ -6614,6 +6615,7 @@ and GenClosureTypeDefs methodImpls = mkILMethodImpls mimpls, nestedTypes = emptyILTypeDefs, implements = ilIntfTys, + implementsCustomAttrs = None, extends = Some ext, isKnownToBeAttribute = false, securityDecls = emptyILSecurityDecls @@ -10569,6 +10571,19 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = tycon.ImmediateInterfaceTypesOfFSharpTycon |> List.map (GenType cenv m eenvinner.tyenv) + let ilIntCustomAttrs = + if g.langFeatureNullness && g.checkNullness && not (isNil ilIntfTys) then + tycon.ImmediateInterfaceTypesOfFSharpTycon + |> List.map ( + GenAdditionalAttributesForTy g + >> mkILCustomAttrs + >> ILAttributesStored.Given + >> (fun x -> x, 0) + ) + |> Some + else + None + let ilTypeName = tref.Name let hidden = IsHiddenTycon eenv.sigToImplRemapInfo tycon @@ -11171,16 +11186,20 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = let ilAttrs = ilCustomAttrs @ [ - mkCompilationMappingAttr - g - (int ( - if isObjectType then - SourceConstructFlags.ObjectType - elif hiddenRepr then - SourceConstructFlags.RecordType ||| SourceConstructFlags.NonPublicRepresentation - else - SourceConstructFlags.RecordType - )) + yield + mkCompilationMappingAttr + g + (int ( + if isObjectType then + SourceConstructFlags.ObjectType + elif hiddenRepr then + SourceConstructFlags.RecordType ||| SourceConstructFlags.NonPublicRepresentation + else + SourceConstructFlags.RecordType + )) + + if not (ilBaseTy.GenericArgs.IsEmpty) then + yield! GenAdditionalAttributesForTy g super ] let isKnownToBeAttribute = @@ -11211,7 +11230,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = .WithSerializable(isSerializable) .WithAbstract(isAbstract) .WithImport(isComInteropTy g thisTy) - .With(methodImpls = mkILMethodImpls methodImpls, isKnownToBeAttribute = isKnownToBeAttribute) + .With( + methodImpls = mkILMethodImpls methodImpls, + isKnownToBeAttribute = isKnownToBeAttribute, + implementsCustomAttrs = ilIntCustomAttrs + ) let tdLayout, tdEncoding = match TryFindFSharpAttribute g g.attrib_StructLayoutAttribute tycon.Attribs with @@ -11374,6 +11397,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = methodImpls = mkILMethodImpls methodImpls, nestedTypes = emptyILTypeDefs, implements = ilIntfTys, + implementsCustomAttrs = None, extends = Some( if tycon.IsStructOrEnumTycon then diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 683460a2238..020ff817375 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -9,10 +9,9 @@ type Continuations = ((FileContentEntry list -> FileContentEntry list) -> FileCo let collectFromOption (mapping: 'T -> 'U list) (t: 'T option) : 'U list = List.collect mapping (Option.toList t) let longIdentToPath (skipLast: bool) (longId: LongIdent) : LongIdentifier = - if skipLast then - List.take (longId.Length - 1) longId - else - longId + match skipLast, longId with + | true, _ :: _ -> List.take (longId.Length - 1) longId + | _ -> longId |> List.map (fun ident -> ident.idText) let synLongIdentToPath (skipLast: bool) (synLongIdent: SynLongIdent) = diff --git a/src/Compiler/Driver/GraphChecking/GraphProcessing.fs b/src/Compiler/Driver/GraphChecking/GraphProcessing.fs index afe491b4b74..37ecc35041d 100644 --- a/src/Compiler/Driver/GraphChecking/GraphProcessing.fs +++ b/src/Compiler/Driver/GraphChecking/GraphProcessing.fs @@ -230,8 +230,12 @@ let processGraphAsync<'Item, 'Result when 'Item: equality and 'Item: comparison> let processedCount = IncrementableInt(0) - let raiseExn (item, ex: exn) = - localCts.Cancel() + let handleExn (item, ex: exn) = + try + localCts.Cancel() + with :? ObjectDisposedException -> + // If it's disposed already, it means that the processing has already finished, most likely due to cancellation or failure in another node. + () match ex with | :? OperationCanceledException -> completionSignal.TrySetCanceled() @@ -252,7 +256,7 @@ let processGraphAsync<'Item, 'Result when 'Item: equality and 'Item: comparison> match res with | Choice1Of2() -> () - | Choice2Of2 ex -> raiseExn (node.Info.Item, ex) + | Choice2Of2 ex -> handleExn (node.Info.Item, ex) }, cts.Token ) diff --git a/src/Compiler/Service/SynExpr.fs b/src/Compiler/Service/SynExpr.fs index 0df9a1a1c17..41dbd4d4d18 100644 --- a/src/Compiler/Service/SynExpr.fs +++ b/src/Compiler/Service/SynExpr.fs @@ -423,7 +423,9 @@ module SynExpr = | SynExpr.MatchLambda(matchClauses = Last(SynMatchClause(resultExpr = expr))) | SynExpr.MatchBang(clauses = Last(SynMatchClause(resultExpr = expr))) | SynExpr.TryWith(withCases = Last(SynMatchClause(resultExpr = expr))) - | SynExpr.TryFinally(finallyExpr = expr) -> loop expr + | SynExpr.TryFinally(finallyExpr = expr) + | SynExpr.Do(expr = expr) + | SynExpr.DoBang(expr = expr) -> loop expr | _ -> ValueNone loop @@ -810,6 +812,12 @@ module SynExpr = -> true + | SynExpr.InterpolatedString(contents = contents), (SynExpr.Tuple(isStruct = false) | Dangling.Problematic _) -> + contents + |> List.exists (function + | SynInterpolatedStringPart.FillExpr(qualifiers = Some _) -> true + | _ -> false) + | SynExpr.Record(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), Dangling.Problematic _ | SynExpr.AnonRecd(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), Dangling.Problematic _ -> true diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs new file mode 100644 index 00000000000..19fd926e2fe --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs @@ -0,0 +1,24 @@ +module MyTestModule + +open System +open System.Collections.Generic + + +type DerivedWhichAllowsNull() = + inherit ResizeArray() + member x.FirstItem = x[0] + +type DerivedWithoutNull() = + inherit ResizeArray() + member x.FirstItem = x[0] + +type ICanGetAnything<'T> = + abstract member Get : unit -> 'T + +type MyClassImplementingTheSameInterface() = + interface ICanGetAnything with + member x.Get() = null + interface ICanGetAnything>> with + member x.Get() = new ResizeArray<_>() + interface ICanGetAnything | null> with + member x.Get() = null \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.net472.bsl new file mode 100644 index 00000000000..fbb63d7ff9e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.net472.bsl @@ -0,0 +1,275 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public DerivedWhichAllowsNull + extends class [runtime]System.Collections.Generic.List`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 02 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void class [runtime]System.Collections.Generic.List`1::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig specialname + instance string get_FirstItem() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (class MyTestModule/DerivedWhichAllowsNull V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldc.i4.0 + IL_0004: tail. + IL_0006: callvirt instance !0 class [runtime]System.Collections.Generic.List`1::get_Item(int32) + IL_000b: ret + } + + .property instance string FirstItem() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .get instance string MyTestModule/DerivedWhichAllowsNull::get_FirstItem() + } + } + + .class auto ansi serializable nested public DerivedWithoutNull + extends class [runtime]System.Collections.Generic.List`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void class [runtime]System.Collections.Generic.List`1::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig specialname + instance string get_FirstItem() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (class MyTestModule/DerivedWithoutNull V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldc.i4.0 + IL_0004: tail. + IL_0006: callvirt instance !0 class [runtime]System.Collections.Generic.List`1::get_Item(int32) + IL_000b: ret + } + + .property instance string FirstItem() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .get instance string MyTestModule/DerivedWithoutNull::get_FirstItem() + } + } + + .class interface abstract auto ansi serializable nested public beforefieldinit ICanGetAnything`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .method public hidebysig abstract virtual + instance !T Get() cil managed + { + } + + } + + .class auto ansi serializable nested public MyClassImplementingTheSameInterface + extends [runtime]System.Object + implements class MyTestModule/ICanGetAnything`1>, + class MyTestModule/ICanGetAnything`1>>, + class MyTestModule/ICanGetAnything`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .interfaceimpl type class MyTestModule/ICanGetAnything`1> + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 02 00 00 ) + .interfaceimpl type class MyTestModule/ICanGetAnything`1 + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 02 00 00 00 01 02 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method private hidebysig newslot virtual + instance string 'MyTestModule.ICanGetAnything.Get'() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .override method instance !0 class MyTestModule/ICanGetAnything`1::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldnull + IL_0003: ret + } + + .method private hidebysig newslot virtual + instance class [runtime]System.Collections.Generic.List`1> + 'MyTestModule.ICanGetAnything>>.Get'() cil managed + { + .override method instance !0 class MyTestModule/ICanGetAnything`1>>::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: newobj instance void class [runtime]System.Collections.Generic.List`1>::.ctor() + IL_0007: ret + } + + .method private hidebysig newslot virtual + instance class [runtime]System.Collections.Generic.List`1 + 'MyTestModule.ICanGetAnything>.Get'() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .override method instance !0 class MyTestModule/ICanGetAnything`1>::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldnull + IL_0003: ret + } + + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public uint8[] NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8[] NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.netcore.bsl new file mode 100644 index 00000000000..6d3e0775b13 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullableInheritance.fs.il.netcore.bsl @@ -0,0 +1,209 @@ + + + + + +.assembly extern runtime { } +.assembly extern System.Collections +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 8:0:0:0 +} +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public DerivedWhichAllowsNull + extends class [System.Collections]System.Collections.Generic.List`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 02 00 00 00 01 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void class [System.Collections]System.Collections.Generic.List`1::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig specialname + instance string get_FirstItem() cil managed + { + .param [0] + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 4 + .locals init (class MyTestModule/DerivedWhichAllowsNull V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldc.i4.0 + IL_0004: tail. + IL_0006: callvirt instance !0 class [System.Collections]System.Collections.Generic.List`1::get_Item(int32) + IL_000b: ret + } + + .property instance string FirstItem() + { + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .get instance string MyTestModule/DerivedWhichAllowsNull::get_FirstItem() + } + } + + .class auto ansi serializable nested public DerivedWithoutNull + extends class [System.Collections]System.Collections.Generic.List`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void class [System.Collections]System.Collections.Generic.List`1::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig specialname + instance string get_FirstItem() cil managed + { + + .maxstack 4 + .locals init (class MyTestModule/DerivedWithoutNull V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldarg.0 + IL_0003: ldc.i4.0 + IL_0004: tail. + IL_0006: callvirt instance !0 class [System.Collections]System.Collections.Generic.List`1::get_Item(int32) + IL_000b: ret + } + + .property instance string FirstItem() + { + .get instance string MyTestModule/DerivedWithoutNull::get_FirstItem() + } + } + + .class interface abstract auto ansi serializable nested public beforefieldinit ICanGetAnything`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .method public hidebysig abstract virtual + instance !T Get() cil managed + { + } + + } + + .class auto ansi serializable nested public MyClassImplementingTheSameInterface + extends [runtime]System.Object + implements class MyTestModule/ICanGetAnything`1>, + class MyTestModule/ICanGetAnything`1>>, + class MyTestModule/ICanGetAnything`1 + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .interfaceimpl type class MyTestModule/ICanGetAnything`1> + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 02 00 00 ) + .interfaceimpl type class MyTestModule/ICanGetAnything`1 + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 02 00 00 00 01 02 00 00 ) + .method public specialname rtspecialname + instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method private hidebysig newslot virtual + instance string 'MyTestModule.ICanGetAnything.Get'() cil managed + { + .param [0] + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .override method instance !0 class MyTestModule/ICanGetAnything`1::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldnull + IL_0003: ret + } + + .method private hidebysig newslot virtual + instance class [System.Collections]System.Collections.Generic.List`1> + 'MyTestModule.ICanGetAnything>>.Get'() cil managed + { + .override method instance !0 class MyTestModule/ICanGetAnything`1>>::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: newobj instance void class [System.Collections]System.Collections.Generic.List`1>::.ctor() + IL_0007: ret + } + + .method private hidebysig newslot virtual + instance class [System.Collections]System.Collections.Generic.List`1 + 'MyTestModule.ICanGetAnything>.Get'() cil managed + { + .param [0] + .custom instance void [runtime]System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .override method instance !0 class MyTestModule/ICanGetAnything`1>::Get() + + .maxstack 3 + .locals init (class MyTestModule/MyClassImplementingTheSameInterface V_0) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldnull + IL_0003: ret + } + + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 0c9774032e8..c7bc6a47755 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -74,6 +74,11 @@ let ``Generic struct DU`` compilation = compilation |> verifyCompilation DoNotOptimize +[] +let ``Nullable inheritance`` compilation = + compilation + |> verifyCompilation DoNotOptimize + module Interop = open System.IO diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs index 279bb55e3dc..12f171de5fa 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs @@ -122,17 +122,36 @@ module B = C | [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> Assert.Pass() | content -> Assert.Fail($"Unexpected content: {content}") -[] -let ``Invalid nested module should just be ignored`` () = - let content = - getContent - false - """ -module A -module B.C -""" +module InvalidSyntax = - match content with - | [ TopLevelNamespace "" [] ] -> Assert.Pass() - | content -> Assert.Fail($"Unexpected content: {content}") + [] + let ``Nested module`` () = + let content = + getContent + false + """ + module A + + module B.C + """ + + match content with + | [ TopLevelNamespace "" [] ] -> Assert.Pass() + | content -> Assert.Fail($"Unexpected content: {content}") + + + [] + let ``Module above namespace`` () = + let content = + getContent + false + """ + module + + namespace A.B.C + """ + + match content with + | [ TopLevelNamespace "" [] ] -> Assert.Pass() + | content -> Assert.Fail($"Unexpected content: {content}") diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 954fca3437d..7dd8098aeb9 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -7,6 +7,22 @@ ! AssemblyReference: System.Reflection.Emit.ILGeneration ! AssemblyReference: System.Reflection.Metadata ! AssemblyReference: netstandard +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntImplIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntImplIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntfIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntfIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar TypeIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_TypeIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object, System.Collections.IEqualityComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object, System.Collections.IComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode(System.Collections.IEqualityComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: System.String ToString() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Void .ctor(j__TPar, j__TPar, j__TPar) FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 CDecl FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 Default FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 FastCall @@ -1540,7 +1556,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs Properties FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs get_Properties() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls SecurityDecls FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls get_SecurityDecls() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]]]) FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess Access FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess get_Access() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefLayout Layout @@ -1555,12 +1571,14 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Collections.FSharpList FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType] get_Implements() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType] Extends FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType] get_Extends() +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]] ImplementsCustomAttrs +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]] get_ImplementsCustomAttrs() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes Attributes FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes get_Attributes() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String Name FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String get_Name() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess Item FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess get_Item() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Tags: Int32 Nested diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 954fca3437d..7dd8098aeb9 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -7,6 +7,22 @@ ! AssemblyReference: System.Reflection.Emit.ILGeneration ! AssemblyReference: System.Reflection.Metadata ! AssemblyReference: netstandard +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntImplIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntImplIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar IntfIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_IntfIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar TypeIdx +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: j__TPar get_TypeIdx() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Boolean Equals(System.Object, System.Collections.IEqualityComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 CompareTo(System.Object, System.Collections.IComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Int32 GetHashCode(System.Collections.IEqualityComparer) +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: System.String ToString() +<>f__AnonymousType10003411232265`3[j__TPar,j__TPar,j__TPar]: Void .ctor(j__TPar, j__TPar, j__TPar) FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 CDecl FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 Default FSharp.Compiler.AbstractIL.IL+ILArgConvention+Tags: Int32 FastCall @@ -1540,7 +1556,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs Properties FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs get_Properties() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls SecurityDecls FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls get_SecurityDecls() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]]]) FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess Access FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess get_Access() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefLayout Layout @@ -1555,12 +1571,14 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Collections.FSharpList FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType] get_Implements() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType] Extends FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType] get_Extends() +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]] ImplementsCustomAttrs +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]] get_ImplementsCustomAttrs() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes Attributes FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes get_Attributes() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String Name FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String get_Name() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.AbstractIL.IL+ILAttributesStored,System.Int32]]], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess Item FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess get_Item() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Tags: Int32 Nested diff --git a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj index 13add70323f..fe6d95f9050 100644 --- a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj +++ b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj @@ -4,6 +4,7 @@ net8.0 true HistoricalBenchmark.Utilities + $(NoWarn);NETSDK1206 diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/BackgroundCompilerBenchmarks.fs b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/BackgroundCompilerBenchmarks.fs index 528557fa3d7..b7ed2a4b78d 100644 --- a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/BackgroundCompilerBenchmarks.fs +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/BackgroundCompilerBenchmarks.fs @@ -225,7 +225,7 @@ type TestProjectType = [] [] [] -[] +[] type TransparentCompilerBenchmark() = let size = 30 diff --git a/tests/scripts/update-baselines.fsx b/tests/scripts/update-baselines.fsx index 06e9c13ef80..6cc8631d898 100644 --- a/tests/scripts/update-baselines.fsx +++ b/tests/scripts/update-baselines.fsx @@ -1,13 +1,13 @@ open System open System.IO -// this script is usefull for tests using a .bsl file (baseline) containing expected compiler output +// this script is useful for tests using a .bsl file (baseline) containing expected compiler output // which is matched against .vserr or .err file aside once the test has run // the script replaces all the .bsl/.bslpp with either .err or .vserr let diff path1 path2 = let result = System.Text.StringBuilder() - let append s = result.AppendLine s |> ignore + let append (s: string) = result.AppendLine s |> ignore if not <| File.Exists(path1) then failwithf "Invalid path %s" path1 if not <| File.Exists(path2) then failwithf "Invalid path %s" path2 diff --git a/tests/service/ModuleReaderCancellationTests.fs b/tests/service/ModuleReaderCancellationTests.fs index a401c637fe6..930791b0ca6 100644 --- a/tests/service/ModuleReaderCancellationTests.fs +++ b/tests/service/ModuleReaderCancellationTests.fs @@ -115,7 +115,7 @@ type PreTypeDefData = let typeAttributes = TypeAttributes.Public let customAttrs = mkILCustomAttrs [] - ILTypeDef(this.Name, typeAttributes, ILTypeDefLayout.Auto, [], [], + ILTypeDef(this.Name, typeAttributes, ILTypeDefLayout.Auto, [], None, [], None, methodsDefs, mkILTypeDefs [], mkILFields [], emptyILMethodImpls, mkILEvents [], mkILProperties [], false, emptyILSecurityDecls, customAttrs) diff --git a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs index c0682607360..6e3de8133f1 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs @@ -447,7 +447,7 @@ module private CheckerExtensions = ) = cancellableTask { - if document.Project.UseTransparentCompiler then + if checker.UsesTransparentCompiler then return! checker.ParseAndCheckDocumentUsingTransparentCompiler(document, options, userOpName) else let allowStaleResults = diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs index 69d6456e378..cd3bbdd2bfc 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs @@ -800,6 +800,24 @@ in x "$\"{(id 3)}\"", "$\"{id 3}\"" "$\"{(x)}\"", "$\"{x}\"" + "$\"{(if true then 1 else 0)}\"", "$\"{if true then 1 else 0}\"" + "$\"{(if true then 1 else 0):N0}\"", "$\"{(if true then 1 else 0):N0}\"" + "$\"{(if true then 1 else 0),-3}\"", "$\"{(if true then 1 else 0),-3}\"" + "$\"{(match () with () -> 1):N0}\"", "$\"{(match () with () -> 1):N0}\"" + "$\"{(match () with () -> 1),-3}\"", "$\"{(match () with () -> 1),-3}\"" + "$\"{(try () with _ -> 1):N0}\"", "$\"{(try () with _ -> 1):N0}\"" + "$\"{(try () with _ -> 1),-3}\"", "$\"{(try () with _ -> 1),-3}\"" + "$\"{(try 1 finally ()):N0}\"", "$\"{(try 1 finally ()):N0}\"" + "$\"{(try 1 finally ()),-3}\"", "$\"{(try 1 finally ()),-3}\"" + "$\"{(let x = 3 in x):N0}\"", "$\"{(let x = 3 in x):N0}\"" + "$\"{(let x = 3 in x),-3}\"", "$\"{(let x = 3 in x),-3}\"" + "$\"{(do (); 3):N0}\"", "$\"{(do (); 3):N0}\"" + "$\"{(do (); 3),-3}\"", "$\"{(do (); 3),-3}\"" + "$\"{(x <- 3):N0}\"", "$\"{(x <- 3):N0}\"" + "$\"{(x <- 3),-3}\"", "$\"{(x <- 3),-3}\"" + "$\"{(1, 2):N0}\"", "$\"{(1, 2):N0}\"" + "$\"{(1, 2),-3}\"", "$\"{(1, 2),-3}\"" + """ $"{(3 + LanguagePrimitives.GenericZero):N0}" """,