8000 Make typecheckExpr a shorthand for typecheckExpect(AnyType) · scala-js/scala-js@eb1f9ae · GitHub
[go: up one dir, main page]

Skip to content

Commit eb1f9ae

Browse files
gzm0sjrd
authored andcommitted
Make typecheckExpr a shorthand for typecheckExpect(AnyType)
This will move errors to the containing trees, rather than the checked trees itself. This makes sense: Whether or not a tree is in expression position is a property of the usage, not the tree itself.
1 parent f22a6b4 commit eb1f9ae

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

linker/shared/src/main/scala/org/scalajs/linker/checker/IRChecker.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,13 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {
615615
}
616616
}
617617

618-
private def typecheckExpr(tree: Tree, env: Env): Unit = {
619-
implicit val ctx = ErrorContext(tree)
620-
if (tree.tpe == NoType)
621-
reportError(i"Expression tree has type NoType")
622-
typecheck(tree, env)
618+
private def typecheckExpr(tree: Tree, env: Env)(
619+
implicit ctx: ErrorContext): Unit = {
620+
typecheckExpect(tree, env, AnyType)
623621
}
624622

625-
private def typecheckExprOrSpread(tree: TreeOrJSSpread, env: Env): Unit = {
623+
private def typecheckExprOrSpread(tree: TreeOrJSSpread, env: Env)(
624+
implicit ctx: ErrorContext): Unit = {
626625
tree match {
627626
case JSSpread(items) =>
628627
typecheckExpr(items, env)

linker/shared/src/test/scala/org/scalajs/linker/IRCheckerTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class IRCheckerTest {
211211

212212
for (log <- testLinkIRErrors(classDefs, MainTestModuleInitializers)) yield {
213213
log.assertContainsError(
214-
"Expression tree has type NoType")
214+
"any expected but <notype> found for tree of type org.scalajs.ir.Trees$Skip")
215215
}
216216
}
217217

@@ -239,7 +239,7 @@ class IRCheckerTest {
239239

240240
for (log <- testLinkIRErrors(classDefs, MainTestModuleInitializers)) yield {
241241
log.assertContainsError(
242-
"Expression tree has type NoType")
242+
"any expected but <notype> found for tree of type org.scalajs.ir.Trees$VarDef")
243243
}
244244
}
245245

0 commit comments

Comments
 (0)
0