From 309034e5579dd5dcf2667d5cd096c1067681b724 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Wed, 25 Sep 2024 09:43:30 +0200 Subject: [PATCH] Small cleanup --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 14 +++++--------- tests/pos/contextbounds-for-poly-functions.scala | 2 ++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 12c237701d62..d37af4aaedae 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1237,15 +1237,11 @@ object desugar { name -> ctxBounds }.flatMap { case (name, ctxBounds) => ctxBounds.map { ctxBound => - idx = idx + 1 - ctxBound match - case ctxBound @ ContextBoundTypeTree(tycon, paramName, ownName) => - if tree.isTerm then - ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given) - else - ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType - case _ => - makeSyntheticParameter(idx, ctxBound).withAddedFlags(Given) + val ContextBoundTypeTree(tycon, paramName, ownName) = ctxBound: @unchecked + if tree.isTerm then + ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given) + else + ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType } } val contextFunctionResult = diff --git a/tests/pos/contextbounds-for-poly-functions.scala b/tests/pos/contextbounds-for-poly-functions.scala index c293fd0d9780..7da7405c9225 100644 --- a/tests/pos/contextbounds-for-poly-functions.scala +++ b/tests/pos/contextbounds-for-poly-functions.scala @@ -16,3 +16,5 @@ val less3: Comparer = [X: Ord as ord] => (x: X, y: X) => ord.compare(x, y) < 0 // type Cmp[X] = (x: X, y: X) => Boolean // type Comparer2 = [X: Ord] => Cmp[X] // val less4: Comparer2 = [X: Ord] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0 + +val less5 = [X: [X] =>> Ord[X]] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0 \ No newline at end of file