From baf99e8d76a3afffa6d4a9ab275bd0db51751345 Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 00:39:29 +0200 Subject: [PATCH 1/8] Add language feature and baselines tests --- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + .../DelegateGenericInstanceMethod.fs | 13 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 179 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 179 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 139 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 139 ++++++ .../DelegateGenericStaticMethod.fs | 16 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 171 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 171 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 156 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 156 ++++++ .../DirectDelegates/DelegateInstanceMethod.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 295 ++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 295 ++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 223 +++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 223 +++++++++ .../DirectDelegates/DelegateKnownFunction.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 209 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 209 ++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 187 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 187 ++++++++ .../DirectDelegates/DelegateNegativeCases.fs | 14 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 203 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 203 ++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 182 +++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 182 +++++++ .../DirectDelegates/DelegateNonInlinable.fs | 56 +++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 447 ++++++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 447 ++++++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 445 +++++++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 445 +++++++++++++++++ .../DelegatePartialApplication.fs | 27 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 270 +++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 270 +++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 195 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 195 ++++++++ .../DirectDelegates/DelegateStaticMethod.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 215 +++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 215 +++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 193 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 193 ++++++++ .../DirectDelegates/DelegateUnitArg.fs | 11 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 114 +++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 114 +++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 110 +++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 110 +++++ .../DirectDelegates/DirectDelegates.fs | 120 +++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../Language/CodeQuotationTests.fs | 36 ++ 64 files changed, 8293 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index d29b5d3dde7..54132f2b406 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1822,3 +1822,4 @@ featurePreprocessorElif,"#elif preprocessor directive" 3889,tastNamespaceAndTypeWithSameNameInAssembly,"The namespace '%s' clashes with the type '%s'." featureExceptionFieldSerializationSupport,"emit GetObjectData and field-restoring deserialization constructor for exception types" featureErrorOnMissingSignatureAttribute,"error (rather than warning) when an enforced compiler-semantic attribute is present in the .fs but missing from the .fsi" +featureDirectDelegateConstruction,"construct delegates that point directly at the target method, avoiding an intermediate closure" diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index da4ef690311..04f0e89dcfc 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -110,6 +110,7 @@ type LanguageFeature = | PreprocessorElif | ExceptionFieldSerializationSupport | ErrorOnMissingSignatureAttribute + | DirectDelegateConstruction /// LanguageVersion management type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) = @@ -263,6 +264,7 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) LanguageFeature.MethodOverloadsCache, previewVersion // Performance optimization for overload resolution LanguageFeature.ImplicitDIMCoverage, languageVersion110 LanguageFeature.ErrorOnMissingSignatureAttribute, previewVersion // Opt-in: turn FS3888 from warning into error + LanguageFeature.DirectDelegateConstruction, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -459,6 +461,7 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) | LanguageFeature.PreprocessorElif -> FSComp.SR.featurePreprocessorElif () | LanguageFeature.ExceptionFieldSerializationSupport -> FSComp.SR.featureExceptionFieldSerializationSupport () | LanguageFeature.ErrorOnMissingSignatureAttribute -> FSComp.SR.featureErrorOnMissingSignatureAttribute () + | LanguageFeature.DirectDelegateConstruction -> FSComp.SR.featureDirectDelegateConstruction () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 5ba352191af..51c41a951c9 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -101,6 +101,7 @@ type LanguageFeature = | PreprocessorElif | ExceptionFieldSerializationSupport | ErrorOnMissingSignatureAttribute + | DirectDelegateConstruction /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 3ea52c5b169..7ed8ac66b89 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding vzor discard ve vazbě použití diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f9fc62909ef..d6313dda61c 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding Das Verwerfen des verwendeten Musters ist verbindlich. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index eca7c688eed..10d4c46c8a6 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding descartar enlace de patrón en uso diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 0922cee5acd..2687a44b909 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding annuler le modèle dans la liaison d’utilisation diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index d39f0a33a85..7f955c5add6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding rimuovi criterio nell'utilizzo dell'associazione diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6f4969e8148..f65cdf8b0cf 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 使用バインドでパターンを破棄する diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fb488a6c240..fe21f373d13 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 사용 중인 패턴 바인딩 무시 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 2720c59fc22..47b24cf0213 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding odrzuć wzorzec w powiązaniu użycia diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8fc5566545f..ef601ecc0a6 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding descartar o padrão em uso de associação diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 16eb9766b81..59779a48068 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding шаблон отмены в привязке использования diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index da5fd475a81..6a8ba91016c 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding kullanım bağlamasında deseni at diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index c43aa519603..16ab595ccfa 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 放弃使用绑定模式 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index d287b294184..960719ebb8b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 捨棄使用繫結中的模式 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs new file mode 100644 index 00000000000..6f3e738f6fa --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -0,0 +1,13 @@ +module DelegateGenericInstanceMethod + +open System + +type C() = + member _.IMc<'T> (x: 'T) (y: 'T) : unit = () + member _.IMt<'T> (x: 'T, y: 'T) : unit = () + +// 13. eta-expanded, generic instance method, curried application +let case13_etaCurried (o: C) = Action(fun a b -> o.IMc a b) + +// 14. eta-expanded, generic instance method, tupled application +let case14_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b9299772df1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,179 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMc(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMt(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b9299772df1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,179 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMc(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMt(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..6836a936968 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..6836a936968 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs new file mode 100644 index 00000000000..b48e9130735 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -0,0 +1,16 @@ +module DelegateGenericStaticMethod + +open System + +type G<'U> = + static member SMc<'T> (x: 'T) (y: 'T) : unit = () + static member SMt<'T> (x: 'T, y: 'T) : unit = () + +// 7. non-eta-expanded generic static method (generic type + generic method) +let case7_nonEta () = Action(G.SMc) + +// 8. eta-expanded, curried application +let case8_etaCurried () = Action(fun a b -> G.SMc a b) + +// 9. eta-expanded, tupled application +let case9_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..23269e8fd6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,171 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 G`1 + extends [runtime]System.Object + { + .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 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMt(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..91c5b9cd522 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,171 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 G`1 + extends [runtime]System.Object + { + .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 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMt(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..e6bb3aa83fc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,156 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 G`1 + extends [runtime]System.Object + { + .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 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..e6bb3aa83fc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,156 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 G`1 + extends [runtime]System.Object + { + .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 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs new file mode 100644 index 00000000000..1701b1c35e6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -0,0 +1,21 @@ +module DelegateInstanceMethod + +open System + +type C(k: int) = + member _.AddC (x: int) (y: int) : unit = ignore k + member _.AddT (x: int, y: int) : unit = ignore k + abstract V : int -> int -> unit + default _.V (x: int) (y: int) : unit = ignore k + +// 10. non-eta-expanded instance method target +let case10_nonEta (o: C) = Action(o.AddC) + +// 11. eta-expanded, curried application +let case11_etaCurried (o: C) = Action(fun a b -> o.AddC a b) + +// 12. eta-expanded, tupled application +let case12_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) + +// virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let caseVirtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b908fa4c200 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,295 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddT(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b908fa4c200 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,295 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddT(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..44b0b4cbbd5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,223 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..44b0b4cbbd5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,223 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs new file mode 100644 index 00000000000..e89b00afc72 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -0,0 +1,21 @@ +module DelegateKnownFunction + +open System + +// known F# functions compiled as methods +let handlerCurried (x: int) (y: int) : unit = () +let handlerTupled (x: int, y: int) : unit = () +let handler3 (x: int) (y: int) (z: int) : unit = () + +// 1. non-eta-expanded known target +let case1_nonEta () = Action(handlerCurried) + +// 2. eta-expanded known target (curried application) +let case2_etaCurried () = Action(fun a b -> handlerCurried a b) + +// 3. eta-expanded known target, tupled application, same compiled representation +let case3_etaTupled () = Action(fun a b -> handlerTupled (a, b)) + +// 15. non-eta-expanded known target via partial application +// (currently a closure with "delegateArg0"-style names; proposal: use elided arg names y, z) +let case15_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..9c87cb38678 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,209 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerTupled(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly::handler3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..9c87cb38678 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,209 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerTupled(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly::handler3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..548f0ecb854 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,187 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..548f0ecb854 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,187 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs new file mode 100644 index 00000000000..8f177b36053 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -0,0 +1,14 @@ +module DelegateNegativeCases + +open System + +// first-class function value: there is no target method to point at, so a closure must remain +let firstClass (handler: int -> int -> unit) = Action(handler) + +// lambda body is not a single direct forwarding call to a known target (the argument is computed, +// not the delegate parameters forwarded as-is): a closure must remain +let private sink (x: int) : unit = () +let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) + +// arguments reordered: not a transparent forwarding, so a closure must remain +let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..32cd386fabb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,203 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/notDirect@11::k + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0009: add + IL_000a: call void assembly::sink(int32) + IL_000f: nop + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..32cd386fabb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,203 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/notDirect@11::k + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0009: add + IL_000a: call void assembly::sink(int32) + IL_000f: nop + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..39878c4a64b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,182 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..39878c4a64b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,182 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs new file mode 100644 index 00000000000..fb8979eee4f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -0,0 +1,56 @@ +module DelegateNonInlinable + +open System + +// Section D, bullet 1: the optimizer inlines small function bodies before IlxGen runs. If a delegate +// target is inlined away in release/Optimize+ builds, the forwarding call no longer survives and the +// direct-delegate recognizer has nothing to fire on. To prove the release path is actually exercised we +// need targets the optimizer will NOT inline. [] forces ValInline.Never, so the +// forwarding call is guaranteed to reach IlxGen regardless of how small the body is (see +// ComputeInlineFlag in CheckExpressions.fs). Bodies are arithmetic only (TFM-stable, no BCL calls) and +// Func<_,_,_> is used so the result is observable. + +[] +let accCurried (x: int) (y: int) : int = x + y + +[] +let accTupled (x: int, y: int) : int = x + y + +// non-inlinable known target, non-eta-expanded +let niNonEta () = Func(accCurried) + +// non-inlinable known target, eta-expanded, curried application +let niEtaCurried () = Func(fun a b -> accCurried a b) + +// non-inlinable known target, eta-expanded, tupled application +let niEtaTupled () = Func(fun a b -> accTupled (a, b)) + +type S = + [] + static member AccS (x: int) (y: int) : int = x + y + +// non-inlinable static target, non-eta-expanded +let niStaticNonEta () = Func(S.AccS) + +// non-inlinable static target, eta-expanded +let niStaticEta () = Func(fun a b -> S.AccS a b) + +type C(k: int) = + [] + member _.AccC (x: int) (y: int) : int = x + y + k + +// non-inlinable instance target, non-eta-expanded +let niInstanceNonEta (o: C) = Func(o.AccC) + +// non-inlinable instance target, eta-expanded +let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) + +// Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and +// guard the inline-vs-direct interaction. In release the optimizer may inline the body before the +// recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) +// for this to still become a direct delegate. +let trivial (x: int) (y: int) : int = x + y + +let niTrivialNonEta () = Func(trivial) + +let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..3d35edadfa8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,447 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 S + extends [runtime]System.Object + { + .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 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..78ddf50dac2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,447 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 S + extends [runtime]System.Object + { + .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 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..dd5dc76e043 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,445 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 S + extends [runtime]System.Object + { + .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 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..7fa0f5a0c7d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,445 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 S + extends [runtime]System.Object + { + .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 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs new file mode 100644 index 00000000000..8b12ee25545 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -0,0 +1,27 @@ +module DelegatePartialApplication + +open System + +// Section D, bullet 2: cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// constant first argument, so their closure can stay static (the constant is re-materialised in Invoke +// with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance +// field, which exercises a distinct emit path. None of these can ever become a direct delegate (the +// target has more parameters than the delegate's Invoke), so a closure must remain regardless of +// langversion; the only proposed change here is friendlier elided argument names. + +let handler3 (x: int) (y: int) (z: int) : unit = () + +type C = + static member Add3 (x: int) (y: int) (z: int) : unit = () + +type I(k: int) = + member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k + +// variable-capture partial application of a known function (instance-field capture of n) +let papKnownVar (n: int) = Action(handler3 n) + +// variable-capture partial application of a static method +let papStaticVar (n: int) = Action(C.Add3 n) + +// variable-capture partial application of an instance method (captures both the receiver and n) +let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..1b719dd6d94 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,270 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/I::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly::handler3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly/C::Add3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/I o + .field public int32 n + .method public specialname rtspecialname instance void .ctor(class assembly/I o, int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_000e: ldarg.0 + IL_000f: call instance void [runtime]System.Object::.ctor() + IL_0014: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0006: ldarg.0 + IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_000c: ldarg.1 + IL_000d: ldarg.2 + IL_000e: callvirt instance void assembly/I::Add3(int32, + int32, + int32) + IL_0013: nop + IL_0014: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + int32) + IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0012: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..fc1e7bc6303 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,270 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/I::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly::handler3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly/C::Add3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/I o + .field public int32 n + .method public specialname rtspecialname instance void .ctor(class assembly/I o, int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_000e: ldarg.0 + IL_000f: call instance void [runtime]System.Object::.ctor() + IL_0014: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0006: ldarg.0 + IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_000c: ldarg.1 + IL_000d: ldarg.2 + IL_000e: callvirt instance void assembly/I::Add3(int32, + int32, + int32) + IL_0013: nop + IL_0014: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + int32) + IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0012: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..f9efcbd168b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,195 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..afb6d8c3f64 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,195 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .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 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) 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: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs new file mode 100644 index 00000000000..5f3ec7b724e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -0,0 +1,21 @@ +module DelegateStaticMethod + +open System + +type C = + static member AddC (x: int) (y: int) : unit = () + static member AddT (x: int, y: int) : unit = () + static member Add3 (x: int) (y: int) (z: int) : unit = () + +// 4. non-eta-expanded static method target +// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) +let case4_nonEta () = Action(C.AddC) + +// 5. eta-expanded, curried application +let case5_etaCurried () = Action(fun a b -> C.AddC a b) + +// 6. eta-expanded, tupled application +let case6_etaTupled () = Action(fun a b -> C.AddT(a, b)) + +// 16. non-eta-expanded static method via partial application +let case16_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..15590de3edc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,215 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddT(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly/C::Add3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..15590de3edc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,215 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddT(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly/C::Add3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..eadfc7c3f13 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,193 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..eadfc7c3f13 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,193 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs new file mode 100644 index 00000000000..7b27fb8611b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -0,0 +1,11 @@ +module DelegateUnitArg + +open System + +let handler () : unit = () + +// unit-argument delegate, non-eta-expanded known target +let caseUnitNonEta () = Action(handler) + +// unit-argument delegate, eta-expanded +let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b91d58c4597 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,114 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b91d58c4597 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,114 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..3684e4e4a6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,110 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..3684e4e4a6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,110 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs new file mode 100644 index 00000000000..ccf7d8d41a0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -0,0 +1,120 @@ +namespace EmittedIL.RealInternalSignature + +open System.IO +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module DirectDelegates = + + let private coreOptions compilation = + compilation + |> withOptions [ "--test:EmitFeeFeeAs100001" ] + |> asExe + |> withEmbeddedPdb + |> withEmbedAllSource + |> ignoreWarnings + + // Default langversion: direct delegates must NOT be emitted (a closure is still generated). + // Baselines: ..il.bsl -- these should remain unchanged when the feature lands. + let verifyCompilation compilation = + compilation + |> coreOptions + |> compile + |> verifyILBaseline + + // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the + // very same input .fs file (no input duplication / drift) without clobbering the default baseline. + let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = + match cUnit with + | FS src -> + let baseline = + src.Baseline + |> Option.map (fun bsl -> + let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") + let content = if File.Exists path then Some(File.ReadAllText path) else None + { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) + FS { src with Baseline = baseline } + | other -> other + + // Preview langversion: direct delegates ARE emitted once the feature lands. + // Baselines: ..Preview.il.bsl -- these are the ones that will change. + let verifyPreviewCompilation compilation = + compilation + |> coreOptions + |> withLangVersionPreview + |> withPreviewBaseline + |> compile + |> verifyILBaseline + + [] + let ``DelegateKnownFunction_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateKnownFunction_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateGenericStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateGenericStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateGenericInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateGenericInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateUnitArg_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateUnitArg_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateNegativeCases_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateNegativeCases_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateNonInlinable_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateNonInlinable_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegatePartialApplication_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegatePartialApplication_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 5f8dbb26c5b..ab0d33585d1 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -260,6 +260,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 29556381221..7085bd7a3a7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -40,6 +40,42 @@ let z : unit = |> compileAndRun |> shouldSucceed + [] + let ``Delegate construction quotations are unaffected by the direct delegate optimization`` () = + Fsx """ +open System +open FSharp.Quotations.Patterns + +let handlerCurried (x: int) (y: int) : unit = () + +type C(k: int) = + member _.AddC (x: int) (y: int) : unit = ignore k + +let check (label: string) (target: string) (expr: Quotations.Expr) = + match expr with + | NewDelegate(dty, _, _) when dty = typeof> -> () + | e -> failwithf "%s: expected NewDelegate of Action, got %A" label e + if not ((string expr).Contains target) then + failwithf "%s: expected the quotation to reference target '%s', got %A" label target expr + +let o = C(1) + +// non-eta-expanded known function +check "nonEta" "handlerCurried" <@ Action(handlerCurried) @> +// eta-expanded known function +check "etaCurried" "handlerCurried" <@ Action(fun a b -> handlerCurried a b) @> +// non-eta-expanded instance method +check "instanceNonEta" "AddC" <@ Action(o.AddC) @> +// eta-expanded instance method +check "instanceEta" "AddC" <@ Action(fun a b -> o.AddC a b) @> + +printfn "ok" + """ + |> asExe + |> withLangVersionPreview + |> compileAndRun + |> shouldSucceed + [] let ``Quotation on decimal literal compiles and runs`` () = FSharp """ From 87cff9abf7f1c9624265401e0856d1763e7f60cc Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 20:16:58 +0200 Subject: [PATCH 2/8] Implementation --- src/Compiler/CodeGen/IlxGen.fs | 362 ++++++++++++++---- .../TypedTree/TypedTreeOps.ExprOps.fs | 65 ++++ .../TypedTree/TypedTreeOps.ExprOps.fsi | 26 ++ .../DelegateExtensionMethod.fs | 18 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 139 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 139 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 139 +++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 139 +++++++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateILMethod.fs | 16 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 127 ++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 127 ++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 78 ++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 127 ++++++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 85 +--- ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 43 +-- ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateNonInlinable.fs | 9 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 149 ++++--- ...RealInternalSignatureOn.OptimizeOff.il.bsl | 136 ++++++- ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 202 +++------- ....RealInternalSignatureOn.OptimizeOn.il.bsl | 128 ++++++- ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateStructTarget.fs | 15 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 317 +++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 317 +++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 284 ++++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 284 ++++++++++++++ .../DirectDelegates/DelegateUnitReturn.fs | 23 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 160 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 194 ++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 126 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 194 ++++++++++ .../DirectDelegates/DirectDelegates.fs | 183 +++++++++ 34 files changed, 3891 insertions(+), 529 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index c63398b4267..8f6b8c92711 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7462,108 +7462,302 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let ilDelegeeParams, ilDelegeeRet = GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod tmvs - let envForDelegeeMeth = - AddStorageForLocalVals g (List.mapi (fun i v -> (v, Arg(i + numthis))) tmvs) envForDelegeeUnderTypars + // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a + // known static method, module-level function, or instance method, point the delegate straight at that + // method instead of generating an intermediate closure class. For a static target the receiver is null + // (ldnull; ldftn target); for an instance target the receiver is evaluated and the function pointer is + // bound with ldftn, or dup; ldvirtftn for a virtual target so dispatch is preserved. A strict + // IL-signature check makes the rewrite provably equivalent to the closure form; anything that does not + // match exactly falls back to the closure path below. Gated by LanguageFeature.DirectDelegateConstruction. + let directDelegateTarget = + if not (g.langVersion.SupportsFeature LanguageFeature.DirectDelegateConstruction) then + None + elif + not cenv.options.localOptimizationsEnabled + && tmvs |> List.exists (fun (v: Val) -> not v.IsCompilerGenerated) + then + // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda + // variables, so keep the closure to preserve their names for debugging. Non-eta delegates (whose + // parameters are synthesized by BuildNewDelegateExpr) are always made direct; eta-expanded ones + // are made direct only in optimized builds, where debuggability is not a concern and the + // forwarding call survives to here. + None + else + match body with + | DirectDelegateForwardingCall g tmvs (target, leadingArgs) -> + // For an instance method the single leading argument is the receiver; a static method or + // module function must have no leading arguments (otherwise it is a partial application). + let receiverShapeOk takesInstanceArg = + if takesInstanceArg then + match leadingArgs with + | [ _ ] -> true + | _ -> false + else + List.isEmpty leadingArgs + + // The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound + // when it can be evaluated there exactly once and as the Target: + // - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the + // receiver on every Invoke; evaluating it once instead is observable unless it is + // side-effect free (a non-mutable value, a constant, a pure field read). + // - It must not reference the delegate's own Invoke parameters, which only exist inside the + // delegee method. + // Checked lazily (and after the cheaper structural bails) so disqualified delegates skip the + // receiver traversal; ExprHasEffect short-circuits before the freeInExpr allocation. + let receiverNotBindable () = + match leadingArgs with + | [ recv ] -> + Optimizer.ExprHasEffect g recv + || (let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals + tmvs |> List.exists (fun tv -> Zset.contains tv recvFreeLocals)) + | _ -> false - let ilMethodBody = - CodeGenMethodForExpr - cenv - cgbuf.mgbuf - ([], - delegeeMethName, - envForDelegeeMeth, - 1, - None, - body, - (if slotSigHasVoidReturnTy slotsig then - discardAndReturnVoid - else - Return)) + // The type checker has already verified that the delegate is built from a compatible function + // shape, and the structural match above forwards the Invoke parameters verbatim, so the + // target's signature is compatible with the delegate's Invoke by construction. We just confirm + // the compiled shape lines up: + // - for a non-generic target, identical parameter and return types (cheap and exact); + // - for a generic target, matching parameter count (the formal signature is written in terms + // of type variables, so an exact type comparison here is not meaningful; arity rejects + // unit-elision / param-array / tupled-arity mismatches). + // For an instance method the receiver is implicit and does not appear in FormalArgTypes. + let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + typesOfILParams ilDelegeeParams = targetMspec.FormalArgTypes + && ilDelegeeRet.Type = targetMspec.FormalReturnType + else + targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length - let delegeeInvokeMeth = - (if useStaticClosure then - mkILNonGenericStaticMethod - else - mkILNonGenericInstanceMethod) ( - delegeeMethName, - ILMemberAccess.Assembly, - ilDelegeeParams, - ilDelegeeRet, - MethodBody.IL(InterruptibleLazy.FromValue ilMethodBody) - ) + let receiverInfo virtualCall = + match leadingArgs with + | [ recv ] -> Some(recv, virtualCall) + | _ -> None - let delegeeCtorMeth = - mkILSimpleStorageCtor (Some g.ilg.typ_Object.TypeSpec, ilDelegeeTyInner, [], [], ILMemberAccess.Assembly, None, eenvouter.imports) + match target with + | DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs) -> + match StorageForValRef m vref eenvouter with + | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> + let _, witnessInfos, _, _, _ = + GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - let ilCtorBody = delegeeCtorMeth.MethodBody + let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - let ilCloLambdas = Lambdas_return ilCtxtDelTy + let _, virtualCall, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + GetMemberCallInfo g (vrefM, valUseFlags) - let cloTypeDefs = - (if useStaticClosure then - GenStaticDelegateClosureTypeDefs - else - GenClosureTypeDefs) - cenv - (ilDelegeeTypeRef, - ilDelegeeGenericParams, - [], - ilCloAllFreeVars, - ilCloLambdas, - ilCtorBody, - [ delegeeInvokeMeth ], - [], - g.ilg.typ_Object, - [], - None) + let isBaseCall = valUseFlags.IsVSlotDirectCall - for cloTypeDef in cloTypeDefs do - cgbuf.mgbuf.AddTypeDef(ilDelegeeTypeRef, cloTypeDef, false, false, None) + if + hasWitnesses + || newobj + || isSuperInit + || isSelfInit + || isBaseCall + || not (receiverShapeOk takesInstanceArg) + || receiverNotBindable () + then + None + else + let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs - CountClosure() + let numEnclILTypeArgs = + if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then + List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) + else + 0 - // Push the constructor for the delegee - let ctxtGenericArgsForDelegee = GenGenericArgs m eenvouter.tyenv cloFreeTyvars + if ilTyArgs.Length < numEnclILTypeArgs then + None + else + let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs + let boxity = mspec.DeclaringType.Boxity + let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) + + if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then + None + elif takesInstanceArg && boxity = AsValue then + // value-type receivers not handled + None + elif signatureMatches ilEnclArgTys ilMethArgTys targetMspec then + Some(targetMspec, receiverInfo virtualCall) + else + None + | _ -> None + + | DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst) -> + // A direct IL call (e.g. a BCL method). Everything needed to build the method spec is on + // the node, so there is no storage/witness resolution; we still bail on the shapes that + // have no closed direct-delegate form. + let isBaseCall = valUseFlag.IsVSlotDirectCall + + let isConstrainedCall = valUseFlag.IsPossibleConstrainedCall + + let takesInstanceArg = ilMethRef.CallingConv.IsInstance + let boxity = if isStruct then AsValue else AsObject + + if + isCtor + || isBaseCall + || isConstrainedCall + || not (receiverShapeOk takesInstanceArg) + || (takesInstanceArg && boxity = AsValue) + || receiverNotBindable () + then + None + else + let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst + let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst + let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + + // Unlike the F# case we cannot compare parameter/return IL types here: the target's + // types come from imported metadata, whose assembly scope refs differ from the + // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare + // primary-assembly form), so structural equality reports false negatives for the very + // primitives that always match. The forwarding match already pins the arity, and the + // type checker has verified the call is well-typed, so element compatibility holds by + // construction; an arity check is the sound guard (matching the generic case). + if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then + Some(targetMspec, receiverInfo isVirtual) + else + None + | _ -> None - if useStaticClosure then - GenUnit cenv eenvouter m cgbuf - else - let ilxCloSpec = - IlxClosureSpec.Create(IlxClosureRef(ilDelegeeTypeRef, ilCloLambdas, ilCloAllFreeVars), ctxtGenericArgsForDelegee, false) + match directDelegateTarget with + | Some(targetMspec, receiverInfo) -> + match receiverInfo with + | None -> + // Static target: the delegate carries a null receiver. + GenUnit cenv eenvouter m cgbuf + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn targetMspec) + | Some(receiverExpr, isVirtual) -> + // Instance target: evaluate the receiver as the delegate's target object. + GenExpr cenv cgbuf eenvouter receiverExpr Continue + + if isVirtual then + // dup the receiver and bind the function pointer to its runtime type's override. + CG.EmitInstr cgbuf (pop 0) (Push [ targetMspec.DeclaringType ]) AI_dup + CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_IntPtr ]) (I_ldvirtftn targetMspec) + else + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn targetMspec) - GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos + // newobj Delegate::.ctor(object, native int) + let ilDelegeeCtorMethOuter = + mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) - for fv in cloFreeVars do - GenGetFreeVarForClosure cenv cgbuf eenvouter m fv + CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) + GenSequel cenv eenvouter.cloc cgbuf sequel - CG.EmitInstr - cgbuf - (pop ilCloAllFreeVars.Length) - (Push [ EraseClosures.mkTyOfLambdas cenv.ilxPubCloEnv ilCloLambdas ]) - (I_newobj(ilxCloSpec.Constructor, None)) + | None -> + let envForDelegeeMeth = + AddStorageForLocalVals g (List.mapi (fun i v -> (v, Arg(i + numthis))) tmvs) envForDelegeeUnderTypars - // Push the function pointer to the Invoke method of the delegee - let ilDelegeeTyOuter = mkILBoxedTy ilDelegeeTypeRef ctxtGenericArgsForDelegee + let ilMethodBody = + CodeGenMethodForExpr + cenv + cgbuf.mgbuf + ([], + delegeeMethName, + envForDelegeeMeth, + 1, + None, + body, + (if slotSigHasVoidReturnTy slotsig then + discardAndReturnVoid + else + Return)) + + let delegeeInvokeMeth = + (if useStaticClosure then + mkILNonGenericStaticMethod + else + mkILNonGenericInstanceMethod) ( + delegeeMethName, + ILMemberAccess.Assembly, + ilDelegeeParams, + ilDelegeeRet, + MethodBody.IL(InterruptibleLazy.FromValue ilMethodBody) + ) - let ilDelegeeInvokeMethOuter = - (if useStaticClosure then - mkILNonGenericStaticMethSpecInTy - else - mkILNonGenericInstanceMethSpecInTy) ( - ilDelegeeTyOuter, - "Invoke", - typesOfILParams ilDelegeeParams, - ilDelegeeRet.Type - ) + let delegeeCtorMeth = + mkILSimpleStorageCtor ( + Some g.ilg.typ_Object.TypeSpec, + ilDelegeeTyInner, + [], + [], + ILMemberAccess.Assembly, + None, + eenvouter.imports + ) - CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn ilDelegeeInvokeMethOuter) + let ilCtorBody = delegeeCtorMeth.MethodBody - // Instantiate the delegate - let ilDelegeeCtorMethOuter = - mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) + let ilCloLambdas = Lambdas_return ilCtxtDelTy - CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) - GenSequel cenv eenvouter.cloc cgbuf sequel + let cloTypeDefs = + (if useStaticClosure then + GenStaticDelegateClosureTypeDefs + else + GenClosureTypeDefs) + cenv + (ilDelegeeTypeRef, + ilDelegeeGenericParams, + [], + ilCloAllFreeVars, + ilCloLambdas, + ilCtorBody, + [ delegeeInvokeMeth ], + [], + g.ilg.typ_Object, + [], + None) + + for cloTypeDef in cloTypeDefs do + cgbuf.mgbuf.AddTypeDef(ilDelegeeTypeRef, cloTypeDef, false, false, None) + + CountClosure() + + // Push the constructor for the delegee + let ctxtGenericArgsForDelegee = GenGenericArgs m eenvouter.tyenv cloFreeTyvars + + if useStaticClosure then + GenUnit cenv eenvouter m cgbuf + else + let ilxCloSpec = + IlxClosureSpec.Create(IlxClosureRef(ilDelegeeTypeRef, ilCloLambdas, ilCloAllFreeVars), ctxtGenericArgsForDelegee, false) + + GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos + + for fv in cloFreeVars do + GenGetFreeVarForClosure cenv cgbuf eenvouter m fv + + CG.EmitInstr + cgbuf + (pop ilCloAllFreeVars.Length) + (Push [ EraseClosures.mkTyOfLambdas cenv.ilxPubCloEnv ilCloLambdas ]) + (I_newobj(ilxCloSpec.Constructor, None)) + + // Push the function pointer to the Invoke method of the delegee + let ilDelegeeTyOuter = mkILBoxedTy ilDelegeeTypeRef ctxtGenericArgsForDelegee + + let ilDelegeeInvokeMethOuter = + (if useStaticClosure then + mkILNonGenericStaticMethSpecInTy + else + mkILNonGenericInstanceMethSpecInTy) ( + ilDelegeeTyOuter, + "Invoke", + typesOfILParams ilDelegeeParams, + ilDelegeeRet.Type + ) + + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn ilDelegeeInvokeMethOuter) + + // Instantiate the delegate + let ilDelegeeCtorMethOuter = + mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) + + CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) + GenSequel cenv eenvouter.cloc cgbuf sequel /// Used to search FSharp.Core implementations of "^T : ^T" and decide whether the conditional activates and ExprIsTraitCall expr = diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs index bdebaf40ff5..54c28c13c18 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs @@ -33,6 +33,24 @@ open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypeProviders #endif +/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). +[] +type internal DirectDelegateForwardingTarget = + /// A known F# value: a module-level function or a member. Carries the value reference, its use flags + /// and the call's type arguments; the consumer resolves storage to a method spec. + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst + /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to + /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and + /// the enclosing-type and method type instantiations. + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst + [] module internal AddressOps = @@ -1815,6 +1833,53 @@ module internal ExprTransforms = ) | _ -> ValueNone + /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding + /// call `target leading... p0 p1 ...` to a known method, whose trailing arguments are exactly the + /// delegate's Invoke parameters in order. This is the shape that lets a delegate point directly at + /// `target` instead of an intermediate closure. Any leading arguments (e.g. an instance method's + /// receiver) are returned to the consumer, which decides whether a direct delegate can actually be + /// emitted (matching IL signature, receiver shape, no witnesses, etc.). + [] + let (|DirectDelegateForwardingCall|_|) g (invokeParams: Val list) expr = + // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded + // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned + // for the consumer to handle. + let matchForwarding (args: Expr list) = + let numLeading = args.Length - invokeParams.Length + + if numLeading >= 0 then + let leadingArgs, forwardedArgs = List.splitAt numLeading args + + if + List.forall2 + (fun (a: Expr) (tv: Val) -> + match stripDebugPoints a with + | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) + | _ -> false) + forwardedArgs + invokeParams + then + ValueSome leadingArgs + else + ValueNone + else + ValueNone + + match stripDebugPoints expr with + | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> ValueSome(DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs), leadingArgs) + | ValueNone -> ValueNone + | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> + ValueSome( + DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst), + leadingArgs + ) + | ValueNone -> ValueNone + | _ -> ValueNone + [] let (|DelegateInvokeExpr|_|) g expr = match expr with diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi index ad90c5c818c..afb4874f70d 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi @@ -12,6 +12,24 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.Syntax +/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). +[] +type internal DirectDelegateForwardingTarget = + /// A known F# value: a module-level function or a member. Carries the value reference, its use flags + /// and the call's type arguments; the consumer resolves storage to a method spec. + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst + /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to + /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and + /// the enclosing-type and method type instantiations. + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst + [] module internal AddressOps = @@ -544,6 +562,14 @@ module internal ExprTransforms = [] val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption + /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding + /// call to a known method (an F# value or a direct IL call) whose trailing arguments are exactly the + /// delegate's Invoke parameters in order. Returns the resolved target and any leading (non-forwarded) + /// argument expressions, e.g. an instance method's receiver. + [] + val (|DirectDelegateForwardingCall|_|): + TcGlobals -> Val list -> Expr -> (DirectDelegateForwardingTarget * Expr list) voption + [] val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * TypeInst * Expr * Expr * range) voption diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs new file mode 100644 index 00000000000..7eba16766c9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -0,0 +1,18 @@ +module DelegateExtensionMethod + +open System +open System.Runtime.CompilerServices + +type Holder() = + class + end + +[] +type HolderExtensions = + [] + static member Combine (h: Holder, x: int, y: int) : int = x + y + +// An extension member compiles to a static method whose first parameter is the receiver, so using it as a +// delegate target binds that receiver as a leading argument - a partial application, which has no closed +// direct-delegate form. A closure must remain regardless of langversion. +let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..0b7acdc3542 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..7347dab3c0d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..0b7acdc3542 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..7347dab3c0d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 23269e8fd6b..bc63a786879 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -56,25 +56,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void class assembly/G`1::SMc(!!0, - !!0) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 extends [runtime]System.Object { @@ -118,8 +99,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void class assembly/G`1::SMc(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs new file mode 100644 index 00000000000..db933f2f73e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -0,0 +1,16 @@ +module DelegateILMethod + +open System +open System.Text + +// IL (BCL) method targets are compiled as TOp.ILCall rather than an F# value application. They are made +// direct only when the eta-expanded forwarding call survives to codegen, i.e. in optimized builds; in +// unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable +// for the F#-value equivalent. + +// Static IL method (System.Math.Max), eta-expanded. +let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) + +// Instance IL method (StringBuilder.Append(string)) on a reference type, eta-expanded. The receiver is a +// parameter, evaluated at the construction site and carried as the delegate's Target. +let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..ef4e95130a2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,78 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 ) + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index b908fa4c200..4e57d30669e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -89,39 +89,6 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance void assembly/C::AddC(int32, - int32) - IL_000d: nop - IL_000e: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 extends [runtime]System.Object { @@ -188,50 +155,16 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance void assembly/C::V(int32, - int32) - IL_000f: ret - } - - } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: ldftn instance void assembly/C::AddC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed @@ -265,12 +198,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: dup + IL_0002: ldvirtftn instance void assembly/C::V(int32, + int32) + IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl index 44b0b4cbbd5..0297f76438f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -119,39 +119,6 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance void assembly/C::V(int32, - int32) - IL_000f: ret - } - - } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed { @@ -193,12 +160,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: dup + IL_0002: ldvirtftn instance void assembly/C::V(int32, + int32) + IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 9c87cb38678..977948fe928 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -33,25 +33,6 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly::handlerCurried(int32, - int32) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 extends [runtime]System.Object { @@ -144,8 +125,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly::handlerCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index fb8979eee4f..1cf2e00e70f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -39,12 +39,21 @@ type C(k: int) = [] member _.AccC (x: int) (y: int) : int = x + y + k + [] + member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x + // non-inlinable instance target, non-eta-expanded let niInstanceNonEta (o: C) = Func(o.AccC) // non-inlinable instance target, eta-expanded let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) +// non-inlinable generic instance target, non-eta-expanded +let niGenericInstanceNonEta (o: C) = Func(o.GPick) + +// non-inlinable generic instance target, eta-expanded +let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) + // Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and // guard the inline-vs-direct interaction. In release the optimizer may inline the body before the // recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 3d35edadfa8..b31ec227850 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -86,22 +86,14 @@ IL_000a: ret } - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret + IL_0000: ldarg.1 + IL_0001: ret } } @@ -142,24 +134,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 extends [runtime]System.Object { @@ -178,7 +152,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,28 +163,29 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret } - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) - IL_000d: ret + IL_000f: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +196,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,35 +207,17 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) IL_000d: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -308,10 +265,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -323,7 +280,7 @@ IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -335,7 +292,7 @@ IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -344,10 +301,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -359,7 +316,7 @@ IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -368,12 +325,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret } .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed @@ -381,11 +337,36 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) IL_0011: ret } @@ -406,10 +387,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::trivial(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -418,10 +399,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl index 78ddf50dac2..075811968d9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -86,6 +86,16 @@ IL_000a: ret } + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + } .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 @@ -178,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -200,17 +210,18 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) - IL_000d: ret + IL_000f: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +232,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,17 +243,82 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) + IL_000f: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) IL_000d: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -260,7 +336,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -368,8 +444,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -381,14 +457,40 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + .method public static int32 trivial(int32 x, int32 y) cil managed { @@ -406,7 +508,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -418,7 +520,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl index dd5dc76e043..769f5764703 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -86,40 +86,14 @@ IL_000a: ret } - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret + IL_0000: ldarg.1 + IL_0001: ret } } @@ -142,107 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -259,7 +133,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -306,8 +180,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -318,8 +192,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -342,8 +216,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -354,8 +228,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -366,12 +240,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed @@ -379,12 +252,35 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret } .method public static int32 trivial(int32 x, @@ -404,7 +300,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -416,7 +312,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 7fa0f5a0c7d..a10586e3a2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -86,6 +86,16 @@ IL_000a: ret } + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + } .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 @@ -178,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -200,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -210,7 +220,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,7 +242,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -242,7 +252,71 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -259,7 +333,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -366,8 +440,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -379,14 +453,40 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + .method public static int32 trivial(int32 x, int32 y) cil managed { @@ -404,7 +504,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -416,7 +516,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 15590de3edc..d9c7305029d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -67,25 +67,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly/C::AddC(int32, - int32) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 extends [runtime]System.Object { @@ -150,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs new file mode 100644 index 00000000000..b7f55d44097 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -0,0 +1,15 @@ +module DelegateStructTarget + +open System + +[] +type S = + [] + member _.Add (x: int) (y: int) : int = x + y + +// The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate +// would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod +// for the reference-type case, which is emitted directly.) +let structInstanceNonEta (s: S) = Func(s.Add) + +let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..8055c451a93 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,317 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any assembly/S + IL_0007: call instance int32 assembly/S::CompareTo(valuetype assembly/S) + IL_000c: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0, + valuetype assembly/S& V_1) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: stloc.1 + IL_000a: ldc.i4.0 + IL_000b: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001d + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: ldarg.2 + IL_0017: call instance bool assembly/S::Equals(valuetype assembly/S, + class [runtime]System.Collections.IEqualityComparer) + IL_001c: ret + + IL_001d: ldc.i4.0 + IL_001e: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001c + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: call instance bool assembly/S::Equals(valuetype assembly/S) + IL_001b: ret + + IL_001c: ldc.i4.0 + IL_001d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..3c01648fc8d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,317 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any assembly/S + IL_0007: call instance int32 assembly/S::CompareTo(valuetype assembly/S) + IL_000c: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0, + valuetype assembly/S& V_1) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: stloc.1 + IL_000a: ldc.i4.0 + IL_000b: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001d + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: ldarg.2 + IL_0017: call instance bool assembly/S::Equals(valuetype assembly/S, + class [runtime]System.Collections.IEqualityComparer) + IL_001c: ret + + IL_001d: ldc.i4.0 + IL_001e: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001c + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: call instance bool assembly/S::Equals(valuetype assembly/S) + IL_001b: ret + + IL_001c: ldc.i4.0 + IL_001d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..1cbf8a76d65 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,284 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..ae22fd38d8a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,284 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .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 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs new file mode 100644 index 00000000000..7e2b1c5e31a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -0,0 +1,23 @@ +module DelegateUnitReturn + +open System + +// Target returns unit, compiled to void; delegate (Action) returns void. +[] +let returnsUnit (x: int) (y: int) : unit = () + +let voidNonEta () = Action(returnsUnit) + +let voidEta () = Action(fun a b -> returnsUnit a b) + +type C = + // Generic method returning its own type variable; instantiated to unit below. The compiled method + // returns the type variable (System.Unit once instantiated), not void - a distinct case from the + // void-returning member above. + [] + static member Echo<'T>(x: 'T) : 'T = x + +// Generic return type variable instantiated to unit; the delegate likewise returns unit. +let unitGenericReturnNonEta () = Func(C.Echo) + +let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..1ac412d919c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,160 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..2169ff70e6f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,194 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..02e82fd6e93 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,126 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..2169ff70e6f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,194 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 C + extends [runtime]System.Object + { + .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 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index ccf7d8d41a0..8ab3fa33684 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -118,3 +118,186 @@ module DirectDelegates = [] let ``DelegatePartialApplication_fs preview`` compilation = compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateUnitReturn_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateUnitReturn_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateStructTarget_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateStructTarget_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateExtensionMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateExtensionMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateILMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateILMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``Direct delegates target the real method and dispatch correctly (preview)`` () = + FSharp """ +module DirectDelegateExecution + +open System + +[] +let add (x: int) (y: int) : int = x + y + +type G<'U> = + [] + static member Pick<'T>(x: 'T) (y: 'T) : 'T = x + +[] +type Base() = + abstract M: int -> int + +type Derived() = + inherit Base() + override _.M x = x + 100 + +[] +let main _ = + // Non-eta known function: the delegate points directly at 'add'. + let d = Func(add) + if d.Invoke(2, 3) <> 5 then failwith "add: wrong result" + if d.Method.Name <> "add" then failwithf "add: expected Method.Name 'add' but got '%s'" d.Method.Name + + // Non-eta generic method on a generic type: the delegate points directly at the fully instantiated method. + let gd = Func(G.Pick) + if gd.Invoke(7, 9) <> 7 then failwithf "generic: expected 7 but got %d" (gd.Invoke(7, 9)) + if gd.Method.Name <> "Pick" then failwithf "generic: expected Method.Name 'Pick' but got '%s'" gd.Method.Name + + // Non-eta virtual instance method: dup; ldvirtftn must preserve override dispatch. + let b: Base = Derived() + let vd = Func(b.M) + if vd.Invoke 1 <> 101 then failwithf "virtual: expected 101 but got %d" (vd.Invoke 1) + if vd.Method.Name <> "M" then failwithf "virtual: expected Method.Name 'M' but got '%s'" vd.Method.Name + if not (obj.ReferenceEquals(vd.Target, b)) then failwith "virtual: Target is not the receiver" + + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + + [] + let ``Without the feature the delegate goes through a closure (default langversion)`` () = + FSharp """ +module ClosureDelegateExecution + +open System + +[] +let add (x: int) (y: int) : int = x + y + +[] +let main _ = + let d = Func(add) + if d.Invoke(2, 3) <> 5 then failwith "add: wrong result" + // Without the feature the delegate is built over a generated closure method named 'Invoke'. + if d.Method.Name <> "Invoke" then failwithf "expected closure Method.Name 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> compileExeAndRun + |> shouldSucceed + + // IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded + // delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure + // 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. + [] + let ``IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ +module IlMethodDelegate + +open System + +[] +let main _ = + let d = Func(fun a b -> Math.Max(a, b)) + if d.Invoke(3, 7) <> 7 then failwith "il: wrong result" + if d.Method.Name <> "Max" then failwithf "il: expected direct 'Max' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + + // A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct + // delegate would evaluate it once at construction. When the receiver has an effect (here a counter- + // bumping call) that difference is observable, so the closure must be kept even under optimization. + [] + let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = + FSharp """ +module ReceiverEffectDelegate + +open System + +let mutable calls = 0 + +type Box(tag: int) = + member _.Read (_: int) : int = tag + +let getBox () = + calls <- calls + 1 + Box(calls) + +[] +let main _ = + // The receiver 'getBox()' has an effect, so it must run on each invocation, not once at construction. + let d = Func(fun a -> (getBox()).Read a) + let r1 = d.Invoke 0 + let r2 = d.Invoke 0 + if calls <> 2 then failwithf "receiver should be re-evaluated per invoke; calls=%d" calls + if r1 = r2 then failwithf "expected distinct boxes per invoke but got %d and %d" r1 r2 + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + + // Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the + // receiver and Method.Name the real method. + [] + let ``Instance IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ +module IlInstanceMethodDelegate + +open System +open System.Text + +[] +let main _ = + let sb = StringBuilder() + // StringBuilder.Append(string) is an instance method on a reference type. + let d = Func(fun s -> sb.Append(s)) + d.Invoke "hello" |> ignore + if sb.ToString() <> "hello" then failwith "il-instance: wrong result" + if d.Method.Name <> "Append" then failwithf "il-instance: expected direct 'Append' but got '%s'" d.Method.Name + if not (obj.ReferenceEquals(d.Target, sb)) then failwith "il-instance: Target is not the receiver" + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed From 894f6f0e9f5e3bfdbfb50bfd9ef9ad88f4963840 Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 23:59:32 +0200 Subject: [PATCH 3/8] Release notes, custom delegate tests --- .../.FSharp.Compiler.Service/11.0.100.md | 1 + docs/release-notes/.Language/preview.md | 4 +- .../DirectDelegates/DelegateCustomType.fs | 40 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 351 +++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 417 ++++++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 285 ++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 417 ++++++++++++++++++ .../DirectDelegates/DirectDelegates.fs | 47 ++ 8 files changed, 1561 insertions(+), 1 deletion(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 54f5a122d6d..190d8ee8cc7 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -108,6 +108,7 @@ ### Improved * Nullness warning FS3261 on dotted method or property access (e.g. `x.Member`) now underlines the receiver expression and includes the member name and (when known) the binding name in the message. ([Issue #19658](https://github.com/dotnet/fsharp/issues/19658), [PR #19814](https://github.com/dotnet/fsharp/pull/19814)) +* Direct delegate construction ([PR ##19993](https://github.com/dotnet/fsharp/pull/19993)) ### Changed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 90c1aa2faa6..1775f5ba65e 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -6,4 +6,6 @@ ### Fixed -### Changed \ No newline at end of file +### Changed + +* Direct delegate construction ([PR ##19993](https://github.com/dotnet/fsharp/pull/19993)) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs new file mode 100644 index 00000000000..0ff380ea4cb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -0,0 +1,40 @@ +module DelegateCustomType + +open System + +// Custom, F#-declared delegate types exercise construction with delegates defined in the *compiled* assembly +// (local scope, unlike imported BCL Func/Action) and with Invoke signatures the Func/Action tests do not +// cover: a multi-argument (tupled) signature, a generic delegate, and a byref parameter. (F# forbids curried +// delegate signatures — FS0950 — so every F# delegate has a single tupled Invoke parameter group.) Targets +// are [] so the optimized path genuinely emits the direct form rather than inlining the +// target away (no inline-race). + +type DTupled = delegate of int * int -> int +type DGen<'T> = delegate of 'T -> 'T +type DByref = delegate of byref -> unit + +[] +let acc (x: int) (y: int) : int = x + y + +[] +let ident (x: 'T) : 'T = x + +type C() = + [] + member _.M (x: int) (y: int) : int = x * y + +// Tupled-signature custom delegate: Invoke(int, int). +let tupledNonEta () = DTupled(acc) +let tupledEta () = DTupled(fun a b -> acc a b) + +// Instance member through a custom delegate: the receiver becomes the delegate's Target. +let instanceNonEta (c: C) = DTupled(c.M) +let instanceEta (c: C) = DTupled(fun a b -> c.M a b) + +// Generic custom delegate instantiated at int: Invoke(int):int over the generic target. +let genNonEta () = DGen(ident) +let genEta () = DGen(fun x -> ident x) + +// byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding +// call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. +let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..2dc27dab7c4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,351 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..f5f71c0f124 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,417 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 delegateArg0) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..e893cc9de1b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,285 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..f5f71c0f124 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,417 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + 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 sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .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 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 delegateArg0) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 8ab3fa33684..93351130abb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -21,6 +21,7 @@ module DirectDelegates = compilation |> coreOptions |> compile + |> shouldSucceed |> verifyILBaseline // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the @@ -45,6 +46,7 @@ module DirectDelegates = |> withLangVersionPreview |> withPreviewBaseline |> compile + |> shouldSucceed |> verifyILBaseline [] @@ -151,6 +153,14 @@ module DirectDelegates = let ``DelegateILMethod_fs preview`` compilation = compilation |> getCompilation |> verifyPreviewCompilation + [] + let ``DelegateCustomType_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateCustomType_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + [] let ``Direct delegates target the real method and dispatch correctly (preview)`` () = FSharp """ @@ -301,3 +311,40 @@ let main _ = |> withOptions [ "--optimize+" ] |> compileExeAndRun |> shouldSucceed + + // Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. + // Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an + // instance target (Target = receiver) through a user-defined delegate. + [] + let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = + FSharp """ +module CustomDelegateExecution + +open System + +type DTupled = delegate of int * int -> int + +[] +let acc (x: int) (y: int) : int = x + y + +type C() = + [] + member _.M (x: int) (y: int) : int = x * y + +[] +let main _ = + let ds = DTupled(acc) + if ds.Invoke(2, 3) <> 5 then failwith "static: wrong result" + if ds.Method.Name <> "acc" then failwithf "static: expected 'acc' but got '%s'" ds.Method.Name + if not (isNull ds.Target) then failwith "static: Target should be null" + + let c = C() + let di = DTupled(c.M) + if di.Invoke(4, 5) <> 20 then failwith "instance: wrong result" + if di.Method.Name <> "M" then failwithf "instance: expected 'M' but got '%s'" di.Method.Name + if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed From 427050787c88e7104eb7cefd25b8fbe0521b6d3b Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 25 Jun 2026 18:58:27 +0200 Subject: [PATCH 4/8] verifyPEFileWithSystemDlls, remove realsig keying, RFC <-> baseline test case numbering --- src/Compiler/CodeGen/IlxGen.fs | 32 +- .../DirectDelegates/DelegateCustomType.fs | 7 + ...eCustomType.fs.OptimizeOff.Preview.il.bsl} | 22 +- ... DelegateCustomType.fs.OptimizeOff.il.bsl} | 40 +- ...teCustomType.fs.OptimizeOn.Preview.il.bsl} | 4 +- ...> DelegateCustomType.fs.OptimizeOn.il.bsl} | 40 +- .../DelegateExtensionMethod.fs | 1 + ...nsionMethod.fs.OptimizeOff.Preview.il.bsl} | 10 +- ...gateExtensionMethod.fs.OptimizeOff.il.bsl} | 10 +- ...ensionMethod.fs.OptimizeOn.Preview.il.bsl} | 10 +- ...egateExtensionMethod.fs.OptimizeOn.il.bsl} | 10 +- .../DelegateGenericInstanceMethod.fs | 8 +- ...tanceMethod.fs.OptimizeOff.Preview.il.bsl} | 30 +- ...nericInstanceMethod.fs.OptimizeOff.il.bsl} | 30 +- ...stanceMethod.fs.OptimizeOn.Preview.il.bsl} | 18 +- ...enericInstanceMethod.fs.OptimizeOn.il.bsl} | 18 +- .../DelegateGenericStaticMethod.fs | 12 +- ...taticMethod.fs.OptimizeOff.Preview.il.bsl} | 22 +- ...GenericStaticMethod.fs.OptimizeOff.il.bsl} | 28 +- ...StaticMethod.fs.OptimizeOn.Preview.il.bsl} | 28 +- ...eGenericStaticMethod.fs.OptimizeOn.il.bsl} | 22 +- .../DirectDelegates/DelegateILMethod.fs | 4 +- ...ateILMethod.fs.OptimizeOff.Preview.il.bsl} | 6 +- ...=> DelegateILMethod.fs.OptimizeOff.il.bsl} | 0 ...gateILMethod.fs.OptimizeOn.Preview.il.bsl} | 0 ... => DelegateILMethod.fs.OptimizeOn.il.bsl} | 0 .../DirectDelegates/DelegateInstanceMethod.fs | 16 +- ...tanceMethod.fs.OptimizeOff.Preview.il.bsl} | 38 +- ...egateInstanceMethod.fs.OptimizeOff.il.bsl} | 52 +- ...stanceMethod.fs.OptimizeOn.Preview.il.bsl} | 30 +- ...legateInstanceMethod.fs.OptimizeOn.il.bsl} | 34 +- .../DirectDelegates/DelegateKnownFunction.fs | 17 +- ...ownFunction.fs.OptimizeOff.Preview.il.bsl} | 30 +- ...legateKnownFunction.fs.OptimizeOff.il.bsl} | 28 +- ...nownFunction.fs.OptimizeOn.Preview.il.bsl} | 36 +- ...elegateKnownFunction.fs.OptimizeOn.il.bsl} | 28 +- .../DirectDelegates/DelegateNegativeCases.fs | 17 +- ...gativeCases.fs.OptimizeOff.Preview.il.bsl} | 74 ++- ...legateNegativeCases.fs.OptimizeOff.il.bsl} | 68 +++ ...egativeCases.fs.OptimizeOn.Preview.il.bsl} | 74 ++- ...elegateNegativeCases.fs.OptimizeOn.il.bsl} | 68 +++ .../DirectDelegates/DelegateNonInlinable.fs | 30 +- ...onInlinable.fs.OptimizeOff.Preview.il.bsl} | 36 +- ...elegateNonInlinable.fs.OptimizeOff.il.bsl} | 90 +-- ...NonInlinable.fs.OptimizeOn.Preview.il.bsl} | 34 +- ...DelegateNonInlinable.fs.OptimizeOn.il.bsl} | 90 +-- .../DelegatePartialApplication.fs | 11 +- ...Application.fs.OptimizeOff.Preview.il.bsl} | 34 +- ...ePartialApplication.fs.OptimizeOff.il.bsl} | 40 +- ...lApplication.fs.OptimizeOn.Preview.il.bsl} | 12 +- ...tePartialApplication.fs.OptimizeOn.il.bsl} | 18 +- .../DirectDelegates/DelegateStaticMethod.fs | 18 +- ...taticMethod.fs.OptimizeOff.Preview.il.bsl} | 22 +- ...elegateStaticMethod.fs.OptimizeOff.il.bsl} | 28 +- ...StaticMethod.fs.OptimizeOn.Preview.il.bsl} | 28 +- ...DelegateStaticMethod.fs.OptimizeOn.il.bsl} | 28 +- .../DirectDelegates/DelegateStructTarget.fs | 2 + ...tructTarget.fs.OptimizeOff.Preview.il.bsl} | 20 +- ...elegateStructTarget.fs.OptimizeOff.il.bsl} | 24 +- ...StructTarget.fs.OptimizeOn.Preview.il.bsl} | 20 +- ...DelegateStructTarget.fs.OptimizeOn.il.bsl} | 24 +- .../DirectDelegates/DelegateUnitArg.fs | 4 +- ...gateUnitArg.fs.OptimizeOff.Preview.il.bsl} | 0 ... => DelegateUnitArg.fs.OptimizeOff.il.bsl} | 0 ...egateUnitArg.fs.OptimizeOn.Preview.il.bsl} | 0 ...l => DelegateUnitArg.fs.OptimizeOn.il.bsl} | 0 .../DirectDelegates/DelegateUnitReturn.fs | 4 + ...eUnitReturn.fs.OptimizeOff.Preview.il.bsl} | 16 +- ... DelegateUnitReturn.fs.OptimizeOff.il.bsl} | 18 +- ...teUnitReturn.fs.OptimizeOn.Preview.il.bsl} | 8 +- ...> DelegateUnitReturn.fs.OptimizeOn.il.bsl} | 18 +- .../DirectDelegates/DirectDelegates.fs | 571 +++++++++++------- 72 files changed, 1356 insertions(+), 914 deletions(-) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateCustomType.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateCustomType.fs.OptimizeOff.il.bsl} (94%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateCustomType.fs.OptimizeOn.Preview.il.bsl} (98%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateCustomType.fs.OptimizeOn.il.bsl} (94%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateExtensionMethod.fs.OptimizeOff.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateExtensionMethod.fs.OptimizeOn.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl} (88%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateILMethod.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateILMethod.fs.OptimizeOff.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateILMethod.fs.OptimizeOn.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateILMethod.fs.OptimizeOn.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl} (86%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateInstanceMethod.fs.OptimizeOff.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl} (88%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateInstanceMethod.fs.OptimizeOn.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateKnownFunction.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateKnownFunction.fs.OptimizeOn.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl} (78%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateNegativeCases.fs.OptimizeOff.il.bsl} (79%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl} (76%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateNegativeCases.fs.OptimizeOn.il.bsl} (77%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateNonInlinable.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateNonInlinable.fs.OptimizeOn.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegatePartialApplication.fs.OptimizeOff.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegatePartialApplication.fs.OptimizeOn.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateStaticMethod.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateStaticMethod.fs.OptimizeOn.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl} (97%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateStructTarget.fs.OptimizeOff.il.bsl} (96%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl} (97%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateStructTarget.fs.OptimizeOn.il.bsl} (96%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateUnitArg.fs.OptimizeOff.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateUnitArg.fs.OptimizeOn.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateUnitReturn.fs.OptimizeOff.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateUnitReturn.fs.OptimizeOn.il.bsl} (93%) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index d95fe298b92..ff83e60226c 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7514,19 +7514,27 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // The type checker has already verified that the delegate is built from a compatible function // shape, and the structural match above forwards the Invoke parameters verbatim, so the - // target's signature is compatible with the delegate's Invoke by construction. We just confirm - // the compiled shape lines up: - // - for a non-generic target, identical parameter and return types (cheap and exact); - // - for a generic target, matching parameter count (the formal signature is written in terms - // of type variables, so an exact type comparison here is not meaningful; arity rejects - // unit-elision / param-array / tupled-arity mismatches). - // For an instance method the receiver is implicit and does not appear in FormalArgTypes. + // target's signature is compatible with the delegate's Invoke by construction. We confirm: + // - parameter *count* matches (already guaranteed by the verbatim forwarding, so essentially + // a sanity check). We deliberately do not compare parameter IL *types*: a value-type + // parameter is exact by construction (a widening/boxing argument would not be a verbatim + // Val and so would not have matched), and for reference-type parameters the CLR's delegate + // relaxation permits contravariance, so an exact comparison would only produce false + // negatives (a CLR-legal binding bailing to a closure). + // - for a non-generic target, the return type matches exactly. This is the one IL mismatch + // the recognizer cannot see and the CLR will not relax: notably an F# 'unit' return + // compiled to 'void' versus a delegate whose Invoke returns 'Unit'. For a generic target + // the return is written in terms of type variables, so no exact comparison is meaningful. let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = - if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then - typesOfILParams ilDelegeeParams = targetMspec.FormalArgTypes - && ilDelegeeRet.Type = targetMspec.FormalReturnType - else - targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + + let returnMatches = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + ilDelegeeRet.Type = targetMspec.FormalReturnType + else + true + + arityMatches && returnMatches let receiverInfo virtualCall = match leadingArgs with diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index 0ff380ea4cb..02f6b3101ad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -24,17 +24,24 @@ type C() = member _.M (x: int) (y: int) : int = x * y // Tupled-signature custom delegate: Invoke(int, int). +// 30. non-eta module function, custom delegate let tupledNonEta () = DTupled(acc) +// 15. eta module function, custom delegate let tupledEta () = DTupled(fun a b -> acc a b) // Instance member through a custom delegate: the receiver becomes the delegate's Target. +// 31. non-eta instance member, custom delegate let instanceNonEta (c: C) = DTupled(c.M) +// 16. eta instance member, custom delegate let instanceEta (c: C) = DTupled(fun a b -> c.M a b) // Generic custom delegate instantiated at int: Invoke(int):int over the generic target. +// 32. non-eta generic method, generic custom delegate let genNonEta () = DGen(ident) +// 17. eta generic method, generic custom delegate let genEta () = DGen(fun x -> ident x) // byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding // call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. +// 53. byref-parameter delegate (mutating body) let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl index 2dc27dab7c4..ebf7fcb3ce1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -181,7 +181,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -191,7 +191,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -206,7 +206,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -264,7 +264,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -288,8 +288,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -312,7 +312,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -323,7 +323,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl similarity index 94% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl index f5f71c0f124..0441b15c935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -177,7 +177,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -209,7 +209,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -220,7 +220,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -241,7 +241,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -256,7 +256,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -271,7 +271,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -317,7 +317,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +329,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -341,8 +341,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -354,8 +354,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -367,7 +367,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +378,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +389,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl similarity index 98% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl index e893cc9de1b..2b9e0be2d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -257,7 +257,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl similarity index 94% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl index f5f71c0f124..0441b15c935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -177,7 +177,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -209,7 +209,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -220,7 +220,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -241,7 +241,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -256,7 +256,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -271,7 +271,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -317,7 +317,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +329,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -341,8 +341,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -354,8 +354,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -367,7 +367,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +378,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +389,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index 7eba16766c9..e1118463d0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -15,4 +15,5 @@ type HolderExtensions = // An extension member compiles to a static method whose first parameter is the receiver, so using it as a // delegate target binds that receiver as a leading argument - a partial application, which has no closed // direct-delegate form. A closure must remain regardless of langversion. +// 52. extension member (receiver is a leading static arg) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl index 7347dab3c0d..66377f64db4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl index 0b7acdc3542..bdc4971648a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl index 7347dab3c0d..66377f64db4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl index 0b7acdc3542..bdc4971648a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs index 6f3e738f6fa..76adc561105 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -6,8 +6,8 @@ type C() = member _.IMc<'T> (x: 'T) (y: 'T) : unit = () member _.IMt<'T> (x: 'T, y: 'T) : unit = () -// 13. eta-expanded, generic instance method, curried application -let case13_etaCurried (o: C) = Action(fun a b -> o.IMc a b) +// 5. eta generic instance method (curried application) +let case5_etaCurried (o: C) = Action(fun a b -> o.IMc a b) -// 14. eta-expanded, generic instance method, tupled application -let case14_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) +// 37. eta generic instance method, tupled application +let case37_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl index b9299772df1..154f0d0415a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -65,7 +65,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -76,7 +76,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0002: stfld class assembly/C assembly/case5_etaCurried@10::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -87,7 +87,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0001: ldfld class assembly/C assembly/case5_etaCurried@10::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMc(!!0, @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -131,29 +131,29 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case5_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl index b9299772df1..154f0d0415a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl @@ -65,7 +65,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -76,7 +76,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0002: stfld class assembly/C assembly/case5_etaCurried@10::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -87,7 +87,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0001: ldfld class assembly/C assembly/case5_etaCurried@10::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMc(!!0, @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -131,29 +131,29 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case5_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 6836a936968..9e16587d173 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -65,7 +65,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -93,27 +93,27 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl index 6836a936968..9e16587d173 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl @@ -65,7 +65,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -93,27 +93,27 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs index b48e9130735..f35b3caf46d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -6,11 +6,11 @@ type G<'U> = static member SMc<'T> (x: 'T) (y: 'T) : unit = () static member SMt<'T> (x: 'T, y: 'T) : unit = () -// 7. non-eta-expanded generic static method (generic type + generic method) -let case7_nonEta () = Action(G.SMc) +// 20. non-eta generic static method (generic type + generic method) +let case20_nonEta () = Action(G.SMc) -// 8. eta-expanded, curried application -let case8_etaCurried () = Action(fun a b -> G.SMc a b) +// 3. eta generic static method (curried application) +let case3_etaCurried () = Action(fun a b -> G.SMc a b) -// 9. eta-expanded, tupled application -let case9_etaTupled () = Action(fun a b -> G.SMt(a, b)) +// 35. eta generic static method, tupled application +let case35_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl index bc63a786879..0f0dd9201ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 @@ -102,31 +102,31 @@ IL_0001: ldftn void class assembly/G`1::SMc(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl similarity index 88% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl index 91c5b9cd522..f22ac83b012 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -113,39 +113,39 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl index e6bb3aa83fc..d29d01ad424 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +70,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,39 +98,39 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl index e6bb3aa83fc..6d706bf6afb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +70,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,37 +98,37 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs index db933f2f73e..04304ab05d0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -8,9 +8,9 @@ open System.Text // unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable // for the F#-value equivalent. -// Static IL method (System.Math.Max), eta-expanded. +// 13. eta IL/BCL static method (System.Math.Max). let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) -// Instance IL method (StringBuilder.Append(string)) on a reference type, eta-expanded. The receiver is a +// 14. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a // parameter, evaluated at the construction site and carried as the delegate's Target. let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl index 718255efb91..12ffd3cce34 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl @@ -45,7 +45,7 @@ IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: call int32 [runtime]System.Math::Max(int32, - int32) + int32) IL_0007: ret } @@ -89,7 +89,7 @@ IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -101,7 +101,7 @@ IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs index 1701b1c35e6..c76c310d5e9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -8,14 +8,14 @@ type C(k: int) = abstract V : int -> int -> unit default _.V (x: int) (y: int) : unit = ignore k -// 10. non-eta-expanded instance method target -let case10_nonEta (o: C) = Action(o.AddC) +// 21. non-eta instance method +let case21_nonEta (o: C) = Action(o.AddC) -// 11. eta-expanded, curried application -let case11_etaCurried (o: C) = Action(fun a b -> o.AddC a b) +// 4. eta instance method (curried application) +let case4_etaCurried (o: C) = Action(fun a b -> o.AddC a b) -// 12. eta-expanded, tupled application -let case12_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) +// 36. eta instance method, tupled application +let case36_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) -// virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch -let caseVirtual (o: C) = Action(o.V) +// 22. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let case22_virtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl similarity index 86% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl index 4e57d30669e..f01abe41e4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0002: stfld class assembly/C assembly/case4_etaCurried@15::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0001: ldfld class assembly/C assembly/case4_etaCurried@15::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -155,7 +155,7 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 @@ -163,37 +163,37 @@ IL_0001: ldftn instance void assembly/C::AddC(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case4_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 @@ -202,7 +202,7 @@ IL_0002: ldvirtftn instance void assembly/C::V(int32, int32) IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000d: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl index b908fa4c200..c5e6b7997f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0002: stfld class assembly/C assembly/case21_nonEta@12::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0001: ldfld class assembly/C assembly/case21_nonEta@12::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0002: stfld class assembly/C assembly/case4_etaCurried@15::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0001: ldfld class assembly/C assembly/case4_etaCurried@15::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -177,7 +177,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0002: stfld class assembly/C assembly/case22_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,53 +221,53 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: newobj instance void assembly/case21_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_nonEta@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case4_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl similarity index 88% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 0297f76438f..84816e669f0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -91,7 +91,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,43 +119,43 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 @@ -164,7 +164,7 @@ IL_0002: ldvirtftn instance void assembly/C::V(int32, int32) IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000d: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl index 44b0b4cbbd5..71fd756ac65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -91,7 +91,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,7 +119,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -130,7 +130,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0002: stfld class assembly/C assembly/case22_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -152,50 +152,50 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs index e89b00afc72..50debc1ffcb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -7,15 +7,14 @@ let handlerCurried (x: int) (y: int) : unit = () let handlerTupled (x: int, y: int) : unit = () let handler3 (x: int) (y: int) (z: int) : unit = () -// 1. non-eta-expanded known target -let case1_nonEta () = Action(handlerCurried) +// 18. non-eta module function +let case18_nonEta () = Action(handlerCurried) -// 2. eta-expanded known target (curried application) -let case2_etaCurried () = Action(fun a b -> handlerCurried a b) +// 1. eta module function (curried application) +let case1_etaCurried () = Action(fun a b -> handlerCurried a b) -// 3. eta-expanded known target, tupled application, same compiled representation -let case3_etaTupled () = Action(fun a b -> handlerTupled (a, b)) +// 33. eta module function, tupled application (same compiled representation) +let case33_etaTupled () = Action(fun a b -> handlerTupled (a, b)) -// 15. non-eta-expanded known target via partial application -// (currently a closure with "delegateArg0"-style names; proposal: use elided arg names y, z) -let case15_partial () = Action(handler3 1) +// 39. partial application of module function (constant arg) +let case39_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl index 977948fe928..e34b7189e73 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -120,7 +120,7 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 @@ -128,43 +128,43 @@ IL_0001: ldftn void assembly::handlerCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl index 9c87cb38678..b1169b274d3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -90,7 +90,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -139,48 +139,48 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index 548f0ecb854..43d1a477c17 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -47,7 +47,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,51 +117,51 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl index 548f0ecb854..6d997901f37 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -47,7 +47,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,48 +117,48 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index 8f177b36053..a18125b447b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -2,13 +2,24 @@ module DelegateNegativeCases open System -// first-class function value: there is no target method to point at, so a closure must remain +// 44. first-class function value: there is no target method to point at, so a closure must remain let firstClass (handler: int -> int -> unit) = Action(handler) -// lambda body is not a single direct forwarding call to a known target (the argument is computed, +// 45. lambda body is not a single direct forwarding call to a known target (the argument is computed, // not the delegate parameters forwarded as-is): a closure must remain let private sink (x: int) : unit = () let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) -// arguments reordered: not a transparent forwarding, so a closure must remain +// 46. arguments reordered: not a transparent forwarding, so a closure must remain let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) + +type Holder() = + [] + member _.TakesObj (x: obj) : int = 1 + +// 47. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. +// The CLR would accept this binding directly (a delegate may bind a method whose parameter is a supertype), +// but it stays a closure: F# elaborates the 'string -> obj' argument upcast as a coercion, so the forwarded +// argument is no longer a verbatim Invoke parameter and the direct-delegate recognizer does not match. (The +// signature check is not involved - it never even runs here.) +let contra (h: Holder) = System.Func(fun s -> h.TakesObj s) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl similarity index 78% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index 32cd386fabb..ca393fa812c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -33,6 +33,32 @@ 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -135,6 +161,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -144,7 +200,7 @@ IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -164,7 +220,7 @@ IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -177,7 +233,19 @@ IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl similarity index 79% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl index 32cd386fabb..8498432adc8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl @@ -33,6 +33,32 @@ 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -135,6 +161,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -181,6 +237,18 @@ IL_0011: ret } + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl similarity index 76% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index 39878c4a64b..00a429b94a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -33,6 +33,32 @@ 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -115,6 +141,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -124,7 +180,7 @@ IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -143,7 +199,7 @@ IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -156,7 +212,19 @@ IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl similarity index 77% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl index 39878c4a64b..25621c1ba07 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl @@ -33,6 +33,32 @@ 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 Holder + extends [runtime]System.Object + { + .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 ) + .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 public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -115,6 +141,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -160,6 +216,18 @@ IL_0011: ret } + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index 1cf2e00e70f..d1457922935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -2,37 +2,29 @@ module DelegateNonInlinable open System -// Section D, bullet 1: the optimizer inlines small function bodies before IlxGen runs. If a delegate -// target is inlined away in release/Optimize+ builds, the forwarding call no longer survives and the -// direct-delegate recognizer has nothing to fire on. To prove the release path is actually exercised we -// need targets the optimizer will NOT inline. [] forces ValInline.Never, so the -// forwarding call is guaranteed to reach IlxGen regardless of how small the body is (see -// ComputeInlineFlag in CheckExpressions.fs). Bodies are arithmetic only (TFM-stable, no BCL calls) and -// Func<_,_,_> is used so the result is observable. - [] let accCurried (x: int) (y: int) : int = x + y [] let accTupled (x: int, y: int) : int = x + y -// non-inlinable known target, non-eta-expanded +// 23. non-eta module function, non-inlinable let niNonEta () = Func(accCurried) -// non-inlinable known target, eta-expanded, curried application +// 6. eta module function, non-inlinable (curried application) let niEtaCurried () = Func(fun a b -> accCurried a b) -// non-inlinable known target, eta-expanded, tupled application +// 38. eta module function, non-inlinable, tupled application let niEtaTupled () = Func(fun a b -> accTupled (a, b)) type S = [] static member AccS (x: int) (y: int) : int = x + y -// non-inlinable static target, non-eta-expanded +// 24. non-eta static method, non-inlinable let niStaticNonEta () = Func(S.AccS) -// non-inlinable static target, eta-expanded +// 7. eta static method, non-inlinable let niStaticEta () = Func(fun a b -> S.AccS a b) type C(k: int) = @@ -42,24 +34,26 @@ type C(k: int) = [] member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x -// non-inlinable instance target, non-eta-expanded +// 25. non-eta instance method, non-inlinable let niInstanceNonEta (o: C) = Func(o.AccC) -// non-inlinable instance target, eta-expanded +// 8. eta instance method, non-inlinable let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) -// non-inlinable generic instance target, non-eta-expanded +// 26. non-eta generic instance method, non-inlinable let niGenericInstanceNonEta (o: C) = Func(o.GPick) -// non-inlinable generic instance target, eta-expanded +// 9. eta generic instance method, non-inlinable let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) -// Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and +// A trivial, inlinable target kept on purpose to document and // guard the inline-vs-direct interaction. In release the optimizer may inline the body before the // recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) // for this to still become a direct delegate. let trivial (x: int) (y: int) : int = x + y +// 27. non-eta inlinable trivial target (inline-race contrast) let niTrivialNonEta () = Func(trivial) +// 10. eta inlinable trivial target (inline-race) let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl index b31ec227850..b359893da86 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -163,7 +163,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -174,7 +174,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -185,7 +185,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -196,7 +196,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -207,7 +207,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -217,7 +217,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -277,7 +277,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -289,7 +289,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -313,7 +313,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -337,8 +337,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -362,8 +362,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -399,7 +399,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl index 075811968d9..123299f5ca8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,7 +221,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -232,7 +232,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -243,7 +243,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -254,7 +254,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -265,7 +265,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -276,7 +276,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -286,7 +286,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -297,7 +297,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -308,7 +308,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -318,7 +318,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -336,7 +336,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -384,10 +384,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -396,10 +396,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -408,10 +408,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -420,10 +420,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -432,10 +432,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -444,11 +444,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -457,11 +457,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -470,11 +470,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -483,11 +483,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -508,10 +508,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -520,10 +520,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl index 769f5764703..4f7a18609ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ IL_0001: ldftn int32 assembly::accCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -195,7 +195,7 @@ IL_0001: ldftn int32 assembly::accCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -204,10 +204,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -219,7 +219,7 @@ IL_0001: ldftn int32 assembly/S::AccS(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -231,7 +231,7 @@ IL_0001: ldftn int32 assembly/S::AccS(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -243,7 +243,7 @@ IL_0001: ldftn instance int32 assembly/C::AccC(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -255,7 +255,7 @@ IL_0001: ldftn instance int32 assembly/C::AccC(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -267,7 +267,7 @@ IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -279,7 +279,7 @@ IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -300,10 +300,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -312,10 +312,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl index a10586e3a2e..8a4ce549f4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -220,7 +220,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -242,7 +242,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -252,7 +252,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -263,7 +263,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -274,7 +274,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -284,7 +284,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -295,7 +295,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -306,7 +306,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -316,7 +316,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -333,7 +333,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -380,10 +380,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -392,10 +392,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -404,10 +404,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -416,10 +416,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -428,10 +428,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -440,11 +440,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -453,11 +453,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -466,11 +466,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -479,11 +479,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -504,10 +504,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -516,10 +516,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs index 8b12ee25545..05dce73a5ee 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -2,12 +2,11 @@ module DelegatePartialApplication open System -// Section D, bullet 2: cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// Cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a // constant first argument, so their closure can stay static (the constant is re-materialised in Invoke // with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance // field, which exercises a distinct emit path. None of these can ever become a direct delegate (the -// target has more parameters than the delegate's Invoke), so a closure must remain regardless of -// langversion; the only proposed change here is friendlier elided argument names. +// target has more parameters than the delegate's Invoke), so a closure must remain. let handler3 (x: int) (y: int) (z: int) : unit = () @@ -17,11 +16,11 @@ type C = type I(k: int) = member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k -// variable-capture partial application of a known function (instance-field capture of n) +// 41. partial application of module function (captured var: instance-field capture of n) let papKnownVar (n: int) = Action(handler3 n) -// variable-capture partial application of a static method +// 42. partial application of static method (captured var) let papStaticVar (n: int) = Action(C.Add3 n) -// variable-capture partial application of an instance method (captures both the receiver and n) +// 43. partial application of instance method (captures both the receiver and n) let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl index 1b719dd6d94..c4365038d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0002: stfld int32 assembly/papKnownVar@20::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0001: ldfld int32 assembly/papKnownVar@20::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0002: stfld int32 assembly/papStaticVar@23::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0001: ldfld int32 assembly/papStaticVar@23::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_0009: stfld int32 assembly/papInstanceVar@26::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_0007: ldfld int32 assembly/papInstanceVar@26::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,8 +211,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -224,8 +224,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -239,9 +239,9 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl index fc1e7bc6303..c4365038d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0002: stfld int32 assembly/papKnownVar@20::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0001: ldfld int32 assembly/papKnownVar@20::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0002: stfld int32 assembly/papStaticVar@23::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0001: ldfld int32 assembly/papStaticVar@23::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_0009: stfld int32 assembly/papInstanceVar@26::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_0007: ldfld int32 assembly/papInstanceVar@26::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,11 +211,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -224,11 +224,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -239,12 +239,12 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0012: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl index f9efcbd168b..61c73994f65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -153,7 +153,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl index afb6d8c3f64..61c73994f65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,10 +141,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -153,10 +153,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -166,10 +166,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs index 5f3ec7b724e..c77a2fc19dc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -7,15 +7,15 @@ type C = static member AddT (x: int, y: int) : unit = () static member Add3 (x: int) (y: int) (z: int) : unit = () -// 4. non-eta-expanded static method target -// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) -let case4_nonEta () = Action(C.AddC) +// 19. non-eta static method +// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) +let case19_nonEta () = Action(C.AddC) -// 5. eta-expanded, curried application -let case5_etaCurried () = Action(fun a b -> C.AddC a b) +// 2. eta static method (curried application) +let case2_etaCurried () = Action(fun a b -> C.AddC a b) -// 6. eta-expanded, tupled application -let case6_etaTupled () = Action(fun a b -> C.AddT(a, b)) +// 34. eta static method, tupled application +let case34_etaTupled () = Action(fun a b -> C.AddT(a, b)) -// 16. non-eta-expanded static method via partial application -let case16_partial () = Action(C.Add3 1) +// 40. partial application of static method (constant arg) +let case40_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl index d9c7305029d..d7b33e7d72b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -126,7 +126,7 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 @@ -138,36 +138,36 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl index 15590de3edc..f1d3a8474e1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -124,7 +124,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -145,48 +145,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index eadfc7c3f13..f2dd2579e43 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -81,7 +81,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,48 +123,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl index eadfc7c3f13..f2dd2579e43 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -81,7 +81,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,48 +123,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index b7f55d44097..84785eda906 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -10,6 +10,8 @@ type S = // The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate // would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod // for the reference-type case, which is emitted directly.) +// 50. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) +// 51. eta struct (value-type) receiver let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl similarity index 97% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl index 3c01648fc8d..291dc96be7c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl @@ -199,7 +199,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +222,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -234,7 +234,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -245,7 +245,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -257,7 +257,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -274,8 +274,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -287,8 +287,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl similarity index 96% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl index 8055c451a93..291dc96be7c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl @@ -199,7 +199,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +222,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -234,7 +234,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -245,7 +245,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -257,7 +257,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -274,11 +274,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -287,11 +287,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl similarity index 97% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl index ae22fd38d8a..f83c608dc89 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl @@ -172,7 +172,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -194,7 +194,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -204,7 +204,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -215,7 +215,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -226,7 +226,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -241,8 +241,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -254,8 +254,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl similarity index 96% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl index 1cbf8a76d65..f83c608dc89 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl @@ -172,7 +172,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -194,7 +194,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -204,7 +204,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -215,7 +215,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -226,7 +226,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -241,11 +241,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -254,11 +254,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index 7b27fb8611b..a72fe20cf80 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -4,8 +4,8 @@ open System let handler () : unit = () -// unit-argument delegate, non-eta-expanded known target +// 48. non-eta unit-argument delegate let caseUnitNonEta () = Action(handler) -// unit-argument delegate, eta-expanded +// 49. eta unit-argument delegate let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs index 7e2b1c5e31a..10e8032a87c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -6,8 +6,10 @@ open System [] let returnsUnit (x: int) (y: int) : unit = () +// 28. non-eta unit-returning member (compiled to void) let voidNonEta () = Action(returnsUnit) +// 11. eta unit-returning member let voidEta () = Action(fun a b -> returnsUnit a b) type C = @@ -18,6 +20,8 @@ type C = static member Echo<'T>(x: 'T) : 'T = x // Generic return type variable instantiated to unit; the delegate likewise returns unit. +// 29. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) let unitGenericReturnNonEta () = Func(C.Echo) +// 12. eta generic unit-returning method let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl index 1ac412d919c..97b1e27f918 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -109,10 +109,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -123,7 +123,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -132,9 +132,9 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl index 2169ff70e6f..72f76894471 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -101,7 +101,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -131,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +155,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl index 02e82fd6e93..2f7c62741e0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl @@ -66,7 +66,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -78,7 +78,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -89,7 +89,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -100,7 +100,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl index 2169ff70e6f..72f76894471 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -101,7 +101,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -131,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +155,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 93351130abb..f14d00e5586 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -1,169 +1,165 @@ -namespace EmittedIL.RealInternalSignature +module EmittedIL.RealInternalSignature.DirectDelegates open System.IO open Xunit open FSharp.Test open FSharp.Test.Compiler -module DirectDelegates = - - let private coreOptions compilation = - compilation - |> withOptions [ "--test:EmitFeeFeeAs100001" ] - |> asExe - |> withEmbeddedPdb - |> withEmbedAllSource - |> ignoreWarnings - - // Default langversion: direct delegates must NOT be emitted (a closure is still generated). - // Baselines: ..il.bsl -- these should remain unchanged when the feature lands. - let verifyCompilation compilation = - compilation - |> coreOptions - |> compile - |> shouldSucceed - |> verifyILBaseline - - // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the - // very same input .fs file (no input duplication / drift) without clobbering the default baseline. - let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = - match cUnit with - | FS src -> - let baseline = - src.Baseline - |> Option.map (fun bsl -> - let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") - let content = if File.Exists path then Some(File.ReadAllText path) else None - { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) - FS { src with Baseline = baseline } - | other -> other - - // Preview langversion: direct delegates ARE emitted once the feature lands. - // Baselines: ..Preview.il.bsl -- these are the ones that will change. - let verifyPreviewCompilation compilation = - compilation - |> coreOptions - |> withLangVersionPreview - |> withPreviewBaseline - |> compile - |> shouldSucceed - |> verifyILBaseline - - [] - let ``DelegateKnownFunction_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateKnownFunction_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateStaticMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateStaticMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateGenericStaticMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateGenericStaticMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateInstanceMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateInstanceMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateGenericInstanceMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateGenericInstanceMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateUnitArg_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateUnitArg_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateNegativeCases_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateNegativeCases_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateNonInlinable_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateNonInlinable_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegatePartialApplication_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegatePartialApplication_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateUnitReturn_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateUnitReturn_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateStructTarget_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateStructTarget_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateExtensionMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateExtensionMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateILMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation +let private coreOptions compilation = + compilation + |> withOptions [ "--test:EmitFeeFeeAs100001" ] + |> asExe + |> withEmbeddedPdb + |> withEmbedAllSource + |> ignoreWarnings + +let verifyCompilation compilation = + compilation + |> coreOptions + |> compile + |> shouldSucceed + |> verifyPEFileWithSystemDlls + |> verifyILBaseline + +// Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the +// very same input .fs file (no input duplication / drift) without clobbering the default baseline. +let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = + match cUnit with + | FS src -> + let baseline = + src.Baseline + |> Option.map (fun bsl -> + let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") + let content = if File.Exists path then Some(File.ReadAllText path) else None + { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) + FS { src with Baseline = baseline } + | other -> other + +let verifyPreviewCompilation compilation = + compilation + |> coreOptions + |> withLangVersionPreview + |> withPreviewBaseline + |> compile + |> shouldSucceed + |> verifyPEFileWithSystemDlls + |> verifyILBaseline + +[] +let ``DelegateKnownFunction_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateKnownFunction_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateGenericStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateGenericStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateGenericInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateGenericInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateUnitArg_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateUnitArg_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateNegativeCases_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateNegativeCases_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateNonInlinable_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateNonInlinable_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegatePartialApplication_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegatePartialApplication_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateUnitReturn_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateUnitReturn_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateStructTarget_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateStructTarget_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateExtensionMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateExtensionMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateILMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation - [] - let ``DelegateILMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation +[] +let ``DelegateILMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation - [] - let ``DelegateCustomType_fs`` compilation = - compilation |> getCompilation |> verifyCompilation +[] +let ``DelegateCustomType_fs`` compilation = + compilation |> getCompilation |> verifyCompilation - [] - let ``DelegateCustomType_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation +[] +let ``DelegateCustomType_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation - [] - let ``Direct delegates target the real method and dispatch correctly (preview)`` () = - FSharp """ +[] +let ``Direct delegates target the real method and dispatch correctly (preview)`` () = + FSharp """ module DirectDelegateExecution open System @@ -203,14 +199,14 @@ let main _ = if not (obj.ReferenceEquals(vd.Target, b)) then failwith "virtual: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> compileExeAndRun - |> shouldSucceed - - [] - let ``Without the feature the delegate goes through a closure (default langversion)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +[] +let ``Without the feature the delegate goes through a closure (default langversion)`` () = + FSharp """ module ClosureDelegateExecution open System @@ -225,16 +221,16 @@ let main _ = // Without the feature the delegate is built over a generated closure method named 'Invoke'. if d.Method.Name <> "Invoke" then failwithf "expected closure Method.Name 'Invoke' but got '%s'" d.Method.Name 0 - """ - |> compileExeAndRun - |> shouldSucceed - - // IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded - // delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure - // 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. - [] - let ``IL method targets are emitted directly when optimized (preview)`` () = - FSharp """ + """ + |> compileExeAndRun + |> shouldSucceed + +// IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded +// delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure +// 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. +[] +let ``IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ module IlMethodDelegate open System @@ -245,18 +241,18 @@ let main _ = if d.Invoke(3, 7) <> 7 then failwith "il: wrong result" if d.Method.Name <> "Max" then failwithf "il: expected direct 'Max' but got '%s'" d.Method.Name 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct - // delegate would evaluate it once at construction. When the receiver has an effect (here a counter- - // bumping call) that difference is observable, so the closure must be kept even under optimization. - [] - let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct +// delegate would evaluate it once at construction. When the receiver has an effect (here a counter- +// bumping call) that difference is observable, so the closure must be kept even under optimization. +[] +let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = + FSharp """ module ReceiverEffectDelegate open System @@ -280,17 +276,17 @@ let main _ = if r1 = r2 then failwithf "expected distinct boxes per invoke but got %d and %d" r1 r2 if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the - // receiver and Method.Name the real method. - [] - let ``Instance IL method targets are emitted directly when optimized (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the +// receiver and Method.Name the real method. +[] +let ``Instance IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ module IlInstanceMethodDelegate open System @@ -306,18 +302,18 @@ let main _ = if d.Method.Name <> "Append" then failwithf "il-instance: expected direct 'Append' but got '%s'" d.Method.Name if not (obj.ReferenceEquals(d.Target, sb)) then failwith "il-instance: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. - // Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an - // instance target (Target = receiver) through a user-defined delegate. - [] - let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. +// Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an +// instance target (Target = receiver) through a user-defined delegate. +[] +let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = + FSharp """ module CustomDelegateExecution open System @@ -344,7 +340,156 @@ let main _ = if di.Method.Name <> "M" then failwithf "instance: expected 'M' but got '%s'" di.Method.Name if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> compileExeAndRun - |> shouldSucceed + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 33-38: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the +// shape is not recognized and a closure is kept even in release. +[] +let ``Tupled application stays a closure (preview)`` () = + FSharp """ +module TupledClosure + +open System + +[] +let accT (x: int, y: int) : int = x + y + +[] +let main _ = + let d = Func(fun a b -> accT (a, b)) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Cases 39-43: a partial application leaves the target with more parameters than the delegate's Invoke, +// so there is no closed direct form and a closure is kept. +[] +let ``Partial application stays a closure (preview)`` () = + FSharp """ +module PartialClosure + +open System + +[] +let add3 (x: int) (y: int) (z: int) : int = x + y + z + +[] +let main _ = + let d = Func(add3 1) + if d.Invoke(2, 3) <> 6 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 48-49: the synthesized unit argument is seen as a leading argument for a static target, so a +// unit-argument delegate stays a closure (and still runs). +[] +let ``Unit-argument delegate stays a closure (preview)`` () = + FSharp """ +module UnitArgClosure + +open System + +let mutable ran = false +let handler () : unit = ran <- true + +[] +let main _ = + let d = Action(handler) + d.Invoke() + if not ran then failwith "did not run" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so +// it stays a closure and still dispatches correctly. +[] +let ``Struct value-type receiver stays a closure (preview)`` () = + FSharp """ +module StructClosure + +open System + +[] +type S = + member _.Add (x: int) (y: int) : int = x + y + +[] +let main _ = + let s = S() + let d = Func(s.Add) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is +// bound as a leading argument (a partial application) and stays a closure. +[] +let ``Extension member stays a closure (preview)`` () = + FSharp """ +module ExtensionClosure + +open System +open System.Runtime.CompilerServices + +type Holder() = class end + +[] +type HolderExtensions = + [] + static member Combine (h: Holder, x: int, y: int) : int = x + y + +[] +let main _ = + let h = Holder() + let d = Func(fun a b -> h.Combine(a, b)) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Case 53: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays +// a closure and mutates through the byref correctly. +[] +let ``Byref-parameter delegate stays a closure and mutates (preview)`` () = + FSharp """ +module ByrefClosure + +open System + +type D = delegate of byref -> unit + +[] +let main _ = + let d = D(fun x -> x <- x + 1) + let mutable v = 10 + d.Invoke(&v) + if v <> 11 then failwithf "expected 11 but got %d" v + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed From 2d60fe4ef18419f8c8c2b637cb836ff76503b2c4 Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 25 Jun 2026 19:36:07 +0200 Subject: [PATCH 5/8] Remove duplicate test cases --- .../DirectDelegates/DelegateCustomType.fs | 14 ++-- .../DelegateExtensionMethod.fs | 2 +- .../DelegateGenericInstanceMethod.fs | 4 +- ...stanceMethod.fs.OptimizeOff.Preview.il.bsl | 12 ++-- ...enericInstanceMethod.fs.OptimizeOff.il.bsl | 12 ++-- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 6 +- ...GenericInstanceMethod.fs.OptimizeOn.il.bsl | 6 +- .../DelegateGenericStaticMethod.fs | 8 +-- ...StaticMethod.fs.OptimizeOff.Preview.il.bsl | 8 +-- ...eGenericStaticMethod.fs.OptimizeOff.il.bsl | 12 ++-- ...cStaticMethod.fs.OptimizeOn.Preview.il.bsl | 12 ++-- ...teGenericStaticMethod.fs.OptimizeOn.il.bsl | 12 ++-- .../DirectDelegates/DelegateILMethod.fs | 4 +- .../DirectDelegates/DelegateInstanceMethod.fs | 12 ++-- ...stanceMethod.fs.OptimizeOff.Preview.il.bsl | 16 ++--- ...legateInstanceMethod.fs.OptimizeOff.il.bsl | 36 +++++----- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 14 ++-- ...elegateInstanceMethod.fs.OptimizeOn.il.bsl | 24 +++---- .../DirectDelegates/DelegateKnownFunction.fs | 12 ++-- ...nownFunction.fs.OptimizeOff.Preview.il.bsl | 14 ++-- ...elegateKnownFunction.fs.OptimizeOff.il.bsl | 18 ++--- ...KnownFunction.fs.OptimizeOn.Preview.il.bsl | 18 ++--- ...DelegateKnownFunction.fs.OptimizeOn.il.bsl | 18 ++--- .../DirectDelegates/DelegateNegativeCases.fs | 8 +-- .../DirectDelegates/DelegateNonInlinable.fs | 22 ++---- ...NonInlinable.fs.OptimizeOff.Preview.il.bsl | 54 -------------- ...DelegateNonInlinable.fs.OptimizeOff.il.bsl | 72 ------------------- ...eNonInlinable.fs.OptimizeOn.Preview.il.bsl | 70 ------------------ .../DelegateNonInlinable.fs.OptimizeOn.il.bsl | 70 ------------------ .../DelegatePartialApplication.fs | 8 +-- .../DirectDelegates/DelegateStaticMethod.fs | 12 ++-- ...StaticMethod.fs.OptimizeOff.Preview.il.bsl | 14 ++-- ...DelegateStaticMethod.fs.OptimizeOff.il.bsl | 18 ++--- ...eStaticMethod.fs.OptimizeOn.Preview.il.bsl | 18 ++--- .../DelegateStaticMethod.fs.OptimizeOn.il.bsl | 18 ++--- .../DirectDelegates/DelegateStructTarget.fs | 4 +- .../DirectDelegates/DelegateUnitArg.fs | 4 +- .../DirectDelegates/DelegateUnitReturn.fs | 8 +-- .../DirectDelegates/DirectDelegates.fs | 12 ++-- 39 files changed, 214 insertions(+), 492 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index 02f6b3101ad..c53cbdbec35 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -24,24 +24,24 @@ type C() = member _.M (x: int) (y: int) : int = x * y // Tupled-signature custom delegate: Invoke(int, int). -// 30. non-eta module function, custom delegate +// 28. non-eta module function, custom delegate let tupledNonEta () = DTupled(acc) -// 15. eta module function, custom delegate +// 14. eta module function, custom delegate let tupledEta () = DTupled(fun a b -> acc a b) // Instance member through a custom delegate: the receiver becomes the delegate's Target. -// 31. non-eta instance member, custom delegate +// 29. non-eta instance member, custom delegate let instanceNonEta (c: C) = DTupled(c.M) -// 16. eta instance member, custom delegate +// 15. eta instance member, custom delegate let instanceEta (c: C) = DTupled(fun a b -> c.M a b) // Generic custom delegate instantiated at int: Invoke(int):int over the generic target. -// 32. non-eta generic method, generic custom delegate +// 30. non-eta generic method, generic custom delegate let genNonEta () = DGen(ident) -// 17. eta generic method, generic custom delegate +// 16. eta generic method, generic custom delegate let genEta () = DGen(fun x -> ident x) // byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding // call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. -// 53. byref-parameter delegate (mutating body) +// 51. byref-parameter delegate (mutating body) let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index e1118463d0b..b21ed6be396 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -15,5 +15,5 @@ type HolderExtensions = // An extension member compiles to a static method whose first parameter is the receiver, so using it as a // delegate target binds that receiver as a leading argument - a partial application, which has no closed // direct-delegate form. A closure must remain regardless of langversion. -// 52. extension member (receiver is a leading static arg) +// 50. extension member (receiver is a leading static arg) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs index 76adc561105..535bee3d582 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -9,5 +9,5 @@ type C() = // 5. eta generic instance method (curried application) let case5_etaCurried (o: C) = Action(fun a b -> o.IMc a b) -// 37. eta generic instance method, tupled application -let case37_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) +// 35. eta generic instance method, tupled application +let case35_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl index 154f0d0415a..12696733399 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case35_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case35_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -144,13 +144,13 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case35_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl index 154f0d0415a..12696733399 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case35_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case35_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -144,13 +144,13 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case35_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 9e16587d173..74be77228f1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,12 +105,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl index 9e16587d173..74be77228f1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,12 +105,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs index f35b3caf46d..a4e30bdaf08 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -6,11 +6,11 @@ type G<'U> = static member SMc<'T> (x: 'T) (y: 'T) : unit = () static member SMt<'T> (x: 'T, y: 'T) : unit = () -// 20. non-eta generic static method (generic type + generic method) -let case20_nonEta () = Action(G.SMc) +// 19. non-eta generic static method (generic type + generic method) +let case19_nonEta () = Action(G.SMc) // 3. eta generic static method (curried application) let case3_etaCurried () = Action(fun a b -> G.SMc a b) -// 35. eta generic static method, tupled application -let case35_etaTupled () = Action(fun a b -> G.SMt(a, b)) +// 33. eta generic static method, tupled application +let case33_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl index 0f0dd9201ea..39cb26442a6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 @@ -118,12 +118,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl index f22ac83b012..52f0ce42863 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -113,12 +113,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -137,12 +137,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl index d29d01ad424..b3e611b286a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,12 +98,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -122,12 +122,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl index 6d706bf6afb..97f8c55b9dc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,12 +98,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -122,12 +122,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs index 04304ab05d0..5be6e249aff 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -8,9 +8,9 @@ open System.Text // unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable // for the F#-value equivalent. -// 13. eta IL/BCL static method (System.Math.Max). +// 12. eta IL/BCL static method (System.Math.Max). let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) -// 14. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a +// 13. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a // parameter, evaluated at the construction site and carried as the delegate's Target. let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs index c76c310d5e9..76c6c53e334 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -8,14 +8,14 @@ type C(k: int) = abstract V : int -> int -> unit default _.V (x: int) (y: int) : unit = ignore k -// 21. non-eta instance method -let case21_nonEta (o: C) = Action(o.AddC) +// 20. non-eta instance method +let case20_nonEta (o: C) = Action(o.AddC) // 4. eta instance method (curried application) let case4_etaCurried (o: C) = Action(fun a b -> o.AddC a b) -// 36. eta instance method, tupled application -let case36_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) +// 34. eta instance method, tupled application +let case34_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) -// 22. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch -let case22_virtual (o: C) = Action(o.V) +// 21. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let case21_virtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl index f01abe41e4a..876f6a1aaee 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case34_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case34_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -155,7 +155,7 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 @@ -180,20 +180,20 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case34_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl index c5e6b7997f6..a9c6bfae607 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case21_nonEta@12::o + IL_0002: stfld class assembly/C assembly/case20_nonEta@12::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case21_nonEta@12::o + IL_0001: ldfld class assembly/C assembly/case20_nonEta@12::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case34_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -177,7 +177,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case34_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case22_virtual@21::o + IL_0002: stfld class assembly/C assembly/case21_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o + IL_0001: ldfld class assembly/C assembly/case21_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,13 +221,13 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case21_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: newobj instance void assembly/case20_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case20_nonEta@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -247,26 +247,26 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case34_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + IL_0001: newobj instance void assembly/case21_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_virtual@21::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 84816e669f0..0395005c4a6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,12 +119,12 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case20_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -143,19 +143,19 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl index 71fd756ac65..b3569cf1a24 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,7 +119,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -130,7 +130,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case22_virtual@21::o + IL_0002: stfld class assembly/C assembly/case21_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o + IL_0001: ldfld class assembly/C assembly/case21_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -152,12 +152,12 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case20_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -176,25 +176,25 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + IL_0001: newobj instance void assembly/case21_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_virtual@21::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs index 50debc1ffcb..8e550999ddf 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -7,14 +7,14 @@ let handlerCurried (x: int) (y: int) : unit = () let handlerTupled (x: int, y: int) : unit = () let handler3 (x: int) (y: int) (z: int) : unit = () -// 18. non-eta module function -let case18_nonEta () = Action(handlerCurried) +// 17. non-eta module function +let case17_nonEta () = Action(handlerCurried) // 1. eta module function (curried application) let case1_etaCurried () = Action(fun a b -> handlerCurried a b) -// 33. eta module function, tupled application (same compiled representation) -let case33_etaTupled () = Action(fun a b -> handlerTupled (a, b)) +// 31. eta module function, tupled application (same compiled representation) +let case31_etaTupled () = Action(fun a b -> handlerTupled (a, b)) -// 39. partial application of module function (constant arg) -let case39_partial () = Action(handler3 1) +// 37. partial application of module function (constant arg) +let case37_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl index e34b7189e73..dcd46c650c9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -120,7 +120,7 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 @@ -144,24 +144,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl index b1169b274d3..4d080c7c4a9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -90,7 +90,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -139,12 +139,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -163,24 +163,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index 43d1a477c17..c737dc4e5dd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,12 +117,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -141,24 +141,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl index 6d997901f37..2ac94696387 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ 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 abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,12 +117,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -141,24 +141,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index a18125b447b..4f1c2e34a96 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -2,22 +2,22 @@ module DelegateNegativeCases open System -// 44. first-class function value: there is no target method to point at, so a closure must remain +// 42. first-class function value: there is no target method to point at, so a closure must remain let firstClass (handler: int -> int -> unit) = Action(handler) -// 45. lambda body is not a single direct forwarding call to a known target (the argument is computed, +// 43. lambda body is not a single direct forwarding call to a known target (the argument is computed, // not the delegate parameters forwarded as-is): a closure must remain let private sink (x: int) : unit = () let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) -// 46. arguments reordered: not a transparent forwarding, so a closure must remain +// 44. arguments reordered: not a transparent forwarding, so a closure must remain let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) type Holder() = [] member _.TakesObj (x: obj) : int = 1 -// 47. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. +// 45. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. // The CLR would accept this binding directly (a delegate may bind a method whose parameter is a supertype), // but it stays a closure: F# elaborates the 'string -> obj' argument upcast as a coercion, so the forwarded // argument is no longer a verbatim Invoke parameter and the direct-delegate recognizer does not match. (The diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index d1457922935..0cdba8a007a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -8,20 +8,20 @@ let accCurried (x: int) (y: int) : int = x + y [] let accTupled (x: int, y: int) : int = x + y -// 23. non-eta module function, non-inlinable +// 22. non-eta module function, non-inlinable let niNonEta () = Func(accCurried) // 6. eta module function, non-inlinable (curried application) let niEtaCurried () = Func(fun a b -> accCurried a b) -// 38. eta module function, non-inlinable, tupled application +// 36. eta module function, non-inlinable, tupled application let niEtaTupled () = Func(fun a b -> accTupled (a, b)) type S = [] static member AccS (x: int) (y: int) : int = x + y -// 24. non-eta static method, non-inlinable +// 23. non-eta static method, non-inlinable let niStaticNonEta () = Func(S.AccS) // 7. eta static method, non-inlinable @@ -34,26 +34,14 @@ type C(k: int) = [] member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x -// 25. non-eta instance method, non-inlinable +// 24. non-eta instance method, non-inlinable let niInstanceNonEta (o: C) = Func(o.AccC) // 8. eta instance method, non-inlinable let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) -// 26. non-eta generic instance method, non-inlinable +// 25. non-eta generic instance method, non-inlinable let niGenericInstanceNonEta (o: C) = Func(o.GPick) // 9. eta generic instance method, non-inlinable let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) - -// A trivial, inlinable target kept on purpose to document and -// guard the inline-vs-direct interaction. In release the optimizer may inline the body before the -// recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) -// for this to still become a direct delegate. -let trivial (x: int) (y: int) : int = x + y - -// 27. non-eta inlinable trivial target (inline-race contrast) -let niTrivialNonEta () = Func(trivial) - -// 10. eta inlinable trivial target (inline-race) -let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl index b359893da86..15f41614e90 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl @@ -217,24 +217,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -370,42 +352,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::trivial(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl index 123299f5ca8..dea6f5753aa 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl @@ -318,42 +318,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -491,42 +455,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl index 4f7a18609ca..f2ac084ccbb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl @@ -116,40 +116,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -283,42 +249,6 @@ IL_000c: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl index 8a4ce549f4a..3f3f5dc01ed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl @@ -316,40 +316,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -487,42 +453,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs index 05dce73a5ee..2e1a9a13c4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -2,7 +2,7 @@ module DelegatePartialApplication open System -// Cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// Cases 37/38 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a // constant first argument, so their closure can stay static (the constant is re-materialised in Invoke // with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance // field, which exercises a distinct emit path. None of these can ever become a direct delegate (the @@ -16,11 +16,11 @@ type C = type I(k: int) = member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k -// 41. partial application of module function (captured var: instance-field capture of n) +// 39. partial application of module function (captured var: instance-field capture of n) let papKnownVar (n: int) = Action(handler3 n) -// 42. partial application of static method (captured var) +// 40. partial application of static method (captured var) let papStaticVar (n: int) = Action(C.Add3 n) -// 43. partial application of instance method (captures both the receiver and n) +// 41. partial application of instance method (captures both the receiver and n) let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs index c77a2fc19dc..a78c9c97dac 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -7,15 +7,15 @@ type C = static member AddT (x: int, y: int) : unit = () static member Add3 (x: int) (y: int) (z: int) : unit = () -// 19. non-eta static method +// 18. non-eta static method // (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) -let case19_nonEta () = Action(C.AddC) +let case18_nonEta () = Action(C.AddC) // 2. eta static method (curried application) let case2_etaCurried () = Action(fun a b -> C.AddC a b) -// 34. eta static method, tupled application -let case34_etaTupled () = Action(fun a b -> C.AddT(a, b)) +// 32. eta static method, tupled application +let case32_etaTupled () = Action(fun a b -> C.AddT(a, b)) -// 40. partial application of static method (constant arg) -let case40_partial () = Action(C.Add3 1) +// 38. partial application of static method (constant arg) +let case38_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl index d7b33e7d72b..2b90acb082f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -126,7 +126,7 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 @@ -150,24 +150,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl index f1d3a8474e1..ce68901f780 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -124,7 +124,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -145,12 +145,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -169,24 +169,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index f2dd2579e43..1de6bfcc577 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,12 +123,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -147,24 +147,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl index f2dd2579e43..1de6bfcc577 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,12 +123,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -147,24 +147,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index 84785eda906..c856d1f5c7b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -10,8 +10,8 @@ type S = // The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate // would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod // for the reference-type case, which is emitted directly.) -// 50. non-eta struct (value-type) receiver +// 48. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) -// 51. eta struct (value-type) receiver +// 49. eta struct (value-type) receiver let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index a72fe20cf80..7a164ad4045 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -4,8 +4,8 @@ open System let handler () : unit = () -// 48. non-eta unit-argument delegate +// 46. non-eta unit-argument delegate let caseUnitNonEta () = Action(handler) -// 49. eta unit-argument delegate +// 47. eta unit-argument delegate let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs index 10e8032a87c..eca9f6e4b1f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -6,10 +6,10 @@ open System [] let returnsUnit (x: int) (y: int) : unit = () -// 28. non-eta unit-returning member (compiled to void) +// 26. non-eta unit-returning member (compiled to void) let voidNonEta () = Action(returnsUnit) -// 11. eta unit-returning member +// 10. eta unit-returning member let voidEta () = Action(fun a b -> returnsUnit a b) type C = @@ -20,8 +20,8 @@ type C = static member Echo<'T>(x: 'T) : 'T = x // Generic return type variable instantiated to unit; the delegate likewise returns unit. -// 29. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) +// 27. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) let unitGenericReturnNonEta () = Func(C.Echo) -// 12. eta generic unit-returning method +// 11. eta generic unit-returning method let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index f14d00e5586..6bc35cbc296 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -345,7 +345,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 33-38: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the +// Cases 31-36: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the // shape is not recognized and a closure is kept even in release. [] let ``Tupled application stays a closure (preview)`` () = @@ -369,7 +369,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 39-43: a partial application leaves the target with more parameters than the delegate's Invoke, +// Cases 37-41: a partial application leaves the target with more parameters than the delegate's Invoke, // so there is no closed direct form and a closure is kept. [] let ``Partial application stays a closure (preview)`` () = @@ -392,7 +392,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 48-49: the synthesized unit argument is seen as a leading argument for a static target, so a +// Cases 46-47: the synthesized unit argument is seen as a leading argument for a static target, so a // unit-argument delegate stays a closure (and still runs). [] let ``Unit-argument delegate stays a closure (preview)`` () = @@ -416,7 +416,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so +// Cases 48-49: a value-type receiver would need boxing (a delegate Target is object); not implemented, so // it stays a closure and still dispatches correctly. [] let ``Struct value-type receiver stays a closure (preview)`` () = @@ -441,7 +441,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is +// Case 50: an extension member compiles to a static method whose first parameter is the receiver, so it is // bound as a leading argument (a partial application) and stays a closure. [] let ``Extension member stays a closure (preview)`` () = @@ -470,7 +470,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 53: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays +// Case 51: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays // a closure and mutates through the byref correctly. [] let ``Byref-parameter delegate stays a closure and mutates (preview)`` () = From dc32fcdbd736bbaeab616a0c494531852c67e753 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 18:45:46 +0200 Subject: [PATCH 6/8] Refactor --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 168 +++++++++++++++ src/Compiler/CodeGen/IlxGen.fs | 192 +++++------------- src/Compiler/FSharp.Compiler.Service.fsproj | 1 + .../TypedTree/TypedTreeOps.ExprOps.fs | 65 ------ .../TypedTree/TypedTreeOps.ExprOps.fsi | 26 --- .../DirectDelegates/DirectDelegates.fs | 74 +++++++ 6 files changed, 296 insertions(+), 230 deletions(-) create mode 100644 src/Compiler/CodeGen/IlxGen.Delegates.fs diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs new file mode 100644 index 00000000000..4d7e8c7a2a8 --- /dev/null +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +/// Helpers for delegate construction in the ILX generator +[] +module internal FSharp.Compiler.IlxGenDelegates + +open Internal.Utilities.Collections +open Internal.Utilities.Library.Extras + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypedTree +open FSharp.Compiler.TypedTreeBasics +open FSharp.Compiler.TypedTreeOps + +/// The target of a delegate forwarding call +[] +type DelegateForwardingTarget = + /// A known F# value: a module-level function or a member + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst * leadingArgs: Expr list + /// A direct IL method call (e.g. a BCL method) + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst * + leadingArgs: Expr list + | Other + +let classifyForwardingTarget g (invokeParams: Val list) expr = + // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded + // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned + // for the consumer to handle. + let matchForwarding (args: Expr list) = + let numLeading = args.Length - invokeParams.Length + + if numLeading >= 0 then + let leadingArgs, forwardedArgs = List.splitAt numLeading args + + if + List.forall2 + (fun (a: Expr) (tv: Val) -> + match stripDebugPoints a with + | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) + | _ -> false) + forwardedArgs + invokeParams + then + ValueSome leadingArgs + else + ValueNone + else + ValueNone + + match stripDebugPoints expr with + | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | ValueNone -> DelegateForwardingTarget.Other + | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> + DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) + | ValueNone -> DelegateForwardingTarget.Other + | _ -> DelegateForwardingTarget.Other + +/// For an instance method the single leading argument is the receiver; a static method or module function +/// must have no leading arguments (otherwise it is a partial application). +let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = + if takesInstanceArg then + match leadingArgs with + | [ _ ] -> true + | _ -> false + else + List.isEmpty leadingArgs + +/// The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound when it can +/// be evaluated there exactly once and as the Target: +/// - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the receiver on +/// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable +/// value, a constant, a pure field read). +/// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. +/// ExprHasEffect short-circuits before the freeInExpr allocation, so disqualified delegates skip the traversal. +let private receiverBindable g (invokeParams: Val list) (leadingArgs: Expr list) = + match leadingArgs with + | [ recv ] -> + let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals + + not (Optimizer.ExprHasEffect g recv) + && (not (invokeParams |> List.exists (fun tv -> Zset.contains tv recvFreeLocals))) + | _ -> true + +/// An F# value target can be pointed at directly only when the call needs no witnesses and is not a +/// constructor / base / self-init call, when the receiver shape is right, and when the receiver can be safely +/// hoisted to the construction site. Only the witness fact is passed in (it needs the IlxGen environment); the +/// newobj / super-init / self-init / instance-receiver facts are derived here from the member's call info, and +/// the base-call flag from valUseFlags. +let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (vrefM: ValRef) (valUseFlags: ValUseFlag) hasWitnesses = + let _, _, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + GetMemberCallInfo g (vrefM, valUseFlags) + + not hasWitnesses + && not newobj + && not isSuperInit + && not isSelfInit + && not valUseFlags.IsVSlotDirectCall + && receiverShapeOk leadingArgs takesInstanceArg + && receiverBindable g invokeParams leadingArgs + +/// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, +/// when the receiver shape is right, when the receiver is not a value type (boxing is not yet implemented), and +/// when the receiver can be safely hoisted to the construction site. The instance-receiver flag is derived here +/// from ilMethRef and the base/constrained-call flags from valUseFlag. +let ilMethodDirectlyBindable + g + (invokeParams: Val list) + (leadingArgs: Expr list) + (ilMethRef: ILMethodRef) + isStruct + (valUseFlag: ValUseFlag) + isCtor + = + let takesInstanceArg = ilMethRef.CallingConv.IsInstance + + not isCtor + && not valUseFlag.IsVSlotDirectCall + && not valUseFlag.IsPossibleConstrainedCall + && receiverShapeOk leadingArgs takesInstanceArg + && not (takesInstanceArg && isStruct) + && receiverBindable g invokeParams leadingArgs + +/// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already +/// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, +/// so this is the residual check: +/// - parameter *count* matches (essentially a sanity check). Parameter IL *types* are deliberately not +/// compared: a value-type parameter is exact by construction (a widening/boxing argument would not be a +/// verbatim Val and so would not have matched), and for reference-type parameters the CLR's delegate +/// relaxation permits contravariance, so an exact comparison would only produce false negatives. +/// - for a non-generic target, the return type matches exactly. This is the one IL mismatch the recognizer +/// cannot see and the CLR will not relax: notably an F# 'unit' return compiled to 'void' versus a delegate +/// whose Invoke returns 'Unit'. For a generic target the return is written in terms of type variables, so +/// no exact comparison is meaningful. +let signatureMatches + (ilDelegeeParams: ILParameter list) + (ilDelegeeRet: ILReturn) + (ilEnclArgTys: ILType list) + (ilMethArgTys: ILType list) + (targetMspec: ILMethodSpec) + = + let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + + let returnMatches = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + ilDelegeeRet.Type = targetMspec.FormalReturnType + else + true + + arityMatches && returnMatches + +/// Package the receiver (if any) with the virtual-call flag for the consumer to emit. +let receiverInfo (leadingArgs: Expr list) virtualCall = + match leadingArgs with + | [ recv ] -> Some(recv, virtualCall) + | _ -> None diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ff83e60226c..a4433bfcedf 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7464,17 +7464,14 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a // known static method, module-level function, or instance method, point the delegate straight at that - // method instead of generating an intermediate closure class. For a static target the receiver is null - // (ldnull; ldftn target); for an instance target the receiver is evaluated and the function pointer is - // bound with ldftn, or dup; ldvirtftn for a virtual target so dispatch is preserved. A strict - // IL-signature check makes the rewrite provably equivalent to the closure form; anything that does not - // match exactly falls back to the closure path below. Gated by LanguageFeature.DirectDelegateConstruction. + // method instead of generating an intermediate closure class. Anything that does not match exactly + // falls back to the closure path below. let directDelegateTarget = if not (g.langVersion.SupportsFeature LanguageFeature.DirectDelegateConstruction) then None elif not cenv.options.localOptimizationsEnabled - && tmvs |> List.exists (fun (v: Val) -> not v.IsCompilerGenerated) + && tmvs |> List.exists (fun v -> not v.IsCompilerGenerated) then // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda // variables, so keep the closure to preserve their names for debugging. Non-eta delegates (whose @@ -7483,152 +7480,69 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // forwarding call survives to here. None else - match body with - | DirectDelegateForwardingCall g tmvs (target, leadingArgs) -> - // For an instance method the single leading argument is the receiver; a static method or - // module function must have no leading arguments (otherwise it is a partial application). - let receiverShapeOk takesInstanceArg = - if takesInstanceArg then - match leadingArgs with - | [ _ ] -> true - | _ -> false - else - List.isEmpty leadingArgs - - // The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound - // when it can be evaluated there exactly once and as the Target: - // - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the - // receiver on every Invoke; evaluating it once instead is observable unless it is - // side-effect free (a non-mutable value, a constant, a pure field read). - // - It must not reference the delegate's own Invoke parameters, which only exist inside the - // delegee method. - // Checked lazily (and after the cheaper structural bails) so disqualified delegates skip the - // receiver traversal; ExprHasEffect short-circuits before the freeInExpr allocation. - let receiverNotBindable () = - match leadingArgs with - | [ recv ] -> - Optimizer.ExprHasEffect g recv - || (let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals - tmvs |> List.exists (fun tv -> Zset.contains tv recvFreeLocals)) - | _ -> false - - // The type checker has already verified that the delegate is built from a compatible function - // shape, and the structural match above forwards the Invoke parameters verbatim, so the - // target's signature is compatible with the delegate's Invoke by construction. We confirm: - // - parameter *count* matches (already guaranteed by the verbatim forwarding, so essentially - // a sanity check). We deliberately do not compare parameter IL *types*: a value-type - // parameter is exact by construction (a widening/boxing argument would not be a verbatim - // Val and so would not have matched), and for reference-type parameters the CLR's delegate - // relaxation permits contravariance, so an exact comparison would only produce false - // negatives (a CLR-legal binding bailing to a closure). - // - for a non-generic target, the return type matches exactly. This is the one IL mismatch - // the recognizer cannot see and the CLR will not relax: notably an F# 'unit' return - // compiled to 'void' versus a delegate whose Invoke returns 'Unit'. For a generic target - // the return is written in terms of type variables, so no exact comparison is meaningful. - let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = - let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length - - let returnMatches = - if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then - ilDelegeeRet.Type = targetMspec.FormalReturnType - else - true + match classifyForwardingTarget g tmvs body with + | DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> + match StorageForValRef m vref eenvouter with + | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> + let _, witnessInfos, _, _, _ = + GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - arityMatches && returnMatches + let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - let receiverInfo virtualCall = - match leadingArgs with - | [ recv ] -> Some(recv, virtualCall) - | _ -> None - - match target with - | DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs) -> - match StorageForValRef m vref eenvouter with - | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> - let _, witnessInfos, _, _, _ = - GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - - let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - - let _, virtualCall, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + if fsharpValDirectlyBindable g tmvs leadingArgs vrefM valUseFlags hasWitnesses then + let _, virtualCall, _, _, _, takesInstanceArg, _, _ = GetMemberCallInfo g (vrefM, valUseFlags) - let isBaseCall = valUseFlags.IsVSlotDirectCall + let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs - if - hasWitnesses - || newobj - || isSuperInit - || isSelfInit - || isBaseCall - || not (receiverShapeOk takesInstanceArg) - || receiverNotBindable () - then + let numEnclILTypeArgs = + if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then + List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) + else + 0 + + if ilTyArgs.Length < numEnclILTypeArgs then None else - let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs + let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs + let boxity = mspec.DeclaringType.Boxity + let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) - let numEnclILTypeArgs = - if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then - List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) - else - 0 - - if ilTyArgs.Length < numEnclILTypeArgs then + if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then + None + elif takesInstanceArg && boxity.IsAsValue then + // value-type receivers not handled None + elif signatureMatches ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec then + Some(targetMspec, receiverInfo leadingArgs virtualCall) else - let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs - let boxity = mspec.DeclaringType.Boxity - let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) - - if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then - None - elif takesInstanceArg && boxity = AsValue then - // value-type receivers not handled - None - elif signatureMatches ilEnclArgTys ilMethArgTys targetMspec then - Some(targetMspec, receiverInfo virtualCall) - else - None - | _ -> None - - | DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst) -> - // A direct IL call (e.g. a BCL method). Everything needed to build the method spec is on - // the node, so there is no storage/witness resolution; we still bail on the shapes that - // have no closed direct-delegate form. - let isBaseCall = valUseFlag.IsVSlotDirectCall - - let isConstrainedCall = valUseFlag.IsPossibleConstrainedCall + None + else + None + | _ -> None - let takesInstanceArg = ilMethRef.CallingConv.IsInstance + | DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> + if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then + let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst + let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst let boxity = if isStruct then AsValue else AsObject - - if - isCtor - || isBaseCall - || isConstrainedCall - || not (receiverShapeOk takesInstanceArg) - || (takesInstanceArg && boxity = AsValue) - || receiverNotBindable () - then - None + let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + + // Unlike the F# case we cannot compare parameter/return IL types here: the target's + // types come from imported metadata, whose assembly scope refs differ from the + // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare + // primary-assembly form), so structural equality reports false negatives for the very + // primitives that always match. The forwarding match already pins the arity, and the + // type checker has verified the call is well-typed, so element compatibility holds by + // construction; an arity check is the sound guard (matching the generic case). + if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then + Some(targetMspec, receiverInfo leadingArgs isVirtual) else - let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst - let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst - let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) - - // Unlike the F# case we cannot compare parameter/return IL types here: the target's - // types come from imported metadata, whose assembly scope refs differ from the - // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare - // primary-assembly form), so structural equality reports false negatives for the very - // primitives that always match. The forwarding match already pins the arity, and the - // type checker has verified the call is well-typed, so element compatibility holds by - // construction; an arity check is the sound guard (matching the generic case). - if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then - Some(targetMspec, receiverInfo isVirtual) - else - None - | _ -> None + None + else + None + + | DelegateForwardingTarget.Other -> None match directDelegateTarget with | Some(targetMspec, receiverInfo) -> diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 5510af6b3f6..d088eee527f 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,6 +442,7 @@ + diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs index 54c28c13c18..bdebaf40ff5 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs @@ -33,24 +33,6 @@ open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypeProviders #endif -/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). -[] -type internal DirectDelegateForwardingTarget = - /// A known F# value: a module-level function or a member. Carries the value reference, its use flags - /// and the call's type arguments; the consumer resolves storage to a method spec. - | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst - /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to - /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and - /// the enclosing-type and method type instantiations. - | ILMethod of - isVirtual: bool * - isStruct: bool * - isCtor: bool * - valUseFlags: ValUseFlag * - ilMethRef: ILMethodRef * - enclTypeInst: TypeInst * - methInst: TypeInst - [] module internal AddressOps = @@ -1833,53 +1815,6 @@ module internal ExprTransforms = ) | _ -> ValueNone - /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding - /// call `target leading... p0 p1 ...` to a known method, whose trailing arguments are exactly the - /// delegate's Invoke parameters in order. This is the shape that lets a delegate point directly at - /// `target` instead of an intermediate closure. Any leading arguments (e.g. an instance method's - /// receiver) are returned to the consumer, which decides whether a direct delegate can actually be - /// emitted (matching IL signature, receiver shape, no witnesses, etc.). - [] - let (|DirectDelegateForwardingCall|_|) g (invokeParams: Val list) expr = - // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded - // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned - // for the consumer to handle. - let matchForwarding (args: Expr list) = - let numLeading = args.Length - invokeParams.Length - - if numLeading >= 0 then - let leadingArgs, forwardedArgs = List.splitAt numLeading args - - if - List.forall2 - (fun (a: Expr) (tv: Val) -> - match stripDebugPoints a with - | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) - | _ -> false) - forwardedArgs - invokeParams - then - ValueSome leadingArgs - else - ValueNone - else - ValueNone - - match stripDebugPoints expr with - | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> - match matchForwarding args with - | ValueSome leadingArgs -> ValueSome(DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs), leadingArgs) - | ValueNone -> ValueNone - | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> - match matchForwarding args with - | ValueSome leadingArgs -> - ValueSome( - DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst), - leadingArgs - ) - | ValueNone -> ValueNone - | _ -> ValueNone - [] let (|DelegateInvokeExpr|_|) g expr = match expr with diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi index afb4874f70d..ad90c5c818c 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi @@ -12,24 +12,6 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.Syntax -/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). -[] -type internal DirectDelegateForwardingTarget = - /// A known F# value: a module-level function or a member. Carries the value reference, its use flags - /// and the call's type arguments; the consumer resolves storage to a method spec. - | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst - /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to - /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and - /// the enclosing-type and method type instantiations. - | ILMethod of - isVirtual: bool * - isStruct: bool * - isCtor: bool * - valUseFlags: ValUseFlag * - ilMethRef: ILMethodRef * - enclTypeInst: TypeInst * - methInst: TypeInst - [] module internal AddressOps = @@ -562,14 +544,6 @@ module internal ExprTransforms = [] val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption - /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding - /// call to a known method (an F# value or a direct IL call) whose trailing arguments are exactly the - /// delegate's Invoke parameters in order. Returns the resolved target and any leading (non-forwarded) - /// argument expressions, e.g. an instance method's receiver. - [] - val (|DirectDelegateForwardingCall|_|): - TcGlobals -> Val list -> Expr -> (DirectDelegateForwardingTarget * Expr list) voption - [] val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * TypeInst * Expr * Expr * range) voption diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 6bc35cbc296..d23f9038694 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -493,3 +493,77 @@ let main _ = |> withLangVersionPreview |> compileExeAndRun |> shouldSucceed + +// Cross-assembly targets: the recognizer has no locality guard, so a delegate over an F# function imported +// from a *referenced* assembly takes the same FSharpVal direct path (StorageForValRef resolution + method-spec +// build across an assembly boundary) that the same-compiland baseline suite never reaches. The targets are +// [] so cross-assembly inlining cannot dissolve the forwarding call before codegen. +let private crossAssemblyLibrary = + FSharp """ +module DelegateLib + +[] +let add (x: int) (y: int) : int = x + y + +type Calc(k: int) = + [] + member _.Scale (x: int) (y: int) : int = (x + y) * k + +// A small inline function: its body is serialized into the referenced assembly and is always inlined at the +// use site (independent of --optimize), so a delegate over it can never see a forwarding call. +let inline addInline (x: int) (y: int) : int = x + y + """ + |> asLibrary + +[] +let ``Cross-assembly F# target is emitted directly (preview)`` () = + FSharp """ +module CrossAsmDirect + +open System +open DelegateLib + +[] +let main _ = + // Static module function imported from another assembly: direct, null Target, real Method.Name. + let ds = Func(add) + if ds.Invoke(2, 3) <> 5 then failwith "static: wrong result" + if ds.Method.Name <> "add" then failwithf "static: expected 'add' but got '%s'" ds.Method.Name + if not (isNull ds.Target) then failwith "static: Target should be null" + + // Instance member imported from another assembly: direct, Target is the receiver. + let c = Calc(10) + let di = Func(c.Scale) + if di.Invoke(2, 3) <> 50 then failwithf "instance: expected 50 but got %d" (di.Invoke(2, 3)) + if di.Method.Name <> "Scale" then failwithf "instance: expected 'Scale' but got '%s'" di.Method.Name + if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" + 0 + """ + |> withReferences [ crossAssemblyLibrary ] + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// An inline target from a referenced assembly is always inlined before the recognizer runs, so the forwarding +// call vanishes and a closure is kept even in release - the deterministic cross-assembly end of the inline-race. +[] +let ``Cross-assembly inline target stays a closure (preview)`` () = + FSharp """ +module CrossAsmInline + +open System +open DelegateLib + +[] +let main _ = + let d = Func(fun a b -> addInline a b) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withReferences [ crossAssemblyLibrary ] + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed From 8017ff02cee30f97b7bd841cebf36d20c7e80936 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 20:10:12 +0200 Subject: [PATCH 7/8] Build fix --- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index d088eee527f..5dd9af61ccc 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,7 +442,7 @@ - + From cd6e3c6650a76036ac08905425c75dd048360fc6 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 20:35:59 +0200 Subject: [PATCH 8/8] Build fix --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 16 +++++++--------- src/Compiler/CodeGen/IlxGen.fs | 6 +++--- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index 4d7e8c7a2a8..858f61c6821 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -5,18 +5,16 @@ module internal FSharp.Compiler.IlxGenDelegates open Internal.Utilities.Collections -open Internal.Utilities.Library.Extras open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypedTreeOps -/// The target of a delegate forwarding call +/// A delegate target that can potentially be forwarded to directly, without an intermediate closure [] -type DelegateForwardingTarget = +type DirectDelegateForwardingTargetCandidate = /// A known F# value: a module-level function or a member | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst * leadingArgs: Expr list /// A direct IL method call (e.g. a BCL method) @@ -59,14 +57,14 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = match stripDebugPoints expr with | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> match matchForwarding args with - | ValueSome leadingArgs -> DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) - | ValueNone -> DelegateForwardingTarget.Other + | ValueSome leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | ValueNone -> DirectDelegateForwardingTargetCandidate.Other | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> match matchForwarding args with | ValueSome leadingArgs -> - DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) - | ValueNone -> DelegateForwardingTarget.Other - | _ -> DelegateForwardingTarget.Other + DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) + | ValueNone -> DirectDelegateForwardingTargetCandidate.Other + | _ -> DirectDelegateForwardingTargetCandidate.Other /// For an instance method the single leading argument is the receiver; a static method or module function /// must have no leading arguments (otherwise it is a partial application). diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index a4433bfcedf..fda1a18a440 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7481,7 +7481,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None else match classifyForwardingTarget g tmvs body with - | DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> + | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> match StorageForValRef m vref eenvouter with | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> let _, witnessInfos, _, _, _ = @@ -7521,7 +7521,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None | _ -> None - | DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> + | DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst @@ -7542,7 +7542,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, else None - | DelegateForwardingTarget.Other -> None + | DirectDelegateForwardingTargetCandidate.Other -> None match directDelegateTarget with | Some(targetMspec, receiverInfo) -> diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 5dd9af61ccc..50492504777 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,7 +442,7 @@ - +