diff --git a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala index c82fca91faa25..ff8633c65a372 100644 --- a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala +++ b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala @@ -345,8 +345,8 @@ object Shape extends ShapeImplicit { path: List1[AST.Ident], rename: Option[AST.Ident.Cons], isAll: Boolean, - onlyNames: Option[List1[AST.Ident.Cons]], - hidingNames: Option[List1[AST.Ident.Cons]] + onlyNames: Option[List1[AST.Ident]], + hidingNames: Option[List1[AST.Ident]] ) extends SpacelessAST[T] final case class Export[T]( path: List1[AST.Ident], @@ -2395,8 +2395,8 @@ object AST { path: List1[AST.Ident], rename: Option[AST.Ident.Cons], isAll: Boolean, - onlyNames: Option[List1[AST.Ident.Cons]], - hidingNames: Option[List1[AST.Ident.Cons]] + onlyNames: Option[List1[AST.Ident]], + hidingNames: Option[List1[AST.Ident]] ): Import = Shape.Import[AST](path, rename, isAll, onlyNames, hidingNames) def unapply(t: AST): Option[ @@ -2404,8 +2404,8 @@ object AST { List1[AST.Ident], Option[AST.Ident.Cons], Boolean, - Option[List1[AST.Ident.Cons]], - Option[List1[AST.Ident.Cons]] + Option[List1[AST.Ident]], + Option[List1[AST.Ident]] ) ] = Unapply[Import].run(t => diff --git a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Builtin.scala b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Builtin.scala index 33668cf74b7ac..d0d021e398db9 100644 --- a/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Builtin.scala +++ b/lib/scala/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Builtin.scala @@ -289,6 +289,11 @@ object Builtin { (name, rename) } + def consOrVar: PartialFunction[AST, AST.Ident] = { + case AST.Ident.Var.any(v) => v: AST.Ident + case AST.Ident.Cons.any(c) => c: AST.Ident + } + val itemsImport = { val all: Pattern = Var("all") val items = Pattern.SepList(Pattern.Cons() | Pattern.Var(), Opr(",")) @@ -305,13 +310,13 @@ object Builtin { case Match.Or(_, Left(hidden)) => val hiddenItems = hidden.toStream .map(_.wrapped) - .flatMap(AST.Ident.Cons.any.unapply) + .collect(consOrVar) (List1(hiddenItems), None) case Match.Or(_, Right(imported)) => val importedItems = imported.toStream .map(_.wrapped) - .flatMap(AST.Ident.Cons.any.unapply) + .collect(consOrVar) (None, List1(importedItems)) case _ => internalError } @@ -339,19 +344,13 @@ object Builtin { val hiddenItems = hidden.toStream .map(_.wrapped) .drop(2) - .collect { - case AST.Ident.Var.any(v) => v: AST.Ident - case AST.Ident.Cons.any(c) => c: AST.Ident - } + .collect(consOrVar) (List1(hiddenItems), None) case Match.Or(_, Right(imported)) => val importedItems = imported.toStream .map(_.wrapped) - .collect { - case AST.Ident.Var.any(v) => v: AST.Ident - case AST.Ident.Cons.any(c) => c: AST.Ident - } + .collect(consOrVar) (None, List1(importedItems)) case _ => internalError }