Permalink
Browse files

Fixes Issue 8717 - Private and Protected should be accessible from wi…

…thin

same module.
  • Loading branch information...
1 parent 2d83684 commit 1a97d3662e905620780c5253bf25f7c3b2d21621 @AndrejMitrovic AndrejMitrovic committed Jan 26, 2013
Showing with 65 additions and 1 deletion.
  1. +2 −1 src/access.c
  2. +63 −0 test/compilable/test8717.d
View
@@ -219,7 +219,8 @@ void AggregateDeclaration::accessCheck(Loc loc, Scope *sc, Dsymbol *smember)
result = access2 >= PROTpublic ||
hasPrivateAccess(f) ||
isFriendOf(cdscope) ||
- (access2 == PROTpackage && hasPackageAccess(sc, this));
+ (access2 == PROTpackage && hasPackageAccess(sc, this)) ||
+ getAccessModule() == sc->module;
#if LOG
printf("result1 = %d\n", result);
#endif
View
@@ -0,0 +1,63 @@
+module test8717;
+
+struct SPR
+{
+private:
+ enum e = 1;
+ immutable int ii = 1;
+ immutable static int sii = 1;
+ static int sf() { return 1; }
+ int f() const { return 1; }
+}
+
+static assert(SPR.e == 1);
+static assert(SPR.ii == 1);
+static assert(SPR.sii == 1);
+static assert(SPR.sf() == 1);
+static assert(SPR.init.e == 1);
+static assert(SPR.init.ii == 1);
+static assert(SPR.init.sii == 1);
+static assert(SPR.sf() == 1);
+static assert(SPR.init.f() == 1);
+
+static if(SPR.e != 1) { static assert(0); }
+static if(SPR.ii != 1) { static assert(0); }
+static if(SPR.sii != 1) { static assert(0); }
+static if(SPR.sf() != 1) { static assert(0); }
+static if(SPR.init.e != 1) { static assert(0); }
+static if(SPR.init.ii != 1) { static assert(0); }
+static if(SPR.init.sii != 1) { static assert(0); }
+static if(SPR.sf() != 1) { static assert(0); }
+static if(SPR.init.f() != 1) { static assert(0); }
+
+struct SPT
+{
+protected:
+ enum e = 1;
+ immutable int ii = 1;
+ immutable static int sii = 1;
+ static int sf() { return 1; }
+ int f() const { return 1; }
+}
+
+static assert(SPT.e == 1);
+static assert(SPT.ii == 1);
+static assert(SPT.sii == 1);
+static assert(SPT.sf() == 1);
+static assert(SPT.init.e == 1);
+static assert(SPT.init.ii == 1);
+static assert(SPT.init.sii == 1);
+static assert(SPT.sf() == 1);
+static assert(SPT.init.f() == 1);
+
+static if(SPT.e != 1) { static assert(0); }
+static if(SPT.ii != 1) { static assert(0); }
+static if(SPT.sii != 1) { static assert(0); }
+static if(SPT.sf() != 1) { static assert(0); }
+static if(SPT.init.e != 1) { static assert(0); }
+static if(SPT.init.ii != 1) { static assert(0); }
+static if(SPT.init.sii != 1) { static assert(0); }
+static if(SPT.sf() != 1) { static assert(0); }
+static if(SPT.init.f() != 1) { static assert(0); }
+
+void main() { }

0 comments on commit 1a97d36

Please sign in to comment.