Skip to content

Commit aaf2dc7

Browse files
Remove normalization of arguments in AppliedType#tryNormalize
Delay their normalization until it is needed. Improves MatchTypeTraces as a side effect. It appears to have been added to avoid some separate issue, which seems to have been fixed. It is no longer needed at all since the previous fix with constFolding.
1 parent c45bcf7 commit aaf2dc7

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4658,7 +4658,7 @@ object Types extends TypeUtils {
46584658
case AliasingBounds(alias) if isMatchAlias =>
46594659
trace(i"normalize $this", typr, show = true) {
46604660
MatchTypeTrace.recurseWith(this) {
4661-
alias.applyIfParameterized(args.map(_.normalized)).tryNormalize
4661+
alias.applyIfParameterized(args).tryNormalize
46624662
/* `applyIfParameterized` may reduce several HKTypeLambda applications
46634663
* before the underlying MatchType is reached.
46644664
* Even if they do not involve any match type normalizations yet,

tests/neg/i12049d.check

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i12049d.scala:14:52 -----------------------------------------------------------
2+
14 |val x: M[NotRelevant[Nothing], Relevant[Nothing]] = 2 // error
3+
| ^
4+
| Found: (2 : Int)
5+
| Required: M[NotRelevant[Nothing], Relevant[Nothing]]
6+
|
7+
| Note: a match type could not be fully reduced:
8+
|
9+
| trying to reduce M[NotRelevant[Nothing], Relevant[Nothing]]
10+
| trying to reduce Relevant[Nothing]
11+
| failed since selector Nothing
12+
| is uninhabited (there are no values of that type).
13+
|
14+
| longer explanation available when compiling with `-explain`

tests/neg/i12049d.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
trait A
3+
trait B
4+
5+
type M[X, Y] = Y match
6+
case A => Int
7+
case B => String
8+
9+
type Relevant[Z] = Z match
10+
case A => B
11+
type NotRelevant[Z] = Z match
12+
case B => A
13+
14+
val x: M[NotRelevant[Nothing], Relevant[Nothing]] = 2 // error

0 commit comments

Comments
 (0)