This page is no longer maintained — Please continue to the home page at www.scala-lang.org

no accessible symbol

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

In Erasure, this was added in r24749:

if (!isAccessible(owner) && qual.tpe != null) {
// Todo: Figure out how qual.tpe could be null in the check above (it does appear in build where SwingWorker.this
// has a null type).

I had the same question for other reasons, and here is what I found out. Compiling this line in Erasure with r24746. (** The use of r24746 is important)

def isAccessible(sym: Symbol) = localTyper.context.isAccessible(sym, sym.owner.thisType, false)

If you use -Ycheck:all it will fail in the typer:

Erasure.scala:1057: error: variable context in class Typer cannot be accessed in Erasure.this.global.analyzer.Typer
because of an internal error (no accessible symbol):
sym = method context
underlying(sym) = variable context
pre = Erasure.this.global.analyzer.Typer

However if it is changed to localTyper.context1, it comes through cleanly. Where context1 is:

var context = context0
def context1 = context

So this seems to have something to do with symbols for getters. (The problem remains if you lift the method outside the anonymous subclass where it is presently, so it's not that aspect.)

And also, it seems that these "inaccessible symbol" errors we see under -Ycheck materialize as trees with no type and/or no symbol under normal operation, and then to the extent the compiler works, it is successfully attributing them during some later attempt. This is a bit of a revelation to me, it explains a lot.

** If you compile with r24749 or a version since then, -Ycheck:all will ALSO come through typer cleanly, but now it is because of the null check you added, so the underlying problem remains.

Since var context is public, one might wonder why context1 exists at all. When it was added it looked like this.

private var context = context0
def context1 = context

------------- Separately... ---------------

When compiling this same file Erasure.scala, -Ycheck:all complains after erasure and in every phase to follow:

[check: erasure] 2 DefTrees with symbol ''value qual'': ,
[check: erasure] 2 DefTrees with symbol ''value parents'': ,
[check: erasure] 2 DefTrees with symbol ''value name'': ,
[check: erasure] 2 DefTrees with symbol ''value name'': ,
[check: erasure] 2 DefTrees with symbol ''value qual'': ,
[check: erasure] 2 DefTrees with symbol ''value args'': ,
[check: erasure] 2 DefTrees with symbol ''value arg'': ,
[check: erasure] 2 DefTrees with symbol ''value arg'': ,
[check: erasure] 2 DefTrees with symbol ''value qual'': ,
[check: erasure] 2 DefTrees with symbol ''value qual'': ,
[check: erasure] 2 DefTrees with symbol ''value qual'': ,
[check: erasure] 2 DefTrees with symbol ''value targ'': ,
[check: erasure] 2 DefTrees with symbol ''value fun'': ,

Do you know why this might be? I don't know when it began; it predates r24749 though.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland