Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalise the types for Type Mismatch Error (E007) #22337

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading