I have a type provider that gives me the error "Type mismatch when splicing an expression in literal quotation."
I extracted the code below to reproduce the problem in a smaller context.
let f (s : string) : string = s
let t = ProvidedTypeDefinition(asm, ns, "Root", Some typeof<obj>)
let ctor = ProvidedConstructor(parameters = [],
InvokeCode = (fun args -> <@@ "root" :> obj @@>)) :> MemberInfo
let prop = ProvidedProperty(propertyName = "SomeProperty",
parameters = [],
propertyType = typeof<string>,
GetterCode = (fun args -> <@@ f %%(args.[0]) @@>)) :> MemberInfo
do t.AddMembers [ctor; prop]
t.SetBaseType typeof<obj>
... and when I use a type provider like
let root = Provided.Root()
let a = root.SomeProperty
I get an error message:
Error: a provider of type 'typeproviders.providerpoc + MyProvider' reported an error in the context of the provided type 'typeproviders.providerpoc.Provided.Root', member of 'get_Menu'.
Error: the type of inconsistency when matching the expression in the quote is literal.
The type of the inserted expression tree does not match the type expected as a result of the splice operation.
Expected "System.Object", but got the type "System.String".
- , , (%% x: string) (% x: string).. : receivedType.
, ?
!