Skip to content

Commit 4a4ad17

Browse files
Restructure MatchType#reduced try catch
1 parent d7b69a3 commit 4a4ad17

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5171,20 +5171,19 @@ object Types extends TypeUtils {
51715171
record("MatchType.reduce computed")
51725172
if (myReduced != null) record("MatchType.reduce cache miss")
51735173
if !isUpToDate then setReductionContext()
5174-
myReduced =
5175-
trace(i"reduce match type $this $hashCode", matchTypes, show = true):
5174+
val saved = ctx.typerState.snapshot()
5175+
try
5176+
myReduced = trace(i"reduce match type $this $hashCode", matchTypes, show = true):
51765177
withMode(Mode.Type):
51775178
TypeComparer.reduceMatchWith: cmp =>
5178-
val saved = ctx.typerState.snapshot()
5179-
try
5180-
cmp.matchCases(scrutinee.normalized, cases.map(MatchTypeCaseSpec.analyze))
5181-
catch case ex: Throwable =>
5182-
myReduced = NoType
5183-
handleRecursive("reduce type ", i"$scrutinee match ...", ex)
5184-
finally
5185-
ctx.typerState.resetTo(saved)
5186-
// this drops caseLambdas in constraint and undoes any typevar
5187-
// instantiations during matchtype reduction
5179+
cmp.matchCases(scrutinee.normalized, cases.map(MatchTypeCaseSpec.analyze))
5180+
catch case ex: Throwable =>
5181+
myReduced = NoType
5182+
handleRecursive("reduce type ", i"$scrutinee match ...", ex)
5183+
finally
5184+
ctx.typerState.resetTo(saved)
5185+
// this drops caseLambdas in constraint and undoes any typevar
5186+
// instantiations during matchtype reduction
51885187

51895188
//else println(i"no change for $this $hashCode / $myReduced")
51905189
myReduced.nn

0 commit comments

Comments
 (0)