Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateTryAndCatchHaveSameType()

static void System.Linq.Expressions.Expression< TDelegate >.ValidateTryAndCatchHaveSameType ( Type type,
Expression< TDelegate > tryBody,
ReadOnlyCollection< CatchBlock > handlers )
inlinestaticprivateinherited

Definition at line 4922 of file Expression.cs.

4923 {
4924 if (type != null)
4925 {
4926 if (!(type != typeof(void)))
4927 {
4928 return;
4929 }
4931 {
4932 throw Error.ArgumentTypesMustMatch();
4933 }
4934 {
4935 foreach (CatchBlock handler in handlers)
4936 {
4937 if (!TypeUtils.AreReferenceAssignable(type, handler.Body.Type))
4938 {
4939 throw Error.ArgumentTypesMustMatch();
4940 }
4941 }
4942 return;
4943 }
4944 }
4945 if (tryBody.Type == typeof(void))
4946 {
4947 foreach (CatchBlock handler2 in handlers)
4948 {
4949 if (handler2.Body.Type != typeof(void))
4950 {
4951 throw Error.BodyOfCatchMustHaveSameTypeAsBodyOfTry();
4952 }
4953 }
4954 return;
4955 }
4956 type = tryBody.Type;
4957 foreach (CatchBlock handler3 in handlers)
4958 {
4959 if (!TypeUtils.AreEquivalent(handler3.Body.Type, type))
4960 {
4961 throw Error.BodyOfCatchMustHaveSameTypeAsBodyOfTry();
4962 }
4963 }
4964 }
static bool AreEquivalent(Type t1, Type t2)
Definition TypeUtils.cs:664
static bool AreReferenceAssignable(Type dest, Type src)
Definition TypeUtils.cs:673

References System.Dynamic.Utils.TypeUtils.AreEquivalent(), System.Dynamic.Utils.TypeUtils.AreReferenceAssignable(), System.Linq.Expressions.Error.ArgumentTypesMustMatch(), System.Linq.Expressions.CatchBlock.Body, System.Linq.Expressions.Error.BodyOfCatchMustHaveSameTypeAsBodyOfTry(), System.Linq.Expressions.Expression< TDelegate >.Type, and System.type.

Referenced by System.Linq.Expressions.Expression< TDelegate >.MakeTry().