+ //
+ // A useful feature for the REPL: if we can resolve the expression
+ // as a type, Describe the type;
+ //
+ if (ec.Module.Evaluator.DescribeTypeExpressions){
+ var old_printer = ec.Report.SetPrinter (new SessionReportPrinter ());
+ Expression tclone;
+ try {
+ // Note: clone context cannot be shared otherwise block mapping would leak
+ tclone = source.Clone (new CloneContext ());
+ tclone = tclone.Resolve (ec, ResolveFlags.Type);
+ if (ec.Report.Errors > 0)
+ tclone = null;
+ } finally {
+ ec.Report.SetPrinter (old_printer);
+ }
+
+ if (tclone is TypeExpr) {
+ Arguments args = new Arguments (1);
+ args.Add (new Argument (new TypeOf ((TypeExpr) clone, Location)));
+ return new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec);
+ }
+ }
+