Skip to content

Commit 58765e6

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 8a1c768 commit 58765e6

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

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

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

tests/neg/i12049d.check

Lines changed: 14 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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)