summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-03 12:54:57 -0700
committerPaul Phillips <paulp@improving.org>2012-05-03 18:24:10 -0700
commit780bed7fbb77d095cbc03eb0244f8b1f1e4cf88c (patch)
tree5bbc4c3662dd9798e35acd7e81a01004d1c95752 /src/compiler
parent8bc8b83f0bd7daef62b41b4a0c87b4e9b7344284 (diff)
downloadscala-780bed7fbb77d095cbc03eb0244f8b1f1e4cf88c.tar.gz
scala-780bed7fbb77d095cbc03eb0244f8b1f1e4cf88c.tar.bz2
scala-780bed7fbb77d095cbc03eb0244f8b1f1e4cf88c.zip
Fix for Dynamic interaction with private methods.
Don't let inaccessible methods prevent calls to *Dynamic, otherwise we are at the mercy of every "private" alteration in every class we inherit. Closes SI-5040.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 6248d27727..5902e480a3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4247,6 +4247,8 @@ trait Typers extends Modes with Adaptations with Taggings {
* @return ...
*/
def typedSelect(qual: Tree, name: Name): Tree = {
+ def asDynamicCall = dyna.mkInvoke(context.tree, tree, qual, name) map (typed1(_, mode, pt))
+
val sym = tree.symbol orElse member(qual, name) orElse {
// symbol not found? --> try to convert implicitly to a type that does have the required
// member. Added `| PATTERNmode` to allow enrichment in patterns (so we can add e.g., an
@@ -4268,11 +4270,7 @@ trait Typers extends Modes with Adaptations with Taggings {
}
// try to expand according to Dynamic rules.
- dyna.mkInvoke(context.tree, tree, qual, name) match {
- case Some(invocation) =>
- return typed1(invocation, mode, pt)
- case _ =>
- }
+ asDynamicCall foreach (x => return x)
debuglog(
"qual = "+qual+":"+qual.tpe+
@@ -4311,7 +4309,8 @@ trait Typers extends Modes with Adaptations with Taggings {
if (err.kind != ErrorKinds.Access) {
context issue err
return setError(tree)
- } else (tree1, Some(err))
+ }
+ else (tree1, Some(err))
case SilentResultValue(treeAndPre) =>
(stabilize(treeAndPre._1, treeAndPre._2, mode, pt), None)
}
@@ -4341,10 +4340,12 @@ trait Typers extends Modes with Adaptations with Taggings {
val qual1 = adaptToMemberWithArgs(tree, qual, name, mode, false, false)
if (!qual1.isErrorTyped && (qual1 ne qual))
typed(Select(qual1, name) setPos tree.pos, mode, pt)
- else {
- issue(accessibleError.get)
- setError(tree)
- }
+ else
+ // before failing due to access, try a dynamic call.
+ asDynamicCall getOrElse {
+ issue(accessibleError.get)
+ setError(tree)
+ }
case _ =>
result
}