8000 IR checker cleanups by gzm0 · Pull Request #4494 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

IR checker cleanups #4494

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

Merged
merged 2 commits into from
May 31, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {
case VarDef(ident, _, vtpe, mutable, rhs) =>
checkDeclareLocalVar(ident)
typecheckExpect(rhs, env, vtpe)
env.withLocal(LocalDef(ident.name, vtpe, mutable)(tree.pos))
env.withLocal(LocalDef(ident.name, vtpe, mutable))

case Skip() =>
env
Expand Down Expand Up @@ -696,15 +696,13 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {

case ForIn(obj, keyVar, _, body) =>
typecheckExpr(obj, env)
val bodyEnv =
env.withLocal(LocalDef(keyVar.name, AnyType, false)(keyVar.pos))
val bodyEnv = env.withLocal(LocalDef(keyVar.name, AnyType, false))
typecheckStat(body, bodyEnv)
env

case TryCatch(block, errVar, _, handler) =>
typecheckStat(block, env)
val handlerEnv =
env.withLocal(LocalDef(errVar.name, AnyType, false)(errVar.pos))
val handlerEnv = env.withLocal(LocalDef(errVar.name, AnyType, false))
typecheckStat(handler, handlerEnv)
env

Expand Down Expand Up @@ -811,7 +809,7 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {
val tpe = tree.tpe
typecheckExpect(block, env, tpe)
val handlerEnv =
env.withLocal(LocalDef(errVar.name, AnyType, false)(errVar.pos))
env.withLocal(LocalDef(errVar.name, AnyType, false))
typecheckExpect(handler, handlerEnv, tpe)

case TryFinally(block, finalizer) =>
Expand Down Expand Up @@ -1372,7 +1370,7 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {
def withThis(thisTpe: Type): Env =
new Env(thisTpe, this.locals, this.returnTypes, this.inConstructorOf)

def withLocal(localDef: LocalDef)(implicit ctx: ErrorContext): Env = {
def withLocal(localDef: LocalDef): Env = {
new Env(thisTpe, locals + (localDef.name -> localDef), returnTypes,
this.inConstructorOf)
}
Expand All @@ -1390,7 +1388,7 @@ private final class IRChecker(unit: LinkingUnit, logger: Logger) {
val allParams = jsClassCaptures.getOrElse(Nil) ::: params
val paramLocalDefs =
for (p @ ParamDef(ident, _, tpe, mutable) <- allParams)
yield ident.name -> LocalDef(ident.name, tpe, mutable)(p.pos)
yield ident.name -> LocalDef(ident.name, tpe, mutable)
new Env(thisType, paramLocalDefs.toMap, Map.empty, inConstructorOf)
}
}
Expand Down Expand Up @@ -1514,7 +1512,5 @@ object IRChecker {
new ErrorContext(linkedClass)
}

private final case class LocalDef(name: LocalName, tpe: Type,
mutable: Boolean)(
val pos: Position)
private final case class LocalDef(name: LocalName, tpe: Type, mutable: Boolean)
}
0