Skip to content

Commit

Permalink
Compute ValInline.Never for externs (#15274)
Browse files Browse the repository at this point in the history
* Compute ValInline.Never for externs
  • Loading branch information
vzarytovskii authored May 30, 2023
1 parent ae8d3dd commit 8bed194
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,18 +2224,21 @@ module GeneralizationHelpers =
//-------------------------------------------------------------------------

let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable g attrs m =
let hasNoCompilerInliningAttribute() = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs
let isCtorOrAbstractSlot() =
let hasNoCompilerInliningAttribute () = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs

let isCtorOrAbstractSlot () =
match memFlagsOption with
| None -> false
| Some x -> (x.MemberKind = SynMemberKind.Constructor) || x.IsDispatchSlot || x.IsOverrideOrExplicitImpl

let isExtern () = HasFSharpAttributeOpt g g.attrib_DllImportAttribute attrs

let inlineFlag, reportIncorrectInlineKeywordUsage =
// Mutable values may never be inlined
// Constructors may never be inlined
// Calls to virtual/abstract slots may never be inlined
// Values marked with NoCompilerInliningAttribute or [<MethodImpl(MethodImplOptions.NoInlining)>] may never be inlined
if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() then
if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() || isExtern () then
ValInline.Never, errorR
elif HasMethodImplNoInliningAttribute g attrs then
ValInline.Never,
Expand Down
9 changes: 8 additions & 1 deletion src/fsc/fsc.targets
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@
</NoneSubstituteText>
</ItemGroup>

<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' != 'true'">
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
</ItemGroup>

<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' == 'true'">
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreShippedPackageVersionValue)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Core/FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Build/FSharp.Build.fsproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)../Compiler/FSharp.Compiler.Service.fsproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj" />
Expand Down
9 changes: 8 additions & 1 deletion src/fsi/fsi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@
</NoneSubstituteText>
</ItemGroup>

<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' != 'true'">
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
</ItemGroup>

<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' == 'true'">
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreShippedPackageVersionValue)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Compiler\FSharp.Compiler.Service.fsproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Compiler.Interactive.Settings\FSharp.Compiler.Interactive.Settings.fsproj" />
</ItemGroup>
Expand Down

0 comments on commit 8bed194

Please sign in to comment.