Summary
markanywhere-render/src/commonMain/kotlin/MarkdownRendering.kt applies Kotlin context-sensitive resolution (CSR) inconsistently: some when/lambda sites over a BlockFrame subject drop the BlockFrame. prefix (e.g. is Pre, is Code, is Inline, is Frontmatter), while structurally identical sites still use the fully-qualified BlockFrame.X. Per CLAUDE.md ("Inside a when whose subject has a known sealed type … drop the type prefix … CSR also applies to is/as against that type"), these should be consistent. This is a style/readability cleanup, surfaced during review of #57 (which added several of the unqualified forms next to pre-existing qualified ones).
Already unqualified (correct, the target style)
blockMarkerEscapingAllowed() — it is Pre || it is Code || it is Frontmatter
- the blank-text dispatch —
it is Pre || it is Code
enclosingInlineDelimiterMask / inInlineCode — is Inline, is TaggedInline, is Code
- the inline-code early-return —
inInlineCode() (was blockStack.lastOrNull() is Code)
Still fully-qualified (to normalize)
In MarkdownRendering.kt (line numbers approximate, will drift):
buildPrefix when (subject BlockFrame): is BlockFrame.Blockquote, is BlockFrame.List, (next as? BlockFrame.ListItem)
spillActiveLinks: frame !is BlockFrame.Link
- the block-spill guard:
blockStack.any { it is BlockFrame.Link && !it.rawMode }
- tagged
Unmark path: frame is BlockFrame.SelfClosed, frame is BlockFrame.TaggedInline
- list handling:
parent is BlockFrame.ListItem, blockStack.lastOrNull() is BlockFrame.ListItem, (blockStack.last() as BlockFrame.ListItem), blockStack.lastOrNull() as? BlockFrame.List, blockStack.lastOrNull() is BlockFrame.Pre
- the
Unmark when (frame.name) casts: frame as BlockFrame.Frontmatter, (frame as BlockFrame.Paragraph).suppressClose, frame as BlockFrame.Inline, frame as BlockFrame.Link
"ul"/"ol" close: blockStack.lastOrNull() is BlockFrame.ListItem
Notes / caveats
- CSR applies to
is/as against the sealed type and inside a when whose subject is the sealed type. For a nullable receiver (blockStack.lastOrNull() as? BlockFrame.List) and bare as casts, confirm CSR resolves before mass-replacing — compile each target. CLAUDE.md notes CSR does not apply in some positions (supertype lists, generic constraints, type-annotation positions), so this is a per-site check, not a blind find/replace of BlockFrame..
- Construction sites (
addLast(BlockFrame.Inline(...)), BlockFrame.SelfClosed as a value, etc.) are not CSR positions and must stay qualified.
Scope
Pure refactor, no behavior change; verify by running :markanywhere-render:jvmTest. Kept out of #57 to avoid ballooning that PR's diff with churn in untouched code.
Summary
markanywhere-render/src/commonMain/kotlin/MarkdownRendering.ktapplies Kotlin context-sensitive resolution (CSR) inconsistently: somewhen/lambda sites over aBlockFramesubject drop theBlockFrame.prefix (e.g.is Pre,is Code,is Inline,is Frontmatter), while structurally identical sites still use the fully-qualifiedBlockFrame.X. Per CLAUDE.md ("Inside awhenwhose subject has a known sealed type … drop the type prefix … CSR also applies tois/asagainst that type"), these should be consistent. This is a style/readability cleanup, surfaced during review of #57 (which added several of the unqualified forms next to pre-existing qualified ones).Already unqualified (correct, the target style)
blockMarkerEscapingAllowed()—it is Pre || it is Code || it is Frontmatterit is Pre || it is CodeenclosingInlineDelimiterMask/inInlineCode—is Inline,is TaggedInline,is CodeinInlineCode()(wasblockStack.lastOrNull() is Code)Still fully-qualified (to normalize)
In
MarkdownRendering.kt(line numbers approximate, will drift):buildPrefixwhen(subjectBlockFrame):is BlockFrame.Blockquote,is BlockFrame.List,(next as? BlockFrame.ListItem)spillActiveLinks:frame !is BlockFrame.LinkblockStack.any { it is BlockFrame.Link && !it.rawMode }Unmarkpath:frame is BlockFrame.SelfClosed,frame is BlockFrame.TaggedInlineparent is BlockFrame.ListItem,blockStack.lastOrNull() is BlockFrame.ListItem,(blockStack.last() as BlockFrame.ListItem),blockStack.lastOrNull() as? BlockFrame.List,blockStack.lastOrNull() is BlockFrame.PreUnmarkwhen (frame.name)casts:frame as BlockFrame.Frontmatter,(frame as BlockFrame.Paragraph).suppressClose,frame as BlockFrame.Inline,frame as BlockFrame.Link"ul"/"ol"close:blockStack.lastOrNull() is BlockFrame.ListItemNotes / caveats
is/asagainst the sealed type and inside awhenwhose subject is the sealed type. For a nullable receiver (blockStack.lastOrNull() as? BlockFrame.List) and bareascasts, confirm CSR resolves before mass-replacing — compile each target. CLAUDE.md notes CSR does not apply in some positions (supertype lists, generic constraints, type-annotation positions), so this is a per-site check, not a blind find/replace ofBlockFrame..addLast(BlockFrame.Inline(...)),BlockFrame.SelfClosedas a value, etc.) are not CSR positions and must stay qualified.Scope
Pure refactor, no behavior change; verify by running
:markanywhere-render:jvmTest. Kept out of #57 to avoid ballooning that PR's diff with churn in untouched code.