Cache only resolved types not expression to report correct error location. Fixes...
[mono.git] / mcs / mcs / report.cs
index 26e3f4101c8764b9636b87d3e0c46200ea98433b..009007b0d529ca45d1cc0de85de61a5cb4f1dab8 100644 (file)
@@ -49,7 +49,7 @@ namespace Mono.CSharp {
                        809, 824,
                        1030, 1058, 1060, 1066,
                        1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592,
-                       1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1699,
+                       1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1697, 1699,
                        1700, 1701, 1702, 1709, 1711, 1717, 1718, 1720, 1735,
                        1901, 1956, 1981, 1998,
                        2002, 2023, 2029,
@@ -550,6 +550,8 @@ namespace Mono.CSharp {
        //
        public abstract class ReportPrinter
        {
+               protected HashSet<ITypeDefinition> reported_missing_definitions;
+
                #region Properties
 
                public int ErrorsCount { get; protected set; }
@@ -605,6 +607,22 @@ namespace Mono.CSharp {
                        }
                }
 
+               //
+               // Tracks reported missing types. It needs to be session specific 
+               // because we can run in probing mode
+               //
+               public bool MissingTypeReported (ITypeDefinition typeDefinition)
+               {
+                       if (reported_missing_definitions == null)
+                               reported_missing_definitions = new HashSet<ITypeDefinition> ();
+
+                       if (reported_missing_definitions.Contains (typeDefinition))
+                               return true;
+
+                       reported_missing_definitions.Add (typeDefinition);
+                       return false;
+               }
+
                public void Reset ()
                {
                        // HACK: Temporary hack for broken repl flow
@@ -649,7 +667,7 @@ namespace Mono.CSharp {
                        //
                        // This line is useful when debugging recorded messages
                        //
-                       // Console.WriteLine ("RECORDING: {0}", msg.ToString ());
+                       // Console.WriteLine ("RECORDING: {0}", msg.Text);
 
                        if (session_messages == null)
                                session_messages = new List<AbstractMessage> ();
@@ -735,6 +753,11 @@ namespace Mono.CSharp {
                                error_msg |= !msg.IsWarning;
                        }
 
+                       if (reported_missing_definitions != null) {
+                               foreach (var missing in reported_missing_definitions)
+                                       dest.MissingTypeReported (missing);
+                       }
+
                        return error_msg;
                }
        }
@@ -931,7 +954,7 @@ namespace Mono.CSharp {
                        if (timers == null)
                                return;
 
-                       Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> () {
+                       Dictionary<TimerType, string> timer_names = new Dictionary<TimerType,string> {
                                { TimerType.ParseTotal, "Parsing source files" },
                                { TimerType.AssemblyBuilderSetup, "Assembly builder setup" },
                                { TimerType.CreateTypeTotal, "Compiled types created" },
@@ -1030,7 +1053,7 @@ namespace Mono.CSharp {
 
                        public override bool IsEnabled (int code, bool previous)
                        {
-                               return this.code == code ? false : previous;
+                               return this.code != code && previous;
                        }
                }
 
@@ -1056,7 +1079,7 @@ namespace Mono.CSharp {
 
                        public override bool IsEnabled(int code, bool previous)
                        {
-                               return this.code == code ? true : previous;
+                               return this.code == code || previous;
                        }
                }