Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible crash in Desugar #19567

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1602,15 +1602,17 @@ object desugar {
* skipping elements that are not convertible.
*/
def patternsToParams(elems: List[Tree])(using Context): List[ValDef] =
def toParam(elem: Tree, tpt: Tree): Tree =
def toParam(elem: Tree, tpt: Tree, span: Span): Tree =
elem match
case Annotated(elem1, _) => toParam(elem1, tpt)
case Typed(elem1, tpt1) => toParam(elem1, tpt1)
case Ident(id: TermName) => ValDef(id, tpt, EmptyTree).withFlags(Param)
case Annotated(elem1, _) => toParam(elem1, tpt, span)
case Typed(elem1, tpt1) => toParam(elem1, tpt1, span)
case Ident(id: TermName) => ValDef(id, tpt, EmptyTree).withFlags(Param).withSpan(span)
case _ => EmptyTree
elems.map(param => toParam(param, TypeTree()).withSpan(param.span)).collect {
case vd: ValDef => vd
}
elems
.map: param =>
toParam(param, TypeTree(), param.span)
.collect:
case vd: ValDef => vd

def makeContextualFunction(formals: List[Tree], paramNamesOrNil: List[TermName], body: Tree, erasedParams: List[Boolean])(using Context): Function = {
val mods = Given
Expand Down
Loading