Skip to content

Commit

Permalink
chore: normalise the types for Type Mismatch Error E007
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Jan 10, 2025
1 parent 0ecc057 commit dd6b6db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tre
val (found2, expected2) =
if (found1 frozen_<:< expected1) || reported.fbounded then (found, expected)
else (found1, expected1)
val (foundStr, expectedStr) = Formatting.typeDiff(found2, expected2)
val (foundStr, expectedStr) = Formatting.typeDiff(found2.normalized, expected2.normalized)
i"""|Found: $foundStr
|Required: $expectedStr${reported.notes}"""
end msg
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i22333.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- [E007] Type Mismatch Error: tests/neg/i22333.scala:5:33 -------------------------------------------------------------
5 |val _ = Container[(1,2,3)].guard((6, 8): Tuple.Tail[(5, 6, 8)]) // error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Found: ((6 : Int), (8 : Int))
| Required: ((2 : Int), (3 : Int))
|
| longer explanation available when compiling with `-explain`
5 changes: 5 additions & 0 deletions tests/neg/i22333.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

class Container[Rs <: Tuple]:
def guard(a: Tuple.Tail[Rs]): Unit = ()

val _ = Container[(1,2,3)].guard((6, 8): Tuple.Tail[(5, 6, 8)]) // error

0 comments on commit dd6b6db

Please sign in to comment.