summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-07-06 12:06:44 +0000
committerMartin Odersky <odersky@gmail.com>2011-07-06 12:06:44 +0000
commit321439e32f89af71ec5d663337cbe379c306c422 (patch)
treeed4dbeedcb94c772dbabf0fe6b28c67a631c601e /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent2c28fc4afa6471fa4059fea674043081ab796423 (diff)
downloadscala-321439e32f89af71ec5d663337cbe379c306c422.tar.gz
scala-321439e32f89af71ec5d663337cbe379c306c422.tar.bz2
scala-321439e32f89af71ec5d663337cbe379c306c422.zip
Changes semantics so that protected access rule...
Changes semantics so that protected access rule (selector must be subclass of current class) does not hold for type members. Fixes t4737. Review by extempore. Spec change in a seperate commit.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 3774411d51..8e22da83b0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -455,17 +455,20 @@ trait Contexts { self: Analyzer =>
"\n Access to protected "+target+" not permitted because"+
"\n "+"enclosing class "+this.enclClass.owner+this.enclClass.owner.locationString+" is not a subclass of "+
"\n "+sym.owner+sym.owner.locationString+" where target is defined"
- c != NoContext && {
- val res =
- isSubClassOrCompanion(pre.widen.typeSymbol, c.owner) ||
- c.owner.isModuleClass &&
- isSubClassOrCompanion(pre.widen.typeSymbol, c.owner.linkedClassOfClass)
- if (!res)
- lastAccessCheckDetails =
- "\n Access to protected "+target+" not permitted because"+
- "\n prefix type "+pre.widen+" does not conform to"+
- "\n "+c.owner+c.owner.locationString+" where the access take place"
- res
+ c != NoContext &&
+ {
+ target.isType || { // allow accesses to types from arbitrary subclasses fixes #4737
+ val res =
+ isSubClassOrCompanion(pre.widen.typeSymbol, c.owner) ||
+ c.owner.isModuleClass &&
+ isSubClassOrCompanion(pre.widen.typeSymbol, c.owner.linkedClassOfClass)
+ if (!res)
+ lastAccessCheckDetails =
+ "\n Access to protected "+target+" not permitted because"+
+ "\n prefix type "+pre.widen+" does not conform to"+
+ "\n "+c.owner+c.owner.locationString+" where the access take place"
+ res
+ }
}
}