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
18 changes: 18 additions & 0 deletions src/Fable.Transforms/FSharp2Fable.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ type Context =
InlinePath: Log.InlinePath list
CaptureBaseConsCall: (FSharpEntity * (Fable.Expr -> unit)) option
Witnesses: Fable.Witness list
// True while translating a quotation body (<@ @>): member calls are kept as-is,
// not replaced/emitted/inlined, to preserve .NET metadata for QuotationEmitter.
CapturingQuotation: bool
}

static member Create(?usedRootNames) =
Expand All @@ -555,6 +558,7 @@ type Context =
InlinePath = []
CaptureBaseConsCall = None
Witnesses = []
CapturingQuotation = false
}

type IFableCompiler =
Expand Down Expand Up @@ -3058,6 +3062,20 @@ module Util =
(callInfo: Fable.CallInfo)
=
match memb, memb.DeclaringEntity with
// Inside a quotation, keep the original member call as-is (skip replace/emit/import/inline)
// so QuotationEmitter gets the real .NET metadata. Tag plain property getters so
// QuotationEmitter can represent them as PropertyGet instead of a method Call.
| _ when ctx.CapturingQuotation ->
let membTyp = makeType ctx.GenericArgs memb.FullType

let callInfo =
if memb.IsPropertyGetterMethod && countNonCurriedParams memb = 0 then
{ callInfo with Tags = "property" :: callInfo.Tags }
else
callInfo

memberIdent com r membTyp memb membRef |> makeCall r typ callInfo

| Emitted com ctx r typ (Some callInfo) emitted, _ -> emitted
| Imported com ctx r typ (Some callInfo) imported -> imported
| Replaced com ctx r typ callInfo replaced -> replaced
Expand Down
3 changes: 2 additions & 1 deletion src/Fable.Transforms/FSharp2Fable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,8 @@ let private transformExpr (com: IFableCompiler) (ctx: Context) appliedGenArgs fs
|> addErrorAndReturnNull com ctx.InlinePath (makeRangeFrom fsExpr)

| FSharpExprPatterns.Quote quotedExpr ->
let! body = transformExpr com ctx [] quotedExpr
// Capturing mode: member calls keep their .NET metadata instead of being replaced/emitted/inlined.
let! body = transformExpr com { ctx with CapturingQuotation = true } [] quotedExpr
let exprType = fsExpr.Type
let isTyped = exprType.GenericArguments.Count > 0
return Fable.Quote(body, isTyped, makeRangeFrom fsExpr)
Expand Down
Loading
Loading