Skip to content
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

Name hashing: Members with constant types are not tracked #1543

Closed
gkossakowski opened this issue Aug 21, 2014 · 1 comment
Closed

Name hashing: Members with constant types are not tracked #1543

gkossakowski opened this issue Aug 21, 2014 · 1 comment

Comments

@gkossakowski
Copy link
Contributor

Let's say we have:

// A.scala
object A {
  final val x = 12
}

// B.scala
object B { 
  def abc: Int = A.x
}

and we'll change A.scala so it looks like this:

// A.scala
object A {
  final val x = "foo"
}

then name hashing won't trigger recompilation of B and won't realize there's a compilation error. The reason is that A.x has a constant type inferred. When we refer to it from B, we get the constant inlined by Scala's type checker and any trace that there was dependency on A.x is gone.

The fix for this issue has to happen on Scala compiler side, see SI-7173.

gkossakowski added a commit to gkossakowski/sbt that referenced this issue Aug 22, 2014
This commit changes the default value of `IncOptions.nameHashing` to be
set to true. It means, the improved incremental compilation algorithm
known as "name hashing" will be enabled by default.

In order to disable it, users should add this to their sbt configuration:

  incOptions := incOptions.value.withNameHashing(false)

Number of tests has been cleaned up as part of this change. All tests
that were marked as name hashing specific are removed. The list includes:

  * constants-name-hashing
  * import-class-name-hashing
  * java-static-name-hashing
  * macro-name-hashing
  * struct-name-hashing

We'll keep just regular version of those tests. The tests will just
exercise the default algorithm: name hashing. This is the first step
towards phasing out of the old incremental compilation algorithm.

Apart from that, a few tests changed its status due to enabling name
hashing algorithm.

The `constants` test has been marked pending due to issue described in
sbt#1543.

The `import-class` test has been marked as passing because name hashing
tracks dependencies introduced by import statements correctly, now.

The `macro` test has been marked as pending due to issue described in
sbt#1544.

The `struct` test has been marked as pending due to issue described in
sbt#1545.

The `java-static` has been slightly modified to exercise just static field
and not run into the same issue as with `constants` test.

There are no other known issues related to name hashing so we conclude
that name hashing is ready to be shipped to all sbt, Scala IDE and zinc
users.
@eed3si9n eed3si9n changed the title Name hashing algorithm doesn't track members with constant types Name hashing: Members with constant types are not tracked Aug 22, 2014
@dwijnand
Copy link
Member

@jvican migrated this to sbt/zinc#227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants