Skip to content

Commit 571ae8d

Browse files
committed
Small cleanup
1 parent 054251e commit 571ae8d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,15 +1225,11 @@ object desugar {
12251225
name -> ctxBounds
12261226
}.flatMap { case (name, ctxBounds) =>
12271227
ctxBounds.map { ctxBound =>
1228-
idx = idx + 1
1229-
ctxBound match
1230-
case ctxBound @ ContextBoundTypeTree(tycon, paramName, ownName) =>
1231-
if tree.isTerm then
1232-
ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given)
1233-
else
1234-
ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType
1235-
case _ =>
1236-
makeSyntheticParameter(idx, ctxBound).withAddedFlags(Given)
1228+
val ContextBoundTypeTree(tycon, paramName, ownName) = ctxBound: @unchecked
1229+
if tree.isTerm then
1230+
ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given)
1231+
else
1232+
ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType
12371233
}
12381234
}
12391235
val contextFunctionResult =

tests/pos/contextbounds-for-poly-functions.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ val less3: Comparer = [X: Ord as ord] => (x: X, y: X) => ord.compare(x, y) < 0
1616
// type Cmp[X] = (x: X, y: X) => Boolean
1717
// type Comparer2 = [X: Ord] => Cmp[X]
1818
// val less4: Comparer2 = [X: Ord] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0
19+
20+
val less5 = [X: [X] =>> Ord[X]] => (x: X, y: X) => summon[Ord[X]].compare(x, y) < 0

0 commit comments

Comments
 (0)