Imported Upstream version 4.6.0.150

Former-commit-id: 73e3bb1e96dd09dc931c1dfe559d2c7f7b8b02c7
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-23 13:20:38 +00:00
parent 02ac915603
commit b95516a3dd
239 changed files with 4096 additions and 1544 deletions

View File

@@ -20,6 +20,7 @@ using System.Security.Cryptography;
using System.Security.Permissions;
using Mono.Security.Cryptography;
using Mono.CompilerServices.SymbolWriter;
using System.Linq;
#if STATIC
using IKVM.Reflection;
@@ -43,6 +44,20 @@ namespace Mono.CSharp
byte[] GetPublicKeyToken ();
bool IsFriendAssemblyTo (IAssemblyDefinition assembly);
}
public class AssemblyReferenceErrorInfo
{
public AssemblyReferenceErrorInfo (AssemblyName dependencyName, string location, string message)
{
this.DependencyName = dependencyName;
this.RequestingAssemblyLocation = location;
this.Message = message;
}
public AssemblyName DependencyName { get; private set; }
public string RequestingAssemblyLocation { get; private set; }
public string Message { get; private set; }
}
public abstract class AssemblyDefinition : IAssemblyDefinition
{
@@ -416,7 +431,8 @@ namespace Mono.CSharp
//
void CheckReferencesPublicToken ()
{
foreach (var an in builder_extra.GetReferencedAssemblies ()) {
var references = builder_extra.GetReferencedAssemblies ();
foreach (var an in references) {
if (public_key != null && an.GetPublicKey ().Length == 0) {
Report.Error (1577, "Referenced assembly `{0}' does not have a strong name",
an.FullName);
@@ -432,11 +448,17 @@ namespace Mono.CSharp
if (ia == null)
continue;
var references = GetNotUnifiedReferences (an);
if (references != null) {
foreach (var r in references) {
Report.SymbolRelatedToPreviousError ( r[0]);
Report.Error (1705, r [1]);
var an_references = GetNotUnifiedReferences (an);
if (an_references != null) {
foreach (var r in an_references) {
//
// Secondary check when assembly references is resolved but not used. For example
// due to type-forwarding
//
if (references.Any (l => l.Name == r.DependencyName.Name)) {
Report.SymbolRelatedToPreviousError (r.RequestingAssemblyLocation);
Report.Error (1705, r.Message);
}
}
}
@@ -570,7 +592,7 @@ namespace Mono.CSharp
return public_key_token;
}
protected virtual List<string[]> GetNotUnifiedReferences (AssemblyName assemblyName)
protected virtual List<AssemblyReferenceErrorInfo> GetNotUnifiedReferences (AssemblyName assemblyName)
{
return null;
}

View File

@@ -973,14 +973,17 @@ namespace Mono.CSharp
public StackFieldExpr (Field field)
: base (field, Location.Null)
{
AutomaticallyReuse = true;
}
public bool AutomaticallyReuse { get; set; }
public bool IsAvailableForReuse {
get {
var field = (Field) spec.MemberDefinition;
return field.IsAvailableForReuse;
}
set {
private set {
var field = (Field) spec.MemberDefinition;
field.IsAvailableForReuse = value;
}
@@ -990,7 +993,7 @@ namespace Mono.CSharp
{
base.AddressOf (ec, mode);
if (mode == AddressOp.Load) {
if (mode == AddressOp.Load && AutomaticallyReuse) {
IsAvailableForReuse = true;
}
}
@@ -999,7 +1002,8 @@ namespace Mono.CSharp
{
base.Emit (ec);
PrepareCleanup (ec);
if (AutomaticallyReuse)
PrepareCleanup (ec);
}
public void EmitLoad (EmitContext ec)

View File

@@ -1 +1 @@
8b331dd7c778f49c22197b98267d5bc59cd1200c
0f7ea925d9e3382fab323c3950fb1a16c48a47b5

View File

@@ -290,7 +290,7 @@ namespace Mono.CSharp
TypeExpr texpr = left as TypeExpr;
if (texpr != null) {
var found = MemberCache.FindNestedType (texpr.Type, mn.Name, mn.Arity);
var found = MemberCache.FindNestedType (texpr.Type, mn.Name, mn.Arity, false);
if (found != null)
return new TypeExpression (found, Location.Null);

View File

@@ -1 +1 @@
4386f93115a197fe081f0e882270c59d29b42df2
020166ddf94f9f86b0a2c64c968df999e14695e3

View File

@@ -1 +1 @@
f805523b76e0a16f41bd3320409ad98aba4cab8e
02ae36b34c16802d921a2476f4a1ab3d750052c3

View File

@@ -1551,7 +1551,7 @@ namespace Mono.CSharp {
// Parent was inflated, find the same type on inflated type
// to use same cache for nested types on same generic parent
//
type = MemberCache.FindNestedType (parent, type.Name, type.Arity);
type = MemberCache.FindNestedType (parent, type.Name, type.Arity, false);
//
// Handle the tricky case where parent shares local type arguments

View File

@@ -220,7 +220,7 @@ namespace Mono.CSharp
return Builder.__AddModule (moduleFile);
}
protected override List<string[]> GetNotUnifiedReferences (AssemblyName assemblyName)
protected override List<AssemblyReferenceErrorInfo> GetNotUnifiedReferences (AssemblyName assemblyName)
{
return loader.GetNotUnifiedReferences (assemblyName);
}
@@ -238,7 +238,7 @@ namespace Mono.CSharp
Assembly corlib;
readonly List<Tuple<AssemblyName, string, Assembly>> loaded_names;
static readonly Dictionary<string, string[]> sdk_directory;
Dictionary<AssemblyName, List<string[]>> resolved_version_mismatches;
Dictionary<AssemblyName, List<AssemblyReferenceErrorInfo>> resolved_version_mismatches;
static StaticLoader ()
{
@@ -358,25 +358,24 @@ namespace Mono.CSharp
if (version_mismatch is AssemblyBuilder)
return version_mismatch;
var v1 = new AssemblyName (refname).Version;
var ref_an = new AssemblyName (refname);
var v1 = ref_an.Version;
var v2 = version_mismatch.GetName ().Version;
if (v1 > v2) {
if (resolved_version_mismatches == null)
resolved_version_mismatches = new Dictionary<AssemblyName, List<string[]>> ();
resolved_version_mismatches = new Dictionary<AssemblyName, List<AssemblyReferenceErrorInfo>> ();
var an = args.RequestingAssembly.GetName ();
List<string[]> names;
List<AssemblyReferenceErrorInfo> names;
if (!resolved_version_mismatches.TryGetValue (an, out names)) {
names = new List<string[]> ();
names = new List<AssemblyReferenceErrorInfo> ();
resolved_version_mismatches.Add (an, names);
}
names.Add (new[] {
args.RequestingAssembly.Location,
names.Add (new AssemblyReferenceErrorInfo (ref_an, args.RequestingAssembly.Location,
string.Format ("Assembly `{0}' depends on `{1}' which has a higher version number than referenced assembly `{2}'",
args.RequestingAssembly.FullName, refname, version_mismatch.GetName ().FullName)
});
args.RequestingAssembly.FullName, refname, version_mismatch.GetName ().FullName)));
return version_mismatch;
}
@@ -433,9 +432,9 @@ namespace Mono.CSharp
return default_references.ToArray ();
}
public List<string[]> GetNotUnifiedReferences (AssemblyName assemblyName)
public List<AssemblyReferenceErrorInfo> GetNotUnifiedReferences (AssemblyName assemblyName)
{
List<string[]> list = null;
List<AssemblyReferenceErrorInfo> list = null;
if (resolved_version_mismatches != null)
resolved_version_mismatches.TryGetValue (assemblyName, out list);

View File

@@ -814,7 +814,7 @@ namespace Mono.CSharp
if (t.Kind == MemberKind.MissingType)
spec = t;
else
spec = MemberCache.FindNestedType (spec, t.Name, t.Arity);
spec = MemberCache.FindNestedType (spec, t.Name, t.Arity, false);
if (t.Arity > 0) {
spec = spec.MakeGenericType (module, targs.Skip (targs_pos).Take (spec.Arity).ToArray ());
@@ -834,7 +834,7 @@ namespace Mono.CSharp
if (index > 0)
name = name.Substring (0, index);
spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos);
spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos, false);
if (spec.Arity > 0) {
spec = spec.MakeGenericType (module, targs.Skip (targs_pos).ToArray ());

View File

@@ -465,7 +465,7 @@ namespace Mono.CSharp {
//
// Finds the nested type in container
//
public static TypeSpec FindNestedType (TypeSpec container, string name, int arity)
public static TypeSpec FindNestedType (TypeSpec container, string name, int arity, bool declaredOnlyClass)
{
IList<MemberSpec> applicable;
TypeSpec best_match = null;
@@ -494,7 +494,7 @@ namespace Mono.CSharp {
if (arity < 0) {
if (best_match == null) {
best_match = ts;
} else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (ts.Arity + arity)) {
} else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (best_match.Arity + arity)) {
best_match = ts;
}
}
@@ -502,7 +502,7 @@ namespace Mono.CSharp {
}
container = container.BaseType;
} while (container != null);
} while (container != null && !declaredOnlyClass);
return best_match;
}

View File

@@ -1159,38 +1159,18 @@ namespace Mono.CSharp {
if (types_using_table != null) {
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);
}
}
}

View File

@@ -1 +1 @@
703e7ba497fef805446a5df389a8fa4f81258816
ad08d02b5db754d3948bdb8ad9c4b690011c1aff