Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
* F# Scripts: Fix default reference paths resolving when an SDK directory is specified. ([PR #19270](https://github.com/dotnet/fsharp/pull/19270))
* Improve static compilation of state machines. ([PR #19297](https://github.com/dotnet/fsharp/pull/19297))
* Fix a bug where `let!` and `use!` were incorrectly allowed outside computation expressions. [PR #19347](https://github.com/dotnet/fsharp/pull/19347)
* Fix TypeLoadException when creating delegate with voidptr parameter. (Issue [#11132](https://github.com/dotnet/fsharp/issues/11132), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Suppress tail calls when localloc (NativePtr.stackalloc) is used. (Issue [#13447](https://github.com/dotnet/fsharp/issues/13447), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix TypeLoadException in Release builds with inline constraints. (Issue [#14492](https://github.com/dotnet/fsharp/issues/14492), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix nativeptr in interfaces leads to TypeLoadException. (Issue [#14508](https://github.com/dotnet/fsharp/issues/14508), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix box instruction for literal upcasts. (Issue [#18319](https://github.com/dotnet/fsharp/issues/18319), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix Decimal Literal causes InvalidProgramException in Debug builds. (Issue [#18956](https://github.com/dotnet/fsharp/issues/18956), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))

### Added
* FSharpType: add ImportILType ([PR #19300](https://github.com/dotnet/fsharp/pull/19300))
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
* Fixed how the source ranges of warn directives are reported (as trivia) in the parser output (by not reporting leading spaces). ([Issue #19405](https://github.com/dotnet/fsharp/issues/19405), [PR #19408]((https://github.com/dotnet/fsharp/pull/19408)))
* Fix UoM value type `ToString()` returning garbage values when `--checknulls+` is enabled, caused by double address-taking in codegen. ([Issue #19435](https://github.com/dotnet/fsharp/issues/19435), [PR #19440](https://github.com/dotnet/fsharp/pull/19440))
* Fix completion inconsistently showing some obsolete members (fields and events) while hiding others (methods and properties). All obsolete members are now consistently hidden by default. ([Issue #13512](https://github.com/dotnet/fsharp/issues/13512), [PR #19506](https://github.com/dotnet/fsharp/pull/19506))
* Fix TypeLoadException when creating delegate with voidptr parameter. (Issue [#11132](https://github.com/dotnet/fsharp/issues/11132), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Suppress tail calls when localloc (NativePtr.stackalloc) is used. (Issue [#13447](https://github.com/dotnet/fsharp/issues/13447), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix TypeLoadException in Release builds with inline constraints. (Issue [#14492](https://github.com/dotnet/fsharp/issues/14492), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix nativeptr in interfaces leads to TypeLoadException. (Issue [#14508](https://github.com/dotnet/fsharp/issues/14508), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix box instruction for literal upcasts. (Issue [#18319](https://github.com/dotnet/fsharp/issues/18319), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))
* Fix Decimal Literal causes InvalidProgramException in Debug builds. (Issue [#18956](https://github.com/dotnet/fsharp/issues/18956), [PR #19338](https://github.com/dotnet/fsharp/pull/19338))

### Added

Expand Down
9 changes: 9 additions & 0 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,6 +3375,15 @@ let mkILSimpleTypar nm =
MetadataIndex = NoMetadataIdx
}

let stripILGenericParamConstraints (gp: ILGenericParameterDef) =
{ gp with
Constraints = []
HasReferenceTypeConstraint = false
HasNotNullableValueTypeConstraint = false
HasDefaultConstructorConstraint = false
HasAllowsRefStruct = false
}

let genericParamOfGenericActual (_ga: ILType) = mkILSimpleTypar "T"

let mkILFormalTypars (x: ILGenericArgsList) = List.map genericParamOfGenericActual x
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/AbstractIL/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,7 @@ val internal mkILFormalNamedTy: ILBoxity -> ILTypeRef -> ILGenericParameterDef l
val internal mkILFormalTypars: ILType list -> ILGenericParameterDefs
val internal mkILFormalGenericArgs: int -> ILGenericParameterDefs -> ILGenericArgsList
val internal mkILSimpleTypar: string -> ILGenericParameterDef
val internal stripILGenericParamConstraints: ILGenericParameterDef -> ILGenericParameterDef

/// Make custom attributes.
val internal mkILCustomAttribMethRef:
Expand Down
36 changes: 32 additions & 4 deletions src/Compiler/CodeGen/EraseClosures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,19 @@ let newIlxPubCloEnv (ilg, addMethodGeneratedAttrs, addFieldGeneratedAttrs, addFi

let mkILTyFuncTy cenv = cenv.mkILTyFuncTy

let inline private (|IsVoidPtr|_|) ty =
match ty with
| ILType.Ptr ILType.Void -> true
| _ -> false

let private fixVoidPtrForGenericArg (ilg: ILGlobals) ty =
match ty with
| IsVoidPtr -> ilg.typ_IntPtr
| _ -> ty

let mkILFuncTy cenv dty rty =
let dty = fixVoidPtrForGenericArg cenv.ilg dty
let rty = fixVoidPtrForGenericArg cenv.ilg rty
mkILBoxedTy cenv.tref_Func[0] [ dty; rty ]

let mkILCurriedFuncTy cenv dtys rty =
Expand All @@ -168,6 +180,8 @@ let typ_Func cenv (dtys: ILType list) rty =
else
mkFuncTypeRef cenv.ilg.fsharpCoreAssemblyScopeRef n

let dtys = dtys |> List.map (fixVoidPtrForGenericArg cenv.ilg)
let rty = fixVoidPtrForGenericArg cenv.ilg rty
mkILBoxedTy tref (dtys @ [ rty ])

let rec mkTyOfApps cenv apps =
Expand All @@ -190,6 +204,8 @@ let mkMethSpecForMultiApp cenv (argTys: ILType list, retTy) =
let n = argTys.Length
let formalArgTys = List.mapi (fun i _ -> ILType.TypeVar(uint16 i)) argTys
let formalRetTy = ILType.TypeVar(uint16 n)
let argTys = argTys |> List.map (fixVoidPtrForGenericArg cenv.ilg)
let retTy = fixVoidPtrForGenericArg cenv.ilg retTy
let inst = argTys @ [ retTy ]

if n = 1 then
Expand Down Expand Up @@ -548,12 +564,14 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =

let convil = convILMethodBody (Some nowCloSpec, boxReturnTy) clo.cloCode.Value

let specializeGenParams = addedGenParams |> List.map stripILGenericParamConstraints

let nowApplyMethDef =
mkILGenericVirtualMethod (
"Specialize",
ILCallingConv.Instance,
ILMemberAccess.Public,
addedGenParams (* method is generic over added ILGenericParameterDefs *) ,
specializeGenParams,
[],
mkILReturn cenv.ilg.typ_Object,
MethodBody.IL(notlazy convil)
Expand Down Expand Up @@ -681,7 +699,17 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
else
// CASE 2b - Build an Invoke method

let nowEnvParentClass = typ_Func cenv (typesOfILParams nowParams) nowReturnTy
let fixedNowParams =
nowParams
|> List.map (fun (p: ILParameter) ->
{ p with
Type = fixVoidPtrForGenericArg cenv.ilg p.Type
})

let fixedNowReturnTy = fixVoidPtrForGenericArg cenv.ilg nowReturnTy

let nowEnvParentClass =
typ_Func cenv (typesOfILParams fixedNowParams) fixedNowReturnTy

let cloTypeDef =
let convil = convILMethodBody (Some nowCloSpec, None) clo.cloCode.Value
Expand All @@ -690,8 +718,8 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
mkILNonGenericVirtualInstanceMethod (
"Invoke",
ILMemberAccess.Public,
nowParams,
mkILReturn nowReturnTy,
fixedNowParams,
mkILReturn fixedNowReturnTy,
MethodBody.IL(notlazy convil)
)

Expand Down
Loading
Loading