提交 dc8a26e6 编写于 作者: S Steffen Forkmann 提交者: GitHub

Merge pull request #23 from vasily-kirichenko/better-indexer-detection

Better indexer detection
...@@ -8222,24 +8222,27 @@ and Propagate cenv overallTy env tpenv (expr: ApplicableExpr) exprty delayed = ...@@ -8222,24 +8222,27 @@ and Propagate cenv overallTy env tpenv (expr: ApplicableExpr) exprty delayed =
let mArg = arg.Range let mArg = arg.Range
match arg with match arg with
| SynExpr.CompExpr _ -> () | SynExpr.CompExpr _ -> ()
| _ -> | SynExpr.ArrayOrListOfSeqExpr _ ->
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body // 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
let flag =
match expr.Expr with match expr.Expr with
| Expr.Val (d,_,_) when | Expr.Val (d,_,_)
| Expr.App(Expr.Val (d,_,_),_,_,_,_) ->
let typ = d.Type let typ = d.Type
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary typ ||
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IDictionary typ ||
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_List typ ||
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IList typ ||
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IReadOnlyList typ ||
HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_ICollection typ ||
isArray1DTy cenv.g typ || isArray1DTy cenv.g typ ||
isListTy cenv.g typ if isAppTy cenv.g typ then
-> let tcref = tcrefOfAppTy cenv.g typ
error (NotAFunction(denv,overallTy,true,mExpr,mArg)) let _, entityTy = generalizeTyconRef tcref
| _ -> error (NotAFunction(denv,overallTy,false,mExpr,mArg)) let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) cenv.g cenv.amap range0 entityTy
props |> List.exists (fun x -> x.PropertyName = "Item")
else false
| _ -> false
error (NotAFunction(denv,overallTy,flag,mExpr,mArg))
| _ ->
error (NotAFunction(denv,overallTy,false,mExpr,mArg))
propagate delayed expr.Range exprty propagate delayed expr.Range exprty
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册