[mcs] C# 7 tuple (foundation only).
[mono.git] / mcs / mcs / namespace.cs
index 2639d046d1bfe1c8ce36790aab6a936847098688..3314ca2d48c24d8341e6c44faf7523343d0fc182 100644 (file)
@@ -624,8 +624,8 @@ namespace Mono.CSharp {
                        if (include_files == null)
                                include_files = new Dictionary<string, SourceFile> ();
 
-                       if (!include_files.ContainsKey (file.FullPathName))
-                               include_files.Add (file.FullPathName, file);
+                       if (!include_files.ContainsKey (file.OriginalFullPathName))
+                               include_files.Add (file.OriginalFullPathName, file);
                }
 
                public void AddDefine (string value)
@@ -648,7 +648,7 @@ namespace Mono.CSharp {
                {
                        var sw = Module.DeclaringAssembly.SymbolWriter;
                        if (sw != null) {
-                               CreateUnitSymbolInfo (sw);
+                               CreateUnitSymbolInfo (sw, Compiler.Settings.PathMap);
                        }
 
                        base.PrepareEmit ();
@@ -657,14 +657,14 @@ namespace Mono.CSharp {
                //
                // Creates symbol file index in debug symbol file
                //
-               void CreateUnitSymbolInfo (MonoSymbolFile symwriter)
+               void CreateUnitSymbolInfo (MonoSymbolFile symwriter, List<KeyValuePair<string, string>> pathMap)
                {
-                       var si = file.CreateSymbolInfo (symwriter);
+                       var si = file.CreateSymbolInfo (symwriter, pathMap);
                        comp_unit = new CompileUnitEntry (symwriter, si);
 
                        if (include_files != null) {
                                foreach (SourceFile include in include_files.Values) {
-                                       si = include.CreateSymbolInfo (symwriter);
+                                       si = include.CreateSymbolInfo (symwriter, pathMap);
                                        comp_unit.AddFile (si);
                                }
                        }
@@ -1157,40 +1157,20 @@ namespace Mono.CSharp {
                                        match = texpr_fne;
                        }
 
-                       if (types_using_table != null) {
+                       if (types_using_table != null && (mode & LookupMode.IgnoreStaticUsing) == 0) {
                                foreach (var using_type in types_using_table) {
-                                       var members = MemberCache.FindMembers (using_type, name, true);
-                                       if (members == null)
+                                       var type = MemberCache.FindNestedType (using_type, name, arity, true);
+                                       if (type == null)
                                                continue;
+                                       
+                                       fne = new TypeExpression (type, loc);
+                                       if (match == null) {
+                                               match = fne;
+                                               continue;
+                                       }
 
-                                       foreach (var member in members) {
-                                               if (arity > 0 && member.Arity != arity)
-                                                       continue;
-                                               
-                                               if ((member.Kind & MemberKind.NestedMask) != 0) {
-                                                       // non-static nested type is included with using static
-                                               } else {
-                                                       if ((member.Modifiers & Modifiers.STATIC) == 0)
-                                                               continue;
-
-                                                       if ((member.Modifiers & Modifiers.METHOD_EXTENSION) != 0)
-                                                               continue;
-
-                                                       if (mode == LookupMode.Normal)
-                                                               continue;
-                                                       
-                                                       return null;
-                                               }
-
-                                               fne = new TypeExpression ((TypeSpec) member, loc);
-                                               if (match == null) {
-                                                       match = fne;
-                                                       continue;
-                                               }
-
-                                               if (mode == LookupMode.Normal) {
-                                                       Error_AmbiguousReference (name, match, fne, loc);
-                                               }
+                                       if (mode == LookupMode.Normal) {
+                                               Error_AmbiguousReference (name, match, fne, loc);
                                        }
                                }
                        }
@@ -1296,16 +1276,20 @@ namespace Mono.CSharp {
                                                continue;
                                        }
 
-                                       entry.Define (this);
+                                       try {
+                                               entry.Define (this);
+                                       } finally {
+                                               //
+                                               // It's needed for repl only, when using clause cannot be resolved don't hold it in
+                                               // global list which is resolved for every evaluation
+                                               //
+                                               if (entry.ResolvedExpression == null) {
+                                                       clauses.RemoveAt (i--);
+                                               }
+                                       }
 
-                                       //
-                                       // It's needed for repl only, when using clause cannot be resolved don't hold it in
-                                       // global list which is resolved for each evaluation
-                                       //
-                                       if (entry.ResolvedExpression == null) {
-                                               clauses.RemoveAt (i--);
+                                       if (entry.ResolvedExpression == null)
                                                continue;
-                                       }
 
                                        var using_ns = entry.ResolvedExpression as NamespaceExpression;
                                        if (using_ns == null) {
@@ -1343,7 +1327,7 @@ namespace Mono.CSharp {
                                        for (int i = 0; i < clauses.Count; ++i) {
                                                var entry = clauses[i];
                                                if (entry.Alias != null) {
-                                                       aliases.Add (entry.Alias.Value, (UsingAliasNamespace) entry);
+                                                       aliases[entry.Alias.Value] = (UsingAliasNamespace) entry;
                                                }
                                        }
                                }
@@ -1439,6 +1423,7 @@ namespace Mono.CSharp {
                        if (resolved != null) {
                                var compiler = ctx.Module.Compiler;
                                var type = resolved.Type;
+                               resolved = null;
 
                                compiler.Report.SymbolRelatedToPreviousError (type);
                                compiler.Report.Error (138, Location,