--- /dev/null
+// CS4012: Parameters or local variables of type `System.TypedReference' cannot be declared in async methods or iterators
+// Line: 9
+
+using System;
+using System.Collections;
+
+class C
+{
+ public IEnumerable Iter ()
+ {
+ int i = 2;
+ TypedReference tr = __makeref (i);
+ yield return 1;
+ }
+}
--- /dev/null
+// CS4012: Parameters or local variables of type `System.TypedReference' cannot be declared in async methods or iterators
+// Line: 11
+// Compiler options: -langversion:future
+
+using System;
+using System.Collections;
+using System.Threading.Tasks;
+
+class C
+{
+ public async void Test ()
+ {
+ int i = 2;
+ TypedReference tr = __makeref (i);
+ await Task.Factory.StartNew (() => 6);
+ }
+}
--- /dev/null
+// CS1913: Local variables of type `System.TypedReference' cannot be used inside anonymous methods, lambda expressions or query expressions
+// Line: 9
+
+using System;
+
+class C
+{
+ public static void Main ()
+ {
+ int i = 1;
+ TypedReference tr = __makeref (i);
+ {
+ Action a = () => { TypedReference tr2 = tr; };
+ }
+ }
+}
+
}
}
- protected bool IsTypePermitted ()
+ protected void IsTypePermitted ()
{
if (MemberType.IsSpecialRuntimeType) {
- Report.Error (610, Location, "Field or property cannot be of type `{0}'", TypeManager.CSharpName (MemberType));
- return false;
+ if (Parent is StateMachine) {
+ Report.Error (4012, Location,
+ "Parameters or local variables of type `{0}' cannot be declared in async methods or iterators",
+ MemberType.GetSignatureForError ());
+ } else if (Parent is HoistedStoreyClass) {
+ Report.Error (4013, Location,
+ "Local variables of type `{0}' cannot be used inside anonymous methods, lambda expressions or query expressions",
+ MemberType.GetSignatureForError ());
+ } else {
+ Report.Error (610, Location,
+ "Field or property cannot be of type `{0}'", MemberType.GetSignatureForError ());
+ }
}
- return true;
}
protected virtual bool CheckBase ()