Skip to content

Commit 8bed194

Browse files
authored
Compute ValInline.Never for externs (#15274)
* Compute ValInline.Never for externs
1 parent ae8d3dd commit 8bed194

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/Compiler/Checking/CheckExpressions.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,18 +2224,21 @@ module GeneralizationHelpers =
22242224
//-------------------------------------------------------------------------
22252225

22262226
let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable g attrs m =
2227-
let hasNoCompilerInliningAttribute() = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs
2228-
let isCtorOrAbstractSlot() =
2227+
let hasNoCompilerInliningAttribute () = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs
2228+
2229+
let isCtorOrAbstractSlot () =
22292230
match memFlagsOption with
22302231
| None -> false
22312232
| Some x -> (x.MemberKind = SynMemberKind.Constructor) || x.IsDispatchSlot || x.IsOverrideOrExplicitImpl
22322233

2234+
let isExtern () = HasFSharpAttributeOpt g g.attrib_DllImportAttribute attrs
2235+
22332236
let inlineFlag, reportIncorrectInlineKeywordUsage =
22342237
// Mutable values may never be inlined
22352238
// Constructors may never be inlined
22362239
// Calls to virtual/abstract slots may never be inlined
22372240
// Values marked with NoCompilerInliningAttribute or [<MethodImpl(MethodImplOptions.NoInlining)>] may never be inlined
2238-
if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() then
2241+
if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() || isExtern () then
22392242
ValInline.Never, errorR
22402243
elif HasMethodImplNoInliningAttribute g attrs then
22412244
ValInline.Never,

src/fsc/fsc.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@
4040
</NoneSubstituteText>
4141
</ItemGroup>
4242

43+
<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' != 'true'">
44+
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
45+
</ItemGroup>
46+
47+
<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' == 'true'">
48+
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreShippedPackageVersionValue)" />
49+
</ItemGroup>
50+
4351
<ItemGroup>
44-
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Core/FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
4552
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Build/FSharp.Build.fsproj" />
4653
<ProjectReference Include="$(MSBuildThisFileDirectory)../Compiler/FSharp.Compiler.Service.fsproj" />
4754
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj" />

src/fsi/fsi.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@
4545
</NoneSubstituteText>
4646
</ItemGroup>
4747

48+
<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' != 'true'">
49+
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
50+
</ItemGroup>
51+
52+
<ItemGroup Condition="'$(FSHARPCORE_USE_PACKAGE)' == 'true'">
53+
<PackageReference Include="FSharp.Core" Version="$(FSharpCoreShippedPackageVersionValue)" />
54+
</ItemGroup>
55+
4856
<ItemGroup>
49-
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
5057
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Compiler\FSharp.Compiler.Service.fsproj" />
5158
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Compiler.Interactive.Settings\FSharp.Compiler.Interactive.Settings.fsproj" />
5259
</ItemGroup>

0 commit comments

Comments
 (0)