Skip to content

Fix #7195: Use superscripts instead of ' for duplicated types #7511

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

Merged
merged 1 commit into from
Nov 7, 2019
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
17 changes: 16 additions & 1 deletion compiler/src/dotty/tools/dotc/printing/Formatting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,22 @@ object Formatting {
alts = entry :: existing
update(key, alts)
}
str + "'" * (alts.length - 1)
val suffix = alts.length match {
case 1 => ""
case n => n.toString.toCharArray.map {
case '0' => '⁰'
case '1' => '¹'
case '2' => '²'
case '3' => '³'
case '4' => '⁴'
case '5' => '⁵'
case '6' => '⁶'
case '7' => '⁷'
case '8' => '⁸'
case '9' => '⁹'
}.mkString
}
str + suffix
}
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/test-resources/repl/errmsgs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var
1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; }
| ^
|Found: C.this.T(C.this.x)
|Required: T'
|Required: T²
|
|where: T is a type in class C
| T' is a type in the initializer of value s which is an alias of String
| T² is a type in the initializer of value s which is an alias of String
1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; }
| ^
|Found: T(y)
|Required: T'
|Required: T²
|
|where: T is a type in the initializer of value s which is an alias of String
| T' is a type in method f which is an alias of Int
| T² is a type in method f which is an alias of Int
scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
1 | class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
| ^^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i7195.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- [E007] Type Mismatch Error: tests/neg/i7195.scala:10:8 --------------------------------------------------------------
10 | A.foo(??? : T) // error
| ^^^^^^^
| Found: B.T
| Required: A.T²
|
| where: T is a type in object B
| T² is a type in object A
13 changes: 13 additions & 0 deletions tests/neg/i7195.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object A {
type T

def foo(a: T) = ()

}

object B {
type T
A.foo(??? : T) // error


}