Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Kumpera <kumpera@gmail.com>2016-07-04 22:46:33 +0300
committerGitHub <noreply@github.com>2016-07-04 22:46:33 +0300
commit11e7e443997ff616493baf850306686c26cc0542 (patch)
tree9084cb7cd62e12647cc6880e661cf62cd071edee
parentf66524ab9cdbbfe92aaee490dc128de958399b69 (diff)
parente56d29f7a32061cd239b9705a0dbf8914bfa4c39 (diff)
Merge pull request #2958 from kumpera/visibility
Fix a visibility check bug
-rw-r--r--mcs/class/corlib/Test/System/DelegateTest.cs2
-rw-r--r--mono/metadata/class.c30
2 files changed, 11 insertions, 21 deletions
diff --git a/mcs/class/corlib/Test/System/DelegateTest.cs b/mcs/class/corlib/Test/System/DelegateTest.cs
index ae5a82908c8..e1d95dc93f0 100644
--- a/mcs/class/corlib/Test/System/DelegateTest.cs
+++ b/mcs/class/corlib/Test/System/DelegateTest.cs
@@ -1251,7 +1251,7 @@ namespace MonoTests.System
}
}
- delegate int IntNoArgs ();
+ public delegate int IntNoArgs ();
[Test]
public void CreateDelegateWithAbstractMethods ()
diff --git a/mono/metadata/class.c b/mono/metadata/class.c
index 39fc6e491df..6f61c9b27b8 100644
--- a/mono/metadata/class.c
+++ b/mono/metadata/class.c
@@ -10209,6 +10209,9 @@ can_access_type (MonoClass *access_klass, MonoClass *member_klass)
{
int access_level;
+ if (access_klass == member_klass)
+ return TRUE;
+
if (access_klass->image->assembly && access_klass->image->assembly->corlib_internal)
return TRUE;
@@ -10357,26 +10360,9 @@ mono_method_can_access_field (MonoMethod *method, MonoClassField *field)
gboolean
mono_method_can_access_method (MonoMethod *method, MonoMethod *called)
{
- int can = can_access_member (method->klass, called->klass, NULL, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
- if (!can) {
- MonoClass *nested = method->klass->nested_in;
- while (nested) {
- can = can_access_member (nested, called->klass, NULL, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);
- if (can)
- return TRUE;
- nested = nested->nested_in;
- }
- }
- /*
- * FIXME:
- * with generics calls to explicit interface implementations can be expressed
- * directly: the method is private, but we must allow it. This may be opening
- * a hole or the generics code should handle this differently.
- * Maybe just ensure the interface type is public.
- */
- if ((called->flags & METHOD_ATTRIBUTE_VIRTUAL) && (called->flags & METHOD_ATTRIBUTE_FINAL))
- return TRUE;
- return can;
+ method = mono_method_get_method_definition (method);
+ called = mono_method_get_method_definition (called);
+ return mono_method_can_access_method_full (method, called, NULL);
}
/*
@@ -10393,6 +10379,10 @@ mono_method_can_access_method (MonoMethod *method, MonoMethod *called)
gboolean
mono_method_can_access_method_full (MonoMethod *method, MonoMethod *called, MonoClass *context_klass)
{
+ /* Wrappers are except from access checks */
+ if (method->wrapper_type != MONO_WRAPPER_NONE || called->wrapper_type != MONO_WRAPPER_NONE)
+ return TRUE;
+
MonoClass *access_class = method->klass;
MonoClass *member_class = called->klass;
int can = can_access_member (access_class, member_class, context_klass, called->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK);