return false;
}
- Type ignored_type;
- bool ignored_is_enumerable;
-
- if (ec.IsConstructor){
- Report.Error (1624, loc, "Can not use iterators inside constructors");
- return false;
- }
-
- if (!Iterator.CheckType (ec.ReturnType, out ignored_type, out ignored_is_enumerable)){
- Report.Error (1624, loc,
- "Can not use iterator block because `{0}' is not an iterator interface type",
- TypeManager.CSharpName (ec.ReturnType));
- return false;
- }
-
//
// We can't use `ec.InUnsafe' here because it's allowed to have an iterator
// inside an unsafe class. See test-martin-29.cs for an example.
//
- if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.IsIterator == false) {
+ if (!ec.CurrentAnonymousMethod.IsIterator) {
Report.Error (1621, loc,
"The yield statement cannot be used inside " +
"anonymous method blocks");
point.Define (ig);
}
+ public override string ContainerType {
+ get { return "iterator"; }
+ }
+
public override bool IsIterator {
get { return true; }
}
//
private Iterator (IMethodData m_container, DeclSpace host, GenericMethod generic,
int modifiers, Type iterator_type, bool is_enumerable)
- : base (null, host, generic, m_container.ParameterInfo,
+ : base (host, generic, m_container.ParameterInfo,
new ToplevelBlock (m_container.ParameterInfo, m_container.Location),
m_container.Block, TypeManager.bool_type, modifiers,
m_container.Location)
return OriginalMethod.GetSignatureForError ();
}
- public override bool Resolve (EmitContext ec)
+ public override bool Define (EmitContext ec)
{
Report.Debug (64, "RESOLVE ITERATOR", this, Container, Block);
return false;
}
- if (!base.Resolve (ec))
+ if (!base.Define (ec))
return false;
Report.Debug (64, "RESOLVE ITERATOR #1", this, method, method.Parent,
Parameters.EmptyReadOnlyParameters);
}
+ public override Expression Resolve (EmitContext ec)
+ {
+ throw new NotSupportedException ();
+ }
+
protected class MoveNextStatement : Statement {
Iterator iterator;
iterator_type, is_enumerable);
}
- internal static bool CheckType (Type ret, out Type original_iterator_type, out bool is_enumerable)
+ static bool CheckType (Type ret, out Type original_iterator_type, out bool is_enumerable)
{
original_iterator_type = null;
is_enumerable = false;