fix
authorJb Evain <jbevain@gmail.com>
Sat, 4 Aug 2007 19:40:07 +0000 (19:40 -0000)
committerJb Evain <jbevain@gmail.com>
Sat, 4 Aug 2007 19:40:07 +0000 (19:40 -0000)
svn path=/trunk/mcs/; revision=83486

mcs/tools/tuner/Mono.Tuner/CheckVisibility.cs

index 01ec1c8772ef9c93334abb5edd4e54cbf65d5d8f..362c265a6df7d29938289447c315600fdb0c0b31 100644 (file)
@@ -126,10 +126,10 @@ namespace Mono.Tuner {
                        if (meth.IsPublic)
                                return true;
 
-                       if (meth.IsPrivate && meth.DeclaringType == dec)
+                       if (meth.IsPrivate && type == dec)
                                return true;
 
-                       if (meth.IsFamily && InHierarchy (dec, meth.DeclaringType))
+                       if (meth.IsFamily && InHierarchy (type, dec))
                                return true;
 
                        if (!AreInDifferentAssemblies (type, dec) && meth.IsAssembly)
@@ -158,10 +158,10 @@ namespace Mono.Tuner {
                        if (field.IsPublic)
                                return true;
 
-                       if (field.IsPrivate && field.DeclaringType == dec)
+                       if (field.IsPrivate && type == dec)
                                return true;
 
-                       if (field.IsFamily && InHierarchy (dec, field.DeclaringType))
+                       if (field.IsFamily && InHierarchy (type, dec))
                                return true;
 
                        if (!AreInDifferentAssemblies (type, dec) && field.IsAssembly)
@@ -170,13 +170,17 @@ namespace Mono.Tuner {
                        return false;
                }
 
-               bool InHierarchy (TypeDefinition declaration, TypeReference reference)
+               bool InHierarchy (TypeReference reference, TypeDefinition other)
                {
-                       TypeDefinition other = Context.Resolver.Resolve (reference);
-                       if (declaration == other)
+                       TypeDefinition type = Context.Resolver.Resolve (reference);
+
+                       if (type.BaseType == null)
+                               return false;
+       
+                       if (type.BaseType == other)
                                return true;
 
-                       return InHierarchy (declaration, other.BaseType);
+                       return InHierarchy (type.BaseType, other);
                }
 
                static void Report (string pattern, params object [] parameters)