@@ -2210,7 +2210,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2210
2210
}
2211
2211
val pat1 = indexPattern(tree).transform(pat)
2212
2212
val guard1 = typedExpr(tree.guard, defn.BooleanType )
2213
- var body1 = ensureNoLocalRefs(typedExpr(tree.body, pt1), pt1, ctx.scope.toList)
2213
+ var body1 = ensureNoLocalRefs(
2214
+ typedExpr(tree.body, pt1)(using ctx.addNotNullInfo(guard1.notNullInfoIf(true ))),
2215
+ pt1, ctx.scope.toList)
2214
2216
if ctx.gadt.isNarrowing then
2215
2217
// Store GADT constraint to later retrieve it (in PostTyper, for now).
2216
2218
// GADT constraints are necessary to correctly check bounds of type app,
@@ -2221,7 +2223,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2221
2223
if pt1.isValueType then // insert a cast if body does not conform to expected type if we disregard gadt bounds
2222
2224
body1 = body1.ensureConforms(pt1)(using originalCtx)
2223
2225
val nni = pat1.notNullInfo
2224
- .seq(guard1.notNullInfoIf(false ).alt(guard1.notNullInfoIf( true ) ))
2226
+ .seq(guard1.notNullInfoIf(true ))
2225
2227
.seq(body1.notNullInfo)
2226
2228
assignType(cpy.CaseDef (tree)(pat1, guard1, body1), pat1, body1).withNotNullInfo(nni)
2227
2229
}
@@ -2343,7 +2345,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2343
2345
val cases2 = cases2x.asInstanceOf [List [CaseDef ]]
2344
2346
2345
2347
var nni = expr2.notNullInfo.retractedInfo
2346
- if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo).reduce(_.alt(_)))
2348
+ if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo.retractedInfo ).reduce(_.alt(_)))
2347
2349
val finalizer1 = typed(tree.finalizer, defn.UnitType )(using ctx.addNotNullInfo(nni))
2348
2350
nni = nni.seq(finalizer1.notNullInfo)
2349
2351
assignType(cpy.Try (tree)(expr2, cases2, finalizer1), expr2, cases2).withNotNullInfo(nni)
0 commit comments