Open kostya9 opened 3 years ago
That use of with
is unusual. Could you try this?
type SyntaxHighlightingRendererWrapper() =
inherit CodeBlockRenderer()
let highlightingRenderer = HighlightedCodeBlockRenderer()
override _.Write(renderer: HtmlRenderer, codeBlock: CodeBlock): unit =
highlightingRenderer.Write(renderer, codeBlock)
I think the issue is related to protected
- Could you link the exact definitions of the virtual Write
method please?
Sure, tried with the syntax without with
, the problem unfortunately persists.
Overload resolution
Did some additional investigation.
With the Write
inlined, the overload taken is
override HighlightedCodeBlockRenderer.Write : renderer:HtmlRenderer * cb:CodeBlock -> unit
With the Write
in a separate render
function, the overload is:
MarkdownObjectRenderer.Write(renderer: RendererBase, obj: MarkdownObject) : unit
Seems like the overload resolution somehow changes depending on the context?
Method in inheritance hierarchy
Here are the exact definitions of the Write
method in the inheritance hierarchy:
override __.Write(renderer : HtmlRenderer, cb : CodeBlock)
inherits from CodeBlockRenderer
protected override void Write(HtmlRenderer renderer, CodeBlock obj)
inherits from HtmlObjectRenderer<CodeBlock>
inherits from MarkdownObjectRenderer<HtmlRenderer, TObject> where TObject : MarkdownObject
public virtual void Write(RendererBase renderer, MarkdownObject obj);
protected abstract void Write(TRenderer renderer, TObject obj);
Repro steps
type SyntaxHighlightingRendererWrapper() = inherit CodeBlockRenderer() with let highlightingRenderer = HighlightedCodeBlockRenderer()
Program.fs(12, 13): [FS0629] Method 'Write' is not accessible from this code location
Related information
I can only guess that this has something to do with overload resolution. Type
HighlightedCodeBlockRenderer
inherits fromMarkdownObjectRenderer
that has a similar protected method: