From 4e8e201be4227ec1b13a28d50505ba71f2979454 Mon Sep 17 00:00:00 2001 From: odersky Date: Sat, 11 Feb 2023 19:48:39 +0100 Subject: [PATCH 1/2] PolyFunction desugar: Don't copy type flags to parameter Fixes #16871 Signed-off-by: odersky --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- tests/pos/i16871.scala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i16871.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 2cfd292fd6dd..85dd5e6665c6 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1732,7 +1732,7 @@ object desugar { val applyVParams = vargs.zipWithIndex.map { case (p: ValDef, _) => p.withAddedFlags(mods.flags) - case (p, n) => makeSyntheticParameter(n + 1, p).withAddedFlags(mods.flags) + case (p, n) => makeSyntheticParameter(n + 1, p).withAddedFlags(mods.flags.toTermFlags) } RefinedTypeTree(polyFunctionTpt, List( DefDef(nme.apply, applyTParams :: applyVParams :: Nil, res, EmptyTree).withFlags(Synthetic) diff --git a/tests/pos/i16871.scala b/tests/pos/i16871.scala new file mode 100644 index 000000000000..3251a7135346 --- /dev/null +++ b/tests/pos/i16871.scala @@ -0,0 +1,3 @@ +import scala.language.experimental.captureChecking + +val f: [X] => Int => Int = [X] => (x: Int) => x \ No newline at end of file From bdd56dd7073cc87293f96fee23a980140276cf3b Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 12 Feb 2023 10:11:49 +0100 Subject: [PATCH 2/2] Move test to cc directory This avoids a pickler test failure, since under pickling we don't see language imports in source when we print the trees for comparisons. --- tests/{pos => pos-custom-args/captures}/i16871.scala | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{pos => pos-custom-args/captures}/i16871.scala (100%) diff --git a/tests/pos/i16871.scala b/tests/pos-custom-args/captures/i16871.scala similarity index 100% rename from tests/pos/i16871.scala rename to tests/pos-custom-args/captures/i16871.scala