From 44c93285d60d3c6b7c6288707ad58cdaf3387151 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 5 Nov 2019 22:48:39 +0100 Subject: [PATCH] Fix #7472: Pass correct context in Child.later There was an ovsersight when converting to IFTs. --- compiler/src/dotty/tools/dotc/core/Annotations.scala | 4 ++-- compiler/test-resources/repl/7472 | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 compiler/test-resources/repl/7472 diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 9706034a385b..cc94f14988ba 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -154,12 +154,12 @@ object Annotations { /** A deferred annotation to the result of a given child computation */ def later(delayedSym: (given Context) => Symbol, span: Span)(implicit ctx: Context): Annotation = { - def makeChildLater(implicit ctx: Context) = { + def makeChildLater(given ctx: Context) = { val sym = delayedSym New(defn.ChildAnnot.typeRef.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil) .withSpan(span) } - deferred(defn.ChildAnnot)(makeChildLater(ctx)) + deferred(defn.ChildAnnot)(makeChildLater) } /** A regular, non-deferred Child annotation */ diff --git a/compiler/test-resources/repl/7472 b/compiler/test-resources/repl/7472 new file mode 100644 index 000000000000..d0f442ae7cf1 --- /dev/null +++ b/compiler/test-resources/repl/7472 @@ -0,0 +1,4 @@ +scala> val list = List(1, 2, 3) +val list: List[Int] = List(1, 2, 3) +scala> list.foldLeft(List.empty[Int]){ case (acc, n) => n :: acc } +val res0: List[Int] = List(3, 2, 1)