@@ -2195,7 +2195,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2195
2195
}
2196
2196
val pat1 = indexPattern(tree).transform(pat)
2197
2197
val guard1 = typedExpr(tree.guard, defn.BooleanType )
2198
- var body1 = ensureNoLocalRefs(typedExpr(tree.body, pt1), pt1, ctx.scope.toList)
2198
+ var body1 = ensureNoLocalRefs(
2199
+ typedExpr(tree.body, pt1)(using ctx.addNotNullInfo(guard1.notNullInfoIf(true ))),
2200
+ pt1, ctx.scope.toList)
2199
2201
if ctx.gadt.isNarrowing then
2200
2202
// Store GADT constraint to later retrieve it (in PostTyper, for now).
2201
2203
// GADT constraints are necessary to correctly check bounds of type app,
@@ -2206,7 +2208,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2206
2208
if pt1.isValueType then // insert a cast if body does not conform to expected type if we disregard gadt bounds
2207
2209
body1 = body1.ensureConforms(pt1)(using originalCtx)
2208
2210
val nni = pat1.notNullInfo
2209
- .seq(guard1.notNullInfoIf(false ).alt(guard1.notNullInfoIf( true ) ))
2211
+ .seq(guard1.notNullInfoIf(true ))
2210
2212
.seq(body1.notNullInfo)
2211
2213
assignType(cpy.CaseDef (tree)(pat1, guard1, body1), pat1, body1).withNotNullInfo(nni)
2212
2214
}
@@ -2328,7 +2330,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2328
2330
val cases2 = cases2x.asInstanceOf [List [CaseDef ]]
2329
2331
2330
2332
var nni = expr2.notNullInfo.retractedInfo
2331
- if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo).reduce(_.alt(_)))
2333
+ if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo.retractedInfo ).reduce(_.alt(_)))
2332
2334
val finalizer1 = typed(tree.finalizer, defn.UnitType )(using ctx.addNotNullInfo(nni))
2333
2335
nni = nni.seq(finalizer1.notNullInfo)
2334
2336
assignType(cpy.Try (tree)(expr2, cases2, finalizer1), expr2, cases2).withNotNullInfo(nni)
0 commit comments