From de12ca6ef8071820c6b2a9403ccab9aa6ed51c0b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 23 May 2013 16:50:45 -0700 Subject: SI-7486 Regressions in implicit search. Revert e86832d7e8 and dd33e280e2. --- test/pending/neg/t7441.check | 6 ++++++ test/pending/neg/t7441.scala | 7 +++++++ test/pending/pos/t7486.scala | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 test/pending/neg/t7441.check create mode 100644 test/pending/neg/t7441.scala create mode 100644 test/pending/pos/t7486.scala (limited to 'test/pending') diff --git a/test/pending/neg/t7441.check b/test/pending/neg/t7441.check new file mode 100644 index 0000000000..f259457197 --- /dev/null +++ b/test/pending/neg/t7441.check @@ -0,0 +1,6 @@ +t7441.scala:4: error: type mismatch; + found : Int(1) + required: List[Any] + def test = apply(1) + ^ +one error found diff --git a/test/pending/neg/t7441.scala b/test/pending/neg/t7441.scala new file mode 100644 index 0000000000..dad7421e3f --- /dev/null +++ b/test/pending/neg/t7441.scala @@ -0,0 +1,7 @@ +object Test { + object Bar { + def apply(xs: List[Any]): Int = 0 + def test = apply(1) + } + implicit def foo = 1 +} diff --git a/test/pending/pos/t7486.scala b/test/pending/pos/t7486.scala new file mode 100644 index 0000000000..6dd7f4c4ac --- /dev/null +++ b/test/pending/pos/t7486.scala @@ -0,0 +1,8 @@ +object Test{ + var locker = 0 + // remove implicit, or change to `locker = locker + 1` to make it compile. + implicit val davyJones0 = { + locker += 0 + 0 + } +} -- cgit v1.2.3 From 851e39991e7a929e1d83d5e35a024d5b9bd0b75f Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 27 May 2013 13:36:48 +0200 Subject: SI-7516 Revert "SI-7234 Make named args play nice w. depmet types" This reverts commit 83c9c764b528a7a1c1d39c480d22c8e3a71d5a58. The tests are shunted to 'pending'. Why revert this seemingly innocous commit? 83c9c764 generates a ValDef whose tpt TypeTree has no original; this contains a reference to the symbol for `d`. resetAttrs and the retypecheck assigns a new symbol for d and leaves a the reference to the prior symbol dangling. The real bug is the resetAttrs concept. --- .../scala/tools/nsc/typechecker/NamesDefaults.scala | 12 +++++++----- test/files/pos/t7234.scala | 15 --------------- test/files/pos/t7234b.scala | 20 -------------------- test/files/pos/t7516/A_1.scala | 9 +++++++++ test/files/pos/t7516/B_2.scala | 4 ++++ test/pending/pos/t7234.scala | 15 +++++++++++++++ test/pending/pos/t7234b.scala | 20 ++++++++++++++++++++ 7 files changed, 55 insertions(+), 40 deletions(-) delete mode 100644 test/files/pos/t7234.scala delete mode 100644 test/files/pos/t7234b.scala create mode 100644 test/files/pos/t7516/A_1.scala create mode 100644 test/files/pos/t7516/B_2.scala create mode 100644 test/pending/pos/t7234.scala create mode 100644 test/pending/pos/t7234b.scala (limited to 'test/pending') 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/t7234.scala b/test/files/pos/t7234.scala deleted file mode 100644 index 59a233d835..0000000000 --- a/test/files/pos/t7234.scala +++ /dev/null @@ -1,15 +0,0 @@ -trait Main { - trait A { - type B - } - trait C { - def c(a: A, x: Int = 0)(b: a.B) - } - def c: C - def d(a: A, x: Int = 0)(b: a.B) - - def ok1(a: A)(b: a.B) = c.c(a, 42)(b) - def ok2(a: A)(b: a.B) = d(a)(b) - - def fail(a: A)(b: a.B) = c.c(a)(b) -} diff --git a/test/files/pos/t7234b.scala b/test/files/pos/t7234b.scala deleted file mode 100644 index fee98e87a8..0000000000 --- a/test/files/pos/t7234b.scala +++ /dev/null @@ -1,20 +0,0 @@ -trait Main { - trait A { - type B - def b: B - } - trait C { - def c(a: A, x: Int = 0)(b: => a.B, bs: a.B*) - def d(a: A = null, x: Int = 0)(b1: => a.B = a.b, b2: a.B = a.b) - } - def c: C - def ok(a: A)(b: a.B) = c.c(a, 42)(b) - def fail(a: A)(b: a.B) = c.c(a)(b) - def fail2(a: A)(b: a.B) = c.c(a)(b, b) - def fail3(a: A)(b: a.B) = c.c(a)(b, Seq[a.B](b): _*) - - def fail4(a: A)(b: a.B) = c.d(a)() - def fail5(a: A)(b: a.B) = c.d(a)(b1 = a.b) - def fail6(a: A)(b: a.B) = c.d(a)(b2 = a.b) - def fail7(a: A)(b: a.B) = c.d()() -} 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/pending/pos/t7234.scala b/test/pending/pos/t7234.scala new file mode 100644 index 0000000000..59a233d835 --- /dev/null +++ b/test/pending/pos/t7234.scala @@ -0,0 +1,15 @@ +trait Main { + trait A { + type B + } + trait C { + def c(a: A, x: Int = 0)(b: a.B) + } + def c: C + def d(a: A, x: Int = 0)(b: a.B) + + def ok1(a: A)(b: a.B) = c.c(a, 42)(b) + def ok2(a: A)(b: a.B) = d(a)(b) + + def fail(a: A)(b: a.B) = c.c(a)(b) +} diff --git a/test/pending/pos/t7234b.scala b/test/pending/pos/t7234b.scala new file mode 100644 index 0000000000..fee98e87a8 --- /dev/null +++ b/test/pending/pos/t7234b.scala @@ -0,0 +1,20 @@ +trait Main { + trait A { + type B + def b: B + } + trait C { + def c(a: A, x: Int = 0)(b: => a.B, bs: a.B*) + def d(a: A = null, x: Int = 0)(b1: => a.B = a.b, b2: a.B = a.b) + } + def c: C + def ok(a: A)(b: a.B) = c.c(a, 42)(b) + def fail(a: A)(b: a.B) = c.c(a)(b) + def fail2(a: A)(b: a.B) = c.c(a)(b, b) + def fail3(a: A)(b: a.B) = c.c(a)(b, Seq[a.B](b): _*) + + def fail4(a: A)(b: a.B) = c.d(a)() + def fail5(a: A)(b: a.B) = c.d(a)(b1 = a.b) + def fail6(a: A)(b: a.B) = c.d(a)(b2 = a.b) + def fail7(a: A)(b: a.B) = c.d()() +} -- cgit v1.2.3