// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.Resolver
{
///
/// Represents an anonymous method or lambda expression.
/// Note: the lambda has no type.
/// To retrieve the delegate type, look at the anonymous function conversion.
///
public abstract class LambdaResolveResult : ResolveResult
{
protected LambdaResolveResult() : base(SpecialType.UnknownType)
{
}
///
/// Gets whether there is a parameter list.
/// This property always returns true for C# 3.0-lambdas, but may return false
/// for C# 2.0 anonymous methods.
///
public abstract bool HasParameterList { get; }
///
/// Gets whether this lambda is using the C# 2.0 anonymous method syntax.
///
public abstract bool IsAnonymousMethod { get; }
///
/// Gets whether the lambda parameters are implicitly typed.
///
/// This property returns false for anonymous methods without parameter list.
public abstract bool IsImplicitlyTyped { get; }
///
/// Gets whether the lambda is async.
///
public abstract bool IsAsync { get; }
///
/// Gets the return type inferred when the parameter types are inferred to be
///
///
/// This method determines the return type inferred from the lambda body, which is used as part of C# type inference.
/// Use the property to retrieve the actual return type as determined by the target delegate type.
///
public abstract IType GetInferredReturnType(IType[] parameterTypes);
///
/// Gets the list of parameters.
///
public abstract IList Parameters { get; }
///
/// Gets the return type of the lambda.
///
/// If the lambda is async, the return type includes Task<T>
///
public abstract IType ReturnType { get; }
///
/// Gets whether the lambda body is valid for the given parameter types and return type.
///
///
/// Produces a conversion with =true if the lambda is valid;
/// otherwise returns .
///
public abstract Conversion IsValid(IType[] parameterTypes, IType returnType, CSharpConversions conversions);
///
/// Gets the resolve result for the lambda body.
/// Returns a resolve result for 'void' for statement lambdas.
///
public abstract ResolveResult Body { get; }
public override IEnumerable GetChildResults()
{
return new [] { this.Body };
}
}
}