@@ -1763,16 +1763,23 @@ let TryDetectQueryQuoteAndRun cenv (expr:Expr) =
17631763| _ ->
17641764//printfn "Not eliminating because no Run found"
17651765 None
1766+
1767+ let IsILMethodRefDeclaringTypeSystemString ( ilg : ILGlobals ) ( mref : ILMethodRef ) =
1768+ mref.DeclaringTypeRef.Scope.IsAssemblyRef&&
1769+ mref.DeclaringTypeRef.Scope.AssemblyRef.Name= ilg.typ_ String.TypeRef.Scope.AssemblyRef.Name&&
1770+ mref.DeclaringTypeRef.BasicQualifiedName= ilg.typ_ String.BasicQualifiedName
17661771
1767- let IsSystemStringConcatOverload ( methRef : ILMethodRef ) =
1768- methRef.Name= " Concat" && methRef.DeclaringTypeRef.FullName= " System.String" &&
1769- methRef.ReturnType.BasicQualifiedName= " System.String" &&
1770- methRef.ArgTypes|> List.forall( fun ilty -> ilty.BasicQualifiedName= " System.String" )
1771-
1772- let IsSystemStringConcatArray ( methRef : ILMethodRef ) =
1773- methRef.Name= " Concat" && methRef.DeclaringTypeRef.FullName= " System.String" &&
1774- methRef.ReturnType.BasicQualifiedName= " System.String" &&
1775- methRef.ArgTypes.Length= 1 && methRef.ArgTypes.Head.BasicQualifiedName= " System.String[]"
1772+ let IsILMethodRefSystemStringConcatOverload ( ilg : ILGlobals ) ( mref : ILMethodRef ) =
1773+ IsILMethodRefDeclaringTypeSystemString ilg mref&&
1774+ mref.Name= " Concat" &&
1775+ mref.ReturnType.BasicQualifiedName= ilg.typ_ String.BasicQualifiedName&&
1776+ mref.ArgCount>= 2 && mref.ArgCount<= 4 && mref.ArgTypes|> List.forall( fun ilty -> ilty.BasicQualifiedName= ilg.typ_ String.BasicQualifiedName)
1777+
1778+ let IsILMethodRefSystemStringConcatArray ( ilg : ILGlobals ) ( mref : ILMethodRef ) =
1779+ IsILMethodRefDeclaringTypeSystemString ilg mref&&
1780+ mref.Name= " Concat" &&
1781+ mref.ReturnType.BasicQualifiedName= ilg.typ_ String.BasicQualifiedName&&
1782+ mref.ArgCount= 1 && mref.ArgTypes.Head.BasicQualifiedName= " System.String[]"
17761783
17771784//-------------------------------------------------------------------------
17781785// The traversal
@@ -1887,10 +1894,10 @@ and OptimizeInterfaceImpl cenv env baseValOpt (ty, overrides) =
18871894and MakeOptimizedSystemStringConcatCall cenv env m args =
18881895let rec optimizeArg e accArgs =
18891896match e, accArgswith
1890- | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, methRef , _, _, _), _, [ Expr.Op( TOp.Array, _, args, _) ], _), _ when IsSystemStringConcatArray methRef ->
1897+ | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, mref , _, _, _), _, [ Expr.Op( TOp.Array, _, args, _) ], _), _ when IsILMethodRefSystemStringConcatArray cenv.g.ilg mref ->
18911898 optimizeArgs args accArgs
18921899
1893- | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, methRef , _, _, _), _, args, _), _ when IsSystemStringConcatOverload methRef ->
1900+ | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, mref , _, _, _), _, args, _), _ when IsILMethodRefSystemStringConcatOverload cenv.g.ilg mref ->
18941901 optimizeArgs args accArgs
18951902
18961903// Optimize string constants, e.g. "1" + "2" will turn into "12"
@@ -1920,7 +1927,7 @@ and MakeOptimizedSystemStringConcatCall cenv env m args =
19201927 mkStaticCall_ String_ Concat_ Array cenv.g m arg
19211928
19221929match ewith
1923- | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, methRef , _, _, _) as op, tyargs, args, m) when IsSystemStringConcatOverload methRef || IsSystemStringConcatArray methRef ->
1930+ | Expr.Op( TOp.ILCall(_, _, _, _, _, _, _, mref , _, _, _) as op, tyargs, args, m) when IsILMethodRefSystemStringConcatOverload cenv.g.ilg mref || IsILMethodRefSystemStringConcatArray cenv.g.ilg mref ->
19241931 OptimizeExprOpReductions cenv env( op, tyargs, args, m)
19251932| _ ->
19261933 OptimizeExpr cenv env e
@@ -1993,9 +2000,9 @@ and OptimizeExprOp cenv env (op, tyargs, args, m) =
19932000| TOp.ILAsm([], [ ty]), _, [ a] when typeEquiv cenv.g( tyOfExpr cenv.g a) ty-> OptimizeExpr cenv env a
19942001
19952002// Optimize calls when concatenating strings, e.g. "1" + "2" + "3" + "4" .. etc.
1996- | TOp.ILCall(_, _, _, _, _, _, _, methRef , _, _, _), _, [ Expr.Op( TOp.Array, _, args, _) ] when IsSystemStringConcatArray methRef ->
2003+ | TOp.ILCall(_, _, _, _, _, _, _, mref , _, _, _), _, [ Expr.Op( TOp.Array, _, args, _) ] when IsILMethodRefSystemStringConcatArray cenv.g.ilg mref ->
19972004 MakeOptimizedSystemStringConcatCall cenv env m args
1998- | TOp.ILCall(_, _, _, _, _, _, _, methRef , _, _, _), _, argswhen IsSystemStringConcatOverload methRef ->
2005+ | TOp.ILCall(_, _, _, _, _, _, _, mref , _, _, _), _, argswhen IsILMethodRefSystemStringConcatOverload cenv.g.ilg mref ->
19992006 MakeOptimizedSystemStringConcatCall cenv env m args
20002007
20012008| _ ->