summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-05-29 12:53:20 -0700
committerJames Iry <jamesiry@gmail.com>2013-05-29 12:53:20 -0700
commit810a6de757a44d7d481e0ee1bd9c2fb8abe6043d (patch)
tree851f9953d3da078e5dc4b9529b396a4bf06af153
parent6cc39842f79bcf266ca3f49eca1f2a1ba46ed817 (diff)
parent851e39991e7a929e1d83d5e35a024d5b9bd0b75f (diff)
downloadscala-810a6de757a44d7d481e0ee1bd9c2fb8abe6043d.tar.gz
scala-810a6de757a44d7d481e0ee1bd9c2fb8abe6043d.tar.bz2
scala-810a6de757a44d7d481e0ee1bd9c2fb8abe6043d.zip
Merge pull request #2601 from retronym/ticket/7516
SI-7516 Revert "SI-7234 Make named args play nice w. depmet types"
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala12
-rw-r--r--test/files/pos/t7516/A_1.scala9
-rw-r--r--test/files/pos/t7516/B_2.scala4
-rw-r--r--test/pending/pos/t7234.scala (renamed from test/files/pos/t7234.scala)0
-rw-r--r--test/pending/pos/t7234b.scala (renamed from test/files/pos/t7234b.scala)0
5 files changed, 20 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 802df39f01..d54f894c62 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -284,11 +284,13 @@ trait NamesDefaults { self: Analyzer =>
case Typed(expr, Ident(tpnme.WILDCARD_STAR)) => expr.tpe
case _ => seqType(arg.tpe)
}
- else
- // Note stabilizing can lead to a non-conformant argument when existentials are involved, e.g. neg/t3507-old.scala, hence the filter.
- // We have to deconst or types inferred from literal arguments will be Constant(_), e.g. pos/z1730.scala.
- gen.stableTypeFor(arg).filter(_ <:< paramTpe).getOrElse(arg.tpe).deconst
- )
+ else {
+ // TODO In 83c9c764b, we tried to a stable type here to fix SI-7234. But the resulting TypeTree over a
+ // singleton type without an original TypeTree fails to retypecheck after a resetLocalAttrs (SI-7516),
+ // which is important for (at least) macros.
+ arg.tpe
+ }
+ ).widen // have to widen or types inferred from literal defaults will be singletons
val s = context.owner.newValue(unit.freshTermName("x$"), arg.pos) setInfo (
if (byName) functionType(Nil, argTpe) else argTpe
)
diff --git a/test/files/pos/t7516/A_1.scala b/test/files/pos/t7516/A_1.scala
new file mode 100644
index 0000000000..3bba19966d
--- /dev/null
+++ b/test/files/pos/t7516/A_1.scala
@@ -0,0 +1,9 @@
+import scala.reflect._,macros._, scala.language.experimental.macros
+
+object A {
+ def impl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = {
+ val r = c.universe.reify { List(t.splice) }
+ c.Expr[List[T]]( c.resetLocalAttrs(r.tree) )
+ }
+ def demo[T](t: T): List[T] = macro impl[T]
+}
diff --git a/test/files/pos/t7516/B_2.scala b/test/files/pos/t7516/B_2.scala
new file mode 100644
index 0000000000..1b8531bc85
--- /dev/null
+++ b/test/files/pos/t7516/B_2.scala
@@ -0,0 +1,4 @@
+object B {
+ final case class CV(p: Int = 3, g: Int = 2)
+ A.demo { val d = 4; CV(g = d); "a" }
+}
diff --git a/test/files/pos/t7234.scala b/test/pending/pos/t7234.scala
index 59a233d835..59a233d835 100644
--- a/test/files/pos/t7234.scala
+++ b/test/pending/pos/t7234.scala
diff --git a/test/files/pos/t7234b.scala b/test/pending/pos/t7234b.scala
index fee98e87a8..fee98e87a8 100644
--- a/test/files/pos/t7234b.scala
+++ b/test/pending/pos/t7234b.scala