@@ -1929,7 +1929,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1929
1929
}
1930
1930
val pat1 = indexPattern(tree).transform(pat)
1931
1931
val guard1 = typedExpr(tree.guard, defn.BooleanType )
1932
- var body1 = ensureNoLocalRefs(typedExpr(tree.body, pt1), pt1, ctx.scope.toList)
1932
+ var body1 = ensureNoLocalRefs(
1933
+ typedExpr(tree.body, pt1)(using ctx.addNotNullInfo(guard1.notNullInfoIf(true ))),
1934
+ pt1, ctx.scope.toList)
1933
1935
if ctx.gadt.isNarrowing then
1934
1936
// Store GADT constraint to later retrieve it (in PostTyper, for now).
1935
1937
// GADT constraints are necessary to correctly check bounds of type app,
@@ -1940,7 +1942,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1940
1942
if pt1.isValueType then // insert a cast if body does not conform to expected type if we disregard gadt bounds
1941
1943
body1 = body1.ensureConforms(pt1)(using originalCtx)
1942
1944
val nni = pat1.notNullInfo
1943
- .seq(guard1.notNullInfoIf(false ).alt(guard1.notNullInfoIf( true ) ))
1945
+ .seq(guard1.notNullInfoIf(true ))
1944
1946
.seq(body1.notNullInfo)
1945
1947
assignType(cpy.CaseDef (tree)(pat1, guard1, body1), pat1, body1).withNotNullInfo(nni)
1946
1948
}
@@ -2062,7 +2064,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2062
2064
val cases2 = cases2x.asInstanceOf [List [CaseDef ]]
2063
2065
2064
2066
var nni = expr2.notNullInfo.retractedInfo
2065
- if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo).reduce(_.alt(_)))
2067
+ if cases2.nonEmpty then nni = nni.seq(cases2.map(_.notNullInfo.retractedInfo ).reduce(_.alt(_)))
2066
2068
val finalizer1 = typed(tree.finalizer, defn.UnitType )(using ctx.addNotNullInfo(nni))
2067
2069
nni = nni.seq(finalizer1.notNullInfo)
2068
2070
assignType(cpy.Try (tree)(expr2, cases2, finalizer1), expr2, cases2).withNotNullInfo(nni)
0 commit comments