-
Notifications
You must be signed in to change notification settings - Fork 831
Description
Maybe it's a known (compiler) limitation but it seems that an inherited padded generic class with inline members will result compiler internal errors. Please note I already have a struct based field padding implementation - but I would like to also make this work with this object inheritance based padding mechanism. Unfortunately a single class and padding fields will not work, because the JIT free to reorder the fields within a clas but it will not reorder the fields across "inheritance borders".
The non-full example code looks like this:
[<NoEquality; NoComparison>]
[<Class>]
type PaddedReferenceRightPad<'T when 'T : not struct> =
inherit PaddedReferenceBase<'T>
val mutable Right: PaddedReferenceRightPadding
new() = { inherit PaddedReferenceBase<'T>(); Right = PaddedReferenceRightPadding() }
new(v: 'T) = { inherit PaddedReferenceBase<'T>(v); Right = PaddedReferenceRightPadding() }
[<NoEquality; NoComparison>]
[<Class>]
type PaddedReference<'T when 'T : not struct> =
inherit PaddedReferenceRightPad<'T>
new(value) = { inherit PaddedReferenceRightPad<'T>(value) }
member inline x.Read() =
GenericOperations.read x.Value
member inline x.ReadByRef() =
GenericOperations.readByRef &x.ValueThe full example code are available here:
https://gist.github.com/zpodlovics/aa333619a39facdeba90
Compilation will result the following errors
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS0073: internal error: the mustinline value 'Read' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS0073: internal error: the mustinline value 'ReadByRef' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS1113: The value 'Read' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS1113: The value 'ReadByRef' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS0073: internal error: the mustinline value 'Read' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS0073: internal error: the mustinline value 'ReadByRef' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS1113: The value 'Read' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS1113: The value 'ReadByRef' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
Is there any workaround available to use this object inheritance based padding mechanism?
Thanks for your help,
Zoltan