Mark tests that regress when name hashing is enabled.

There are number of scripted tests that fail if we switch to name hashing
being enabled by default. There's no easy way to mark those tests as
pending only when name hashing flag is enabled so I decided to "mark" them
by copying those tests, enabling name hashing in each of them and mark
those copies as pending.

Here's explanation of each failing test:

  * `constants` and `java-static` fail due to typer inlining constants
    so we can't track dependencies properly (see SI-7173)
  * `macro` fails for similar reasons as above: typer expands macros
    and we can't track dependencies properly
  * `struct` fails because it turns out that we need to handle structural
    types in a special way both at declaration and use sites. At the moment
    we handle them explicitly at declaration site so `struct-usage` passes
    but `struct` fails
This commit is contained in:
Grzegorz Kossakowski 2013-12-15 23:46:07 +01:00
parent a48ab0d38b
commit cd6b2a2a8c
21 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1 @@
incOptions := incOptions.value.withNameHashing(true)

View File

@ -0,0 +1 @@
object A { final val x = 1 }

View File

@ -0,0 +1 @@
object A { final val x = 2 }

View File

@ -0,0 +1,4 @@
object B
{
def main(args: Array[String]) = assert(args(0).toInt == A.x )
}

View File

@ -0,0 +1,11 @@
# Tests if source dependencies are tracked properly
# for compile-time constants (like final vals in top-level objects)
# see https://issues.scala-lang.org/browse/SI-7173 for details
# why compile-time constants can be tricky to track due to early inlining
$ copy-file changes/B.scala B.scala
$ copy-file changes/A1.scala A.scala
> run 1
$ copy-file changes/A2.scala A.scala
> run 2

View File

@ -0,0 +1 @@
incOptions := incOptions.value.withNameHashing(true)

View File

@ -0,0 +1,4 @@
public class J
{
public static final int x = 3;
}

View File

@ -0,0 +1,4 @@
public class J
{
public static final String x = "3";
}

View File

@ -0,0 +1,4 @@
object S
{
val y: Int = J.x
}

View File

@ -0,0 +1,24 @@
# When a Java class is loaded from a class file and not parsed from a source file, scalac reports
# the statics as an object without a file and so the Analyzer must know to look for the
# object's linked class.
# This test verifies this happens.
# The test compiles a Java class with a static field.
# It then adds a Scala object that references the static field. Because the object only depends on a
# static member and because the Java source is not included in the compilation (since it didn't change),
# this triggers the special case above.
# add and compile the Java source
$ copy-file changes/J1.java src/main/java/J.java
> compile
# add and compile the Scala source
$ copy-file changes/S.scala src/main/scala/S.scala
> compile
# change the Java source so that a compile error should occur if S.scala is also recompiled (which will happen if the dependency was properly recorded)
$ copy-file changes/J2.java src/main/java/J.java
-> compile
# verify it should have failed by doing a full recompilation
> clean
-> compile

View File

@ -0,0 +1,5 @@
package macro
object Client {
Provider.tree(0)
}

View File

@ -0,0 +1,8 @@
package macro
import scala.language.experimental.macros
import scala.reflect.macros._
object Provider {
def tree(args: Any) = macro treeImpl
def treeImpl(c: Context)(args: c.Expr[Any]) = c.universe.reify(args.splice)
}

View File

@ -0,0 +1,8 @@
package macro
import scala.language.experimental.macros
import scala.reflect.macros._
object Provider {
def tree(args: Any) = macro treeImpl
def treeImpl(c: Context)(args: c.Expr[Any]) = sys.error("no macro for you!")
}

View File

@ -0,0 +1,13 @@
> compile
# replace macro with one that throws an error
$ copy-file macro-provider/changes/Provider.scala macro-provider/Provider.scala
> macro-provider/compile
-> macro-client/compile
> clean
-> compile

View File

@ -0,0 +1,29 @@
import sbt._
import Keys._
object build extends Build {
val defaultSettings = Seq(
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ ),
incOptions := incOptions.value.withNameHashing(true)
)
lazy val root = Project(
base = file("."),
id = "macro",
aggregate = Seq(macroProvider, macroClient),
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroProvider = Project(
base = file("macro-provider"),
id = "macro-provider",
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroClient = Project(
base = file("macro-client"),
id = "macro-client",
dependencies = Seq(macroProvider),
settings = Defaults.defaultSettings ++ defaultSettings
)
}

View File

@ -0,0 +1,3 @@
object A {
def x: Int = 3
}

View File

@ -0,0 +1,4 @@
object B {
def onX(m: { def x: Int } ) =
m.x
}

View File

@ -0,0 +1,4 @@
object C {
def main(args: Array[String]) =
println(B.onX(A))
}

View File

@ -0,0 +1 @@
incOptions := incOptions.value.withNameHashing(true)

View File

@ -0,0 +1,3 @@
object A {
def x: Byte = 3
}

View File

@ -0,0 +1,6 @@
> compile
# modify A.scala so that it does not conform to the structural type in B.scala
$ copy-file changes/A.scala A.scala
-> compile