Skip to content

Commit fe2002b

Browse files
Alan GellerKevinRansom
authored andcommitted
Bug fix to allow RebuildShapeCombination for indexed static property gets (dotnet#2512)
* Bug fix to allow RebuildShapeCombination to rebuild gets of indexed static properties * Unit test for RebuildShapeCombination of indexed static property
1 parent 527d6de commit fe2002b

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/fsharp/FSharp.Core.Unittests/FSharp.Core/Microsoft.FSharp.Quotations/FSharpQuotations.fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ open Microsoft.FSharp.Quotations
1111

1212
type E = Microsoft.FSharp.Quotations.Expr;;
1313

14+
type StaticIndexedPropertyTest() =
15+
static member IdxProp with get (n : int) = n + 1
16+
1417
module Check =
1518
let argumentException f =
1619
let mutable ex = false
@@ -68,6 +71,17 @@ type FSharpQuotationsTests() =
6871
Check.argumentException(fun () -> ExprShape.RebuildShapeCombination(shape, [wrongValue;lambda]))
6972
| _ -> Assert.Fail()
7073

74+
[<Test>]
75+
member x.ReShapeStaticIndexedProperties() =
76+
let q0 = <@ StaticIndexedPropertyTest.IdxProp 5 @>
77+
match q0 with
78+
| ExprShape.ShapeCombination(shape, args) ->
79+
try
80+
ExprShape.RebuildShapeCombination(shape, args) |> ignore
81+
with
82+
| _ -> Assert.Fail()
83+
| _ -> Assert.Fail()
84+
7185
[<Test>]
7286
member x.GetConstructorFiltersOutStaticConstructor() =
7387
ignore <@ System.Exception() @>

src/fsharp/FSharp.Core/quotations.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ module ExprShape =
21712171
| NewTupleOp(ty),_ -> mkNewTupleWithType(ty, args)
21722172
| TupleGetOp(ty,i),[arg] -> mkTupleGet(ty,i,arg)
21732173
| InstancePropGetOp(pinfo),(obj::args) -> mkInstancePropGet(obj,pinfo,args)
2174-
| StaticPropGetOp(pinfo),[] -> mkStaticPropGet(pinfo,args)
2174+
| StaticPropGetOp(pinfo),_ -> mkStaticPropGet(pinfo,args)
21752175
| InstancePropSetOp(pinfo),obj::(FrontAndBack(args,v)) -> mkInstancePropSet(obj,pinfo,args,v)
21762176
| StaticPropSetOp(pinfo),(FrontAndBack(args,v)) -> mkStaticPropSet(pinfo,args,v)
21772177
| InstanceFieldGetOp(finfo),[obj] -> mkInstanceFieldGet(obj,finfo)

0 commit comments

Comments
 (0)