File tree 2 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/transform 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -32,14 +32,20 @@ class PatternMatcher extends MiniPhase {
32
32
override def transformMatch (tree : Match )(implicit ctx : Context ): Tree =
33
33
if (tree.isInstanceOf [InlineMatch ]) tree
34
34
else {
35
- val translated = new Translator (tree.tpe, this ).translateMatch(tree)
35
+ // Widen termrefs with underlying `=> T` types. Otherwise ElimByName will produce
36
+ // inconsistent types. See i7743.scala.
37
+ // Question: Does this need to be done more systematically, not just for pattern matches?
38
+ val matchType = tree.tpe.widenSingleton match
39
+ case ExprType (rt) => rt
40
+ case rt => tree.tpe
41
+ val translated = new Translator (matchType, this ).translateMatch(tree)
36
42
37
43
// check exhaustivity and unreachability
38
44
val engine = new patmat.SpaceEngine
39
45
engine.checkExhaustivity(tree)
40
46
engine.checkRedundancy(tree)
41
47
42
- translated.ensureConforms(tree.tpe )
48
+ translated.ensureConforms(matchType )
43
49
}
44
50
}
45
51
Original file line number Diff line number Diff line change
1
+ def foo (x : => String ) = 1 match {
2
+ case _ => x
3
+ }
You can’t perform that action at this time.
0 commit comments