Skip to content

Commit a094367

Browse files
wip Abstract away the list construction logic
1 parent d0b2604 commit a094367

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,5 +1371,18 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13711371
*/
13721372
def repeated(trees: List[Tree], tpt: Tree)(given ctx: Context): Tree =
13731373
ctx.typeAssigner.arrayToRepeated(JavaSeqLiteral(trees, tpt))
1374-
}
13751374

1375+
/** Create a tree representing a list containing all
1376+
* the elements of the argument list. A "list of tree to
1377+
* tree of list" conversion.
1378+
*
1379+
* @param trees the elements the list represented by
1380+
* the resulting tree should contain.
1381+
* @param tpe the type of the elements of the resulting list.
1382+
*
1383+
*/
1384+
def mkList(trees: List[Tree], tpe: Tree)(given Context): Tree =
1385+
ref(defn.ListModule).select(nme.apply)
1386+
.appliedToTypeTree(tpe)
1387+
.appliedToVarargs(trees, tpe)
1388+
}

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ object Inliner {
240240
private def packErrors(errors: List[(ErrorKind, Error)])(given Context): Tree =
241241
val individualErrors: List[Tree] = errors.map(packError)
242242
val errorTpt = ref(defn.CompiletimeTesting_ErrorClass)
243-
ref(defn.ListModule).select(nme.apply)
244-
.appliedToTypeTree(errorTpt)
245-
.appliedToVarargs(individualErrors, errorTpt)
243+
mkList(individualErrors, errorTpt)
246244

247245
/** Expand call to scala.compiletime.testing.typeChecks */
248246
def typeChecks(tree: Tree)(given Context): Tree =

0 commit comments

Comments
 (0)