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

quasiquote unapply macro gives spurious "wrong number of subpatterns" under presentation compiler #8934

Closed
scabug opened this issue Oct 23, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Oct 23, 2014

git show
commit 1658a825f0e1004186df9be188fe9ce374ad9ae7
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Thu Oct 23 16:26:46 2014 +1000

    Failing test case for quasiquotes in presentation compiler

    ```
    $ ./test/partest --show-diff test/files/presentation/quasiquotes
    ...
    +reload: Source.scala
    +too many patterns for trait api: expected 1, found 2
    ```

diff --git a/test/files/presentation/quasiquotes/Runner.scala b/test/files/presentation/quasiquotes/Runner.scala
new file mode 100644
index 0000000..944f458
--- /dev/null
+++ b/test/files/presentation/quasiquotes/Runner.scala
@@ -0,0 +1,27 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+import scala.reflect.internal.util.SourceFile
+import scala.tools.nsc.interactive.Response
+
+object Test extends InteractiveTest {
+
+  override def execute(): Unit = {
+    val src = loadSourceAndWaitUntilTypechecked("Source.scala")
+    checkErrors(src)
+  }
+
+  private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = {
+    val sourceFile = sourceFiles.find(_.file.name == sourceName).head
+    askReload(List(sourceFile)).get
+    askLoadedTyped(sourceFile).get
+    sourceFile
+  }
+
+  private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match {
+    case Some(unit) =>
+      val problems = unit.problems.toList
+      if(problems.isEmpty) reporter.println("Test OK")
+      else problems.foreach(problem => reporter.println(problem.msg))
+
+    case None => reporter.println("No compilation unit found for " + source.file.name)
+  }
+}
diff --git a/test/files/presentation/quasiquotes/src/Source.scala b/test/files/presentation/quasiquotes/src/Source.scala
new file mode 100644
index 0000000..769c8fd
--- /dev/null
+++ b/test/files/presentation/quasiquotes/src/Source.scala
@@ -0,0 +1,10 @@
+class Quasi {
+  import reflect.runtime.universe._
+
+  def test: Unit = {
+    (null: Any) match {
+      case q"$foo($bar)" =>
+    }
+    ()
+  }
+}
topic/quasiquote-presentation ~/code/scala git diff
topic/quasiquote-presentation ~/code/scala git diff head
diff --git a/test/files/presentation/quasiquotes.flags b/test/files/presentation/quasiquotes.flags
new file mode 100644
index 0000000..3c1ff18
--- /dev/null
+++ b/test/files/presentation/quasiquotes.flags
@@ -0,0 +1 @@
+-Ytyper-debug


% qscalac -Ytyper-debug 
test/files/presentation/quasiquotes/src/Source.scala 2>&1 | tee sandbox/good.txt

% pt --show-diff test/files/presentation/quasiquotes

% diff -U 100000 sandbox/good.txt test/files/presentation/quasiquotes-presentation.log | gist --filename quasiquote.diff
https://gist.github.com/retronym/31af8fe2c36bd880a072

As reported https://groups.google.com/d/msg/scala-ide-user/jUalTVRnTmY/v6XG7q3B3FYJ

@scabug
Copy link
Author

scabug commented Oct 23, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8934?orig=1
Reporter: @retronym
Affected Versions: 2.11.2

@scabug
Copy link
Author

scabug commented Oct 24, 2014

@retronym said:
Here's a potential solution: https://github.com/retronym/scala/compare/ticket/8934?expand=0

@scabug
Copy link
Author

scabug commented Oct 24, 2014

@retronym said:
scala/scala#4076

@scabug scabug closed this as completed Nov 2, 2014
@scabug
Copy link
Author

scabug commented Nov 21, 2014

@soc said:
I have experienced the same issue with som-snytt's regextractor library. If I find some time, I'll check whether this change also fixes it.

@scabug
Copy link
Author

scabug commented Jan 13, 2015

@soc said:
I can report that this change also fixed the issue I saw. Thanks!

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