From 4c200200489986bd794489e4a75b278e15c73fc4 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 30 May 2023 14:25:29 +0200 Subject: [PATCH 1/2] Compute ValInline.Never for externs --- .vscode/launch.json | 3 +++ src/Compiler/Checking/CheckExpressions.fs | 9 ++++++--- src/fsc/fsc.targets | 9 ++++++++- src/fsi/fsi.targets | 9 ++++++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a0118990e74..9b242d1f571 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -54,6 +54,9 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/artifacts/bin/fsc/Debug/net7.0/fsc.dll", "args": [ + "--target:library", + "Lib.fsi", + "Lib.fs", "${input:fscArgsPrompt}" ], "cwd": "${workspaceFolder}", diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 13075a5e6b9..9df233a9388 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -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 [] 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, diff --git a/src/fsc/fsc.targets b/src/fsc/fsc.targets index 33d98e00642..47d7ea87264 100644 --- a/src/fsc/fsc.targets +++ b/src/fsc/fsc.targets @@ -40,8 +40,15 @@ + + + + + + + + - diff --git a/src/fsi/fsi.targets b/src/fsi/fsi.targets index ecc0b56c830..4e8c6a6cbc3 100644 --- a/src/fsi/fsi.targets +++ b/src/fsi/fsi.targets @@ -45,8 +45,15 @@ + + + + + + + + - From f7f3865bc56c0ab30f13a2964c126e9391fd8194 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Tue, 30 May 2023 14:26:16 +0200 Subject: [PATCH 2/2] Compute ValInline.Never for externs --- .vscode/launch.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9b242d1f571..a0118990e74 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -54,9 +54,6 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/artifacts/bin/fsc/Debug/net7.0/fsc.dll", "args": [ - "--target:library", - "Lib.fsi", - "Lib.fs", "${input:fscArgsPrompt}" ], "cwd": "${workspaceFolder}",