Skip to content

Commit 309034e

Browse files
committed
Small cleanup
1 parent 134c015 commit 309034e

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
@@ -1237,15 +1237,11 @@ object desugar {
12371237
name -> ctxBounds
12381238
}.flatMap { case (name, ctxBounds) =>
12391239
ctxBounds.map { ctxBound =>
1240-
idx = idx + 1
1241-
ctxBound match
1242-
case ctxBound @ ContextBoundTypeTree(tycon, paramName, ownName) =>
1243-
if tree.isTerm then
1244-
ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given)
1245-
else
1246-
ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType
1247-
case _ =>
1248-
makeSyntheticParameter(idx, ctxBound).withAddedFlags(Given)
1240+
val ContextBoundTypeTree(tycon, paramName, ownName) = ctxBound: @unchecked
1241+
if tree.isTerm then
1242+
ValDef(ownName, ctxBound, EmptyTree).withFlags(TermParam | Given)
1243+
else
1244+
ContextBoundTypeTree(tycon, paramName, EmptyTermName) // this has to be handled in Typer#typedFunctionType
12491245
}
12501246
}
12511247
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)