Skip to content

Commit

Permalink
tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
niktrop committed Oct 27, 2016
1 parent a9fdd59 commit 92f7d9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
25 changes: 11 additions & 14 deletions src/org/jetbrains/plugins/scala/lang/resolve/ResolveUtils.scala
Expand Up @@ -200,6 +200,11 @@ object ResolveUtils {
case Some(am: ScAccessModifier) =>
if (am.isPrivate) {
if (am.access == ScAccessModifier.Type.THIS_PRIVATE) {
val containingClass = scMember.containingClass
if (containingClass == null) return true

if (scMember.hasModifierProperty("implicit"))
return PsiTreeUtil.isContextAncestor(containingClass, place, false)
/*
ScalaRefernce.pdf:
A member M marked with this modifier can be accessed only from
Expand All @@ -209,28 +214,20 @@ object ResolveUtils {
case ref: ScReferenceElement =>
ref.qualifier match {
case None =>
val enclosing = PsiTreeUtil.getContextOfType(scMember, true, classOf[ScTemplateDefinition])
if (enclosing == null) return true
return PsiTreeUtil.isContextAncestor(enclosing, place, false)
return PsiTreeUtil.isContextAncestor(containingClass, place, false)
case Some(t: ScThisReference) =>
val enclosing = PsiTreeUtil.getContextOfType(scMember, true, classOf[ScTemplateDefinition])
if (enclosing == null) return true
t.refTemplate match {
case Some(t) => return t == enclosing
case _ => return PsiTreeUtil.isContextAncestor(enclosing, place, false)
return t.refTemplate match {
case Some(templ) => templ == containingClass
case _ => PsiTreeUtil.isContextAncestor(containingClass, place, false)
}
case Some(ref: ScReferenceElement) =>
val enclosing = PsiTreeUtil.getContextOfType(scMember, true, classOf[ScTemplateDefinition])
if (enclosing == null) return false
val resolve = ref.resolve()
if (enclosing.extendsBlock.selfTypeElement == Some(resolve)) return true
if (containingClass.extendsBlock.selfTypeElement.contains(resolve)) return true
else return false
case _ => return false
}
case _ =>
val enclosing = PsiTreeUtil.getContextOfType(scMember, true, classOf[ScTemplateDefinition])
if (enclosing == null) return true
return PsiTreeUtil.isContextAncestor(enclosing, place, false)
return PsiTreeUtil.isContextAncestor(containingClass, place, false)
}
}
val ref = am.getReference
Expand Down
Expand Up @@ -30,7 +30,7 @@ trait SimpleResolveTestBase {
var tgt: PsiElement = null
def configureFile(file: (String, String), configureFun: (String, String) => PsiFile) = {
val (source, fileName) = file
val trimmed = source.trim
val trimmed = source.trim.replace("\r", "")
val srcOffset = trimmed.replaceAll(REFTGT, "").indexOf(REFSRC)
val tgtOffset = trimmed.replaceAll(REFSRC, "").indexOf(REFTGT)
val psiFile = configureFun(fileName, trimmed.replaceAll(REFSRC, "").replaceAll(REFTGT,""))
Expand Down

0 comments on commit 92f7d9d

Please sign in to comment.