Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperFKorban committed Nov 14, 2024
1 parent 134c015 commit 309034e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 5 additions & 9 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/contextbounds-for-poly-functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 309034e

Please sign in to comment.