-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dotty sometimes loads denotation from classpath, even when a more recent version is being typechecked #2137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 23, 2017
… a real one Previously, we sometimes ended up forcing a companion class symbol from a previous run or from the classpath which lead to weird issues like in `tests/pos-special/false-companion`. Even if we end up not forcing such a symbol, its presence can still lead to issue: before this commit incremental compilation of `dotty-compiler-bootstrapped` was broken because we recorded a false dependency on the non-bootstrapped `dotty-compiler` jar.
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 23, 2017
… a real one Previously, we sometimes ended up forcing a companion class symbol from a previous run or from the classpath which lead to weird issues like in `tests/pos-special/false-companion`. Even if we end up not forcing such a symbol, its presence can still lead to issue: before this commit incremental compilation of `dotty-compiler-bootstrapped` was broken because we recorded a false dependency on the non-bootstrapped `dotty-compiler` jar.
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 23, 2017
… a real one Previously, we sometimes ended up forcing a companion class symbol from a previous run or from the classpath which lead to weird issues like in `tests/pos-special/false-companion`. Even if we end up not forcing such a symbol, its presence can still lead to issue: before this commit incremental compilation of `dotty-compiler-bootstrapped` was broken because we recorded a false dependency on the non-bootstrapped `dotty-compiler` jar.
smarter
added a commit
that referenced
this issue
Mar 28, 2017
Fix #2137: Create dummy companions for top-level objects without a real one
OlivierBlanvillain
pushed a commit
to dotty-staging/dotty
that referenced
this issue
Mar 30, 2017
… a real one Previously, we sometimes ended up forcing a companion class symbol from a previous run or from the classpath which lead to weird issues like in `false-companion`. Even if we end up not forcing such a symbol, its presence can still lead to issue: before this commit incremental compilation of `dotty-compiler-bootstrapped` was broken because we recorded a false dependency on the non-bootstrapped `dotty-compiler` jar. The added test is currently marked pending because it does not work with JUnit (which doesn't handle separate compilation), only partest. I didn't managed to get it to work right, and this won't be necessary once our testing framework is overhauled by scala#2125 anyway, so I'll just have to remember to enable this test afterwards.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Suppose that some file defines an object:
While typechecking this file, a term for
Foo
is entered in the scope ofdummy
, but no corresponding type is entered because there is noclass Foo
. However, once compilation is done, we output:If the current directory is on the classpath, this means that any subsequent compiler run will enter a type
Foo
in the scope ofdummy
because of howPackageLoader
works. Of course,dummy.Foo
is not a valid class,TypeAssigner
contains a methodreallyExists
to determine this:I think there is a fatal flaw in
reallyExists
: it requires forcing the info of the potentially-stale/absent symbol, this means we might unpickle trees from the classpath and pollute the scope with things that no longer exist. Here's a demonstration of how this might lead the compiler to crash:outerFoo_1.scala
:outerinnerFoo_1.scala
:outerinnerFoo_2.scala
:outerinnerTest_2.scala
Full stacktrace: https://gist.github.com/smarter/c854842847e1e4d12794adabee5ad7c0
I don't know exactly why this is crashing but the root cause here is that when I do
val x: Foo
inTest
,typedIdent
will first tryouter.inner.Foo
, which means callingreallyExists
on it and thus unpicklingouter.inner.Foo
andouter.inner.Foo$
fromouter/inner/Foo.class
even though we are also compilingouterinnerFoo_2.scala
which contains a more recent version of the objectouter.inner.Foo$
.The only solution I can think of is that whenever we enter the symbol for a class or object without companion, we should mark the companion as absent to make very sure that we never try to load it from the classpath.
The text was updated successfully, but these errors were encountered: