Skip to content

Commit 606a553

Browse files
committed
SI-8512 Infer Any for the q
Avoid the widening bug for q. This resolution also suffers from the inference of Any, which can trigger a warning and an anxiety attack. But that's still better than doing the wrong thing. Right?
1 parent 2e3583b commit 606a553

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/reflect/scala/reflect/api/Quasiquotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait Quasiquotes { self: Universe =>
1313
protected trait api {
1414
// implementation is hardwired to `dispatch` method of `scala.tools.reflect.quasiquotes.Quasiquotes`
1515
// using the mechanism implemented in `scala.tools.reflect.FastTrack`
16-
def apply[T](args: T*): Tree = macro ???
16+
def apply[A >: Any](args: A*): Tree = macro ???
1717
def unapply(scrutinee: Any): Any = macro ???
1818
}
1919
object q extends api

test/files/pos/t8013.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Xfatal-warnings -Xlint
1+
-Xfatal-warnings -Xlint:-infer-any,_

test/junit/scala/reflect/QTest.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
package scala.reflect
3+
4+
import org.junit.Test
5+
import org.junit.Assert._
6+
import org.junit.runner.RunWith
7+
import org.junit.runners.JUnit4
8+
9+
import scala.tools.testing.AssertUtil._
10+
11+
@RunWith(classOf[JUnit4])
12+
class QTest {
13+
14+
import reflect.runtime._
15+
import universe._
16+
@Test def qConstantsNotHomogenized() = {
17+
//Apply(Select(Literal(Constant(1.0)), TermName("$plus")), List(Literal(Constant(1.0))))
18+
val t = q"${1} + ${1.0}"
19+
val Apply(Select(Literal(Constant(i)), TermName("$plus")), List(Literal(Constant(j)))) = t
20+
assertEquals(1, i)
21+
assertEquals(1.0, j)
22+
}
23+
}

0 commit comments

Comments
 (0)