From 44af0d6352c91baf6da98fb5fe3f831b6745faed Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Tue, 24 Sep 2024 16:17:26 +0200 Subject: [PATCH] Fix pickling issue --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- tests/pos/contextbounds-for-poly-functions.scala | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index ab7e9870e7db..035fd03fde2c 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1216,7 +1216,7 @@ object desugar { val PolyFunction(tparams: List[untpd.TypeDef] @unchecked, fun @ Function(vparamTypes, res)) = tree: @unchecked val newTParams = tparams.mapConserve { case td @ TypeDef(name, cb @ ContextBounds(bounds, ctxBounds)) => - TypeDef(name, ContextBounds(bounds, List.empty)) + cpy.TypeDef(td)(name, bounds) case t => t } var idx = 0 diff --git a/tests/pos/contextbounds-for-poly-functions.scala b/tests/pos/contextbounds-for-poly-functions.scala index 90bd01ce6b6d..6a3ec9935a65 100644 --- a/tests/pos/contextbounds-for-poly-functions.scala +++ b/tests/pos/contextbounds-for-poly-functions.scala @@ -5,10 +5,11 @@ import scala.language.future trait Ord[X]: def compare(x: X, y: X): Int -// val less1 = [X: Ord] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0 +val less1 = [X: Ord] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0 -// val less2 = [X: Ord as ord] => (x: X, y: X) => ord.compare(x, y) < 0 +val less2 = [X: Ord as ord] => (x: X, y: X) => ord.compare(x, y) < 0 +type CtxFunctionRef = Ord[Int] ?=> Boolean type ComparerRef = [X] => (x: X, y: X) => Ord[X] ?=> Boolean type Comparer = [X: Ord] => (x: X, y: X) => Boolean val less3: Comparer = [X: Ord as ord] => (x: X, y: X) => ord.compare(x, y) < 0