Skip to content

Commit

Permalink
fix quotation of readonly fields
Browse files Browse the repository at this point in the history
fixes #514
closes #622
  • Loading branch information
enricosada authored and latkin committed Sep 8, 2015
1 parent 751f0b7 commit a2d2990
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fsharp/QuotationTranslator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
QP.mkTupleGet(tyR, n, ConvExpr cenv env e)

| TOp.ILAsm(([ I_ldfld(_,_,fspec) ]
| [ I_ldfld(_,_,fspec); AI_nop ]
| [ I_ldsfld (_,fspec) ]
| [ I_ldsfld (_,fspec); AI_nop ]),_),enclTypeArgs,args ->
ConvLdfld cenv env m fspec enclTypeArgs args
Expand Down
7 changes: 7 additions & 0 deletions tests/fsharp/core/quotes/cslib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
public struct S {
public int x;
}

public class Class1
{
public string myField;
public readonly string myReadonlyField;
public Class1(string v) { this.myReadonlyField = v; }
}
8 changes: 8 additions & 0 deletions tests/fsharp/core/quotes/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ module TypedTest = begin
| _ -> false
end

test "check accesses to readonly fields in ReflectedDefinitions"
begin
let c1 = Class1("a")
match <@ c1.myReadonlyField @> with
| FieldGet(Some (ValueWithName (_, v, "c1")), field) -> (v.Name = "Class1") && (field.Name = "myReadonlyField")
| _ -> false
end

end

(*
Expand Down

0 comments on commit a2d2990

Please sign in to comment.