Browse Source

Fixed lambda type inference when the lambda was used for an expression tree.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3014 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
7236ca06c0
  1. 9
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/TypeInference.cs

9
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CSharp/TypeInference.cs

@ -200,10 +200,17 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp @@ -200,10 +200,17 @@ namespace ICSharpCode.SharpDevelop.Dom.CSharp
if (rt == null)
return null;
IClass c = rt.GetUnderlyingClass();
if (allowExpressionTree && c != null && c.FullyQualifiedName == "System.Linq.Expressions.Expression") {
ConstructedReturnType crt = rt.CastToConstructedReturnType();
if (crt != null && crt.TypeArguments.Count == 1) {
// get delegate type from expression type
rt = crt.TypeArguments[0];
c = rt != null ? rt.GetUnderlyingClass() : null;
}
}
if (c != null && c.ClassType == ClassType.Delegate) {
return rt.GetMethods().FirstOrDefault((IMethod m) => m.Name == "Invoke");
}
// TODO: handle expression trees
return null;
}

Loading…
Cancel
Save