Skip to content
Merged
64 changes: 33 additions & 31 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,12 @@ let CheckRequiredProperties (g:TcGlobals) (env: TcEnv) (cenv: TcFileState) (minf
let details = NicePrint.multiLineStringOfPropInfos g cenv.amap mMethExpr env.DisplayEnv missingProps
errorR(Error(FSComp.SR.tcMissingRequiredMembers details, mMethExpr))

let private HasMethodImplNoInliningAttribute g attrs =
match TryFindFSharpAttribute g g.attrib_MethodImplAttribute attrs with
// NO_INLINING = 8
| Some (Attrib(_, _, [ AttribInt32Arg flags ], _, _, _, _)) -> (flags &&& 0x8) <> 0x0
| _ -> false

let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRecInfo, vscheme, attrs, xmlDoc, konst, isGeneratedEventVal) =

let g = cenv.g
Expand Down Expand Up @@ -1257,16 +1263,10 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec
errorR(Error(FSComp.SR.tcDllImportStubsCannotBeInlined(), m))
ValInline.Never
else
let implflags =
match TryFindFSharpAttribute g g.attrib_MethodImplAttribute attrs with
| Some (Attrib(_, _, [ AttribInt32Arg flags ], _, _, _, _)) -> flags
| _ -> 0x0
// MethodImplOptions.NoInlining = 0x8
let NO_INLINING = 0x8
if (implflags &&& NO_INLINING) <> 0x0 then
ValInline.Never
else
inlineFlag
if HasMethodImplNoInliningAttribute g attrs
then ValInline.Never
else inlineFlag


// CompiledName not allowed on virtual/abstract/override members
let compiledNameAttrib = TryFindFSharpStringAttribute g g.attrib_CompiledNameAttribute attrs
Expand Down Expand Up @@ -2204,26 +2204,32 @@ module GeneralizationHelpers =
// ComputeInlineFlag
//-------------------------------------------------------------------------

let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable hasNoCompilerInliningAttribute m =
let inlineFlag =
let isCtorOrAbstractSlot =
match memFlagsOption with
| None -> false
| Some x -> (x.MemberKind = SynMemberKind.Constructor) || x.IsDispatchSlot || x.IsOverrideOrExplicitImpl
let ComputeInlineFlag (memFlagsOption: SynMemberFlags option) isInline isMutable g attrs m =
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 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 may never be inlined
if isMutable || isCtorOrAbstractSlot || hasNoCompilerInliningAttribute then
ValInline.Never
// Values marked with NoCompilerInliningAttribute or [<MethodImpl(MethodImplOptions.NoInlining)>] may never be inlined
if isMutable || isCtorOrAbstractSlot() || hasNoCompilerInliningAttribute() then
ValInline.Never, errorR
elif HasMethodImplNoInliningAttribute g attrs then
ValInline.Never,
if g.langVersion.SupportsFeature LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction
then warning
else ignore
elif isInline then
ValInline.Always
ValInline.Always, ignore
else
ValInline.Optional
ValInline.Optional, ignore

if isInline && (inlineFlag <> ValInline.Always) then
errorR(Error(FSComp.SR.tcThisValueMayNotBeInlined(), m))
reportIncorrectInlineKeywordUsage (Error(FSComp.SR.tcThisValueMayNotBeInlined(), m))

inlineFlag

Expand Down Expand Up @@ -10287,10 +10293,8 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt
SynValData(valMf, SynValInfo(args, SynArgInfo({Attributes=rotRetSynAttrs; Range=mHead} :: attrs, opt, retId)), valId)
retAttribs, valAttribs, valSynData

let isVolatile = HasFSharpAttribute g g.attrib_VolatileFieldAttribute valAttribs
let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute valAttribs

let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable hasNoCompilerInliningAttribute mBinding
let isVolatile = HasFSharpAttribute g g.attrib_VolatileFieldAttribute valAttribs
let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable g valAttribs mBinding

let argAttribs =
spatsL |> List.map (SynInfo.InferSynArgInfoFromSimplePats >> List.map (SynInfo.AttribsOfArgData >> TcAttrs AttributeTargets.Parameter false))
Expand Down Expand Up @@ -11423,10 +11427,9 @@ and AnalyzeAndMakeAndPublishRecursiveValue
let bindingAttribs = TcAttributes cenv env attrTgt bindingSynAttribs

// Allocate the type inference variable for the inferred type
let ty = NewInferenceType g
let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute bindingAttribs
let ty = NewInferenceType g

let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable hasNoCompilerInliningAttribute mBinding
let inlineFlag = ComputeInlineFlag memberFlagsOpt isInline isMutable g bindingAttribs mBinding

if isMutable then errorR(Error(FSComp.SR.tcOnlyRecordFieldsAndSimpleLetCanBeMutable(), mBinding))

Expand Down Expand Up @@ -12042,7 +12045,6 @@ let TcAndPublishValSpec (cenv: cenv, env, containerInfo: ContainerInfo, declKind

let attrs = TcAttributes cenv env attrTgt synAttrs
let newOk = if canInferTypars then NewTyparsOK else NoNewTypars
let hasNoCompilerInliningAttribute = HasFSharpAttribute g g.attrib_NoCompilerInliningAttribute attrs

let valinfos, tpenv = TcValSpec cenv env declKind newOk containerInfo memFlagsOpt None tpenv synValSig attrs
let denv = env.DisplayEnv
Expand All @@ -12051,7 +12053,7 @@ let TcAndPublishValSpec (cenv: cenv, env, containerInfo: ContainerInfo, declKind

let (ValSpecResult (altActualParent, memberInfoOpt, id, enclosingDeclaredTypars, declaredTypars, ty, prelimValReprInfo, declKind)) = valSpecResult

let inlineFlag = ComputeInlineFlag (memberInfoOpt |> Option.map (fun (PrelimMemberInfo(memberInfo, _, _)) -> memberInfo.MemberFlags)) isInline mutableFlag hasNoCompilerInliningAttribute m
let inlineFlag = ComputeInlineFlag (memberInfoOpt |> Option.map (fun (PrelimMemberInfo(memberInfo, _, _)) -> memberInfo.MemberFlags)) isInline mutableFlag g attrs m

let freeInType = freeInTypeLeftToRight g false ty

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQua
featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard is not allowed for union case that takes no data."
featureCSharpExtensionAttributeNotRequired,"Allow implicit Extension attribute on declaring types, modules"
featureErrorForNonVirtualMembersOverrides,"Raises errors for non-virtual members overrides"
featureWarningWhenInliningMethodImplNoInlineMarkedFunction,"Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined."
featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals"
3353,fsiInvalidDirective,"Invalid directive '#%s %s'"
3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
Expand Down
7 changes: 5 additions & 2 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type LanguageFeature =
| MatchNotAllowedForUnionCaseWithNoData
| CSharpExtensionAttributeNotRequired
| ErrorForNonVirtualMembersOverrides
| WarningWhenInliningMethodImplNoInlineMarkedFunction
| EscapeDotnetFormattableStrings
| ArithmeticInLiterals

Expand Down Expand Up @@ -132,6 +133,7 @@ type LanguageVersion(versionText) =
LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion
LanguageFeature.CSharpExtensionAttributeNotRequired, previewVersion
LanguageFeature.ErrorForNonVirtualMembersOverrides, previewVersion
LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction, previewVersion
LanguageFeature.EscapeDotnetFormattableStrings, previewVersion
LanguageFeature.ArithmeticInLiterals, previewVersion

Expand Down Expand Up @@ -242,8 +244,9 @@ type LanguageVersion(versionText) =
| LanguageFeature.InterfacesWithAbstractStaticMembers -> FSComp.SR.featureInterfacesWithAbstractStaticMembers ()
| LanguageFeature.SelfTypeConstraints -> FSComp.SR.featureSelfTypeConstraints ()
| LanguageFeature.MatchNotAllowedForUnionCaseWithNoData -> FSComp.SR.featureMatchNotAllowedForUnionCaseWithNoData ()
| LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired ()
| LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides ()
| LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired ()
| LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides ()
| LanguageFeature.WarningWhenInliningMethodImplNoInlineMarkedFunction -> FSComp.SR.featureWarningWhenInliningMethodImplNoInlineMarkedFunction ()
| LanguageFeature.EscapeDotnetFormattableStrings -> FSComp.SR.featureEscapeBracesInFormattableString ()
| LanguageFeature.ArithmeticInLiterals -> FSComp.SR.featureArithmeticInLiterals ()

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type LanguageFeature =
| MatchNotAllowedForUnionCaseWithNoData
| CSharpExtensionAttributeNotRequired
| ErrorForNonVirtualMembersOverrides
| WarningWhenInliningMethodImplNoInlineMarkedFunction
| EscapeDotnetFormattableStrings
| ArithmeticInLiterals

Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">reprezentace struktury aktivních vzorů</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">zástupný znak ve smyčce for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">Strukturdarstellung für aktive Muster</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">Platzhalter in for-Schleife</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">representación de struct para modelos activos</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">carácter comodín en bucle for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">représentation de structure pour les modèles actifs</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">caractère générique dans une boucle for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">rappresentazione struct per criteri attivi</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">carattere jolly nel ciclo for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">アクティブなパターンの構造体表現</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">for ループのワイルド カード</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">활성 패턴에 대한 구조체 표현</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">for 루프의 와일드카드</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">reprezentacja struktury aktywnych wzorców</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">symbol wieloznaczny w pętli for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">representação estrutural para padrões ativos</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">curinga para loop</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">представление структуры для активных шаблонов</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">подстановочный знак в цикле for</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">etkin desenler için yapı gösterimi</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">for döngüsünde joker karakter</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@
<target state="translated">活动模式的结构表示形式</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="new">Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</target>
<note />
</trans-unit>
<trans-unit id="featureWildCardInForLoop">
<source>wild card in for loop</source>
<target state="translated">for 循环中的通配符</target>
Expand Down
Loading