summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2017-04-11 16:57:16 -0700
committerAdriaan Moors <adriaan@lightbend.com>2017-04-12 07:51:18 -0700
commit747e22322330a762dd54037ccc1cb3608c6691bd (patch)
tree1f18742955bbdc6914c23c739e65f11a738895a3 /test
parent12c240d69b6958d2c8f03a7728c097dd215011cd (diff)
downloadscala-747e22322330a762dd54037ccc1cb3608c6691bd.tar.gz
scala-747e22322330a762dd54037ccc1cb3608c6691bd.tar.bz2
scala-747e22322330a762dd54037ccc1cb3608c6691bd.zip
Actually retract clashing synthetic apply/unapply
The completer set the IS_ERROR flag and I assumed the typer dropped a synthetic tree with a symbol with that flag, because the tree was not shown in -Xprint output. It turns out, as explained by lrytz, that the mechanism was fragile because it relied on the order in which completers are run. We now cover both the case that: - the completer was run (and the `IS_ERROR` flag was set) before `addSynthetics` in `typedStat` iterates over the scope (since the symbol is already unlinked, the tree is not added, irrespective of its flags). For this case, we also remove the symbol from the synthetics in its unit. - the completer is triggered during the iteration in `addSynthetics`, which needs the check for the `IS_ERROR` flag during the iteration. Thankfully, the community build caught my mistake, and lrytz provided a good analysis and review. Fix scala/bug#10261
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t10261/Companion_1.scala4
-rw-r--r--test/files/run/t10261/Test_2.scala14
2 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/t10261/Companion_1.scala b/test/files/run/t10261/Companion_1.scala
new file mode 100644
index 0000000000..9b8e2c73b2
--- /dev/null
+++ b/test/files/run/t10261/Companion_1.scala
@@ -0,0 +1,4 @@
+trait Companion[T] {
+ def parse(value: String): Option[T]
+ def apply(value: String): T = parse(value).get
+}
diff --git a/test/files/run/t10261/Test_2.scala b/test/files/run/t10261/Test_2.scala
new file mode 100644
index 0000000000..d7d9fe9a0e
--- /dev/null
+++ b/test/files/run/t10261/Test_2.scala
@@ -0,0 +1,14 @@
+import scala.util.Try
+
+object C extends Companion[C] {
+ def parse(v: String) = if (v.nonEmpty) Some(new C(v)) else None
+}
+
+case class C(value: String)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(Try{C("")}.isFailure, "Empty value should fail to parse") // check that parse is used to validate input
+ assert(C("a").value == "a", "Unexpected value")
+ }
+}