Skip to content

Fix of #39 #42

Merged
merged 1 commit into from Mar 6, 2014

3 participants

@odersky
odersky commented Mar 4, 2014

Two fixes:
1) Avoid the infinite recursion in checkAccessible if the accessibility check fails.
2) Make accessibility succeed for the test, and in general if the target denotation does not have a symbol.

Added original test in pos and a negative test which makes accessibility fail.

Review by @DarkDimius, @samuelgruetter

@odersky odersky Fix of #39
Two fixes:
1) Avoid the infinite recursion in checkAccessible if the accessibility check fails.
2) Make accessibility succeed for the test, and in general if the target denotation does not have a symbol.

Added original test in pos and a negative test which makes accessibility fail.
f196e07
@DarkDimius DarkDimius commented on the diff Mar 4, 2014
test/dotc/tests.scala
@@ -40,6 +40,7 @@ class tests extends CompilerTest {
@Test def pos_overloaded() = compileFile(posDir, "overloaded")
@Test def pos_templateParents() = compileFile(posDir, "templateParents")
@Test def pos_structural() = compileFile(posDir, "structural")
+ @Test def pos_i39 = compileFile(posDir, "i39")
@DarkDimius
Programming Methods Laboratory EPFL member
DarkDimius added a note Mar 4, 2014

It would be good to have a http link for this issue on github, as "i39" is not so obvious.

@odersky
odersky added a note Mar 4, 2014

I think should have a naming convention for issue tests, then it will become obvious. Scala 2 has t123, should we do the same or stick with i123?

@DarkDimius
Programming Methods Laboratory EPFL member
DarkDimius added a note Mar 4, 2014

Having such convention seems good idea.
I'd prefer i123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@DarkDimius DarkDimius commented on the diff Mar 4, 2014
test/dotc/tests.scala
@@ -49,6 +50,7 @@ class tests extends CompilerTest {
@Test def neg_privates() = compileFile(negDir, "privates", xerrors = 2)
@Test def neg_rootImports = compileFile(negDir, "rootImplicits", xerrors = 2)
@Test def neg_templateParents() = compileFile(negDir, "templateParents", xerrors = 3)
+ @Test def neg_i39 = compileFile(negDir, "i39", xerrors = 1)
@DarkDimius
Programming Methods Laboratory EPFL member
DarkDimius added a note Mar 4, 2014

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@DarkDimius
Programming Methods Laboratory EPFL member

Otherwise Ok for me

@DarkDimius
Programming Methods Laboratory EPFL member

LGTM

@samuelgruetter
Programming Methods Laboratory EPFL member

Not sure if this is an issue: In

object test241 {

  trait A {
    def foo(i: Int): String = ???
    def foo(s: String): String = ???
  }

  class B extends A {
    private def foo(s: String): String = ???
  }

  println((new B).foo(""))

}

I get

error: type mismatch:
found   : String("")
required: Int
println((new B).foo(""))
                    ^

so the foo(String) of super cannot be accessed. But if I remove the foo(Int), the foo(String) of super can be accessed. This is inconsistant. But, on the other hand, Scala 2.10.3 behaves the same.

@samuelgruetter samuelgruetter commented on the diff Mar 4, 2014
src/dotty/tools/dotc/typer/Typer.scala
+ val d2 = pre.nonPrivateMember(name)
+ if (reallyExists(d2) && firstTry) test(pre.select(name, d2), false)
+ else {
+ val alts = tpe.denot.alternatives.map(_.symbol).filter(_.exists)
+ val what = alts match {
+ case Nil =>
+ name.toString
+ case sym :: Nil =>
+ if (sym.owner == pre.typeSymbol) sym.show else sym.showLocated
+ case _ =>
+ i"none of the overloaded alternatives named $name"
+ }
+ val where = if (ctx.owner.exists) s" from ${ctx.owner.enclosingClass}" else ""
+ val whyNot = new StringBuffer
+ val addendum =
+ alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot))
@samuelgruetter
Programming Methods Laboratory EPFL member

why do you assign Unit to a val?

@odersky
odersky added a note Mar 6, 2014

Good catch. I will do a shortcut in the interest of time and fix it in the next commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@odersky odersky merged commit 6ada020 into lampepfl:master Mar 6, 2014

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.