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

Explicitly state empty package in extendedLocationText #18748

Merged
merged 1 commit into from
Oct 24, 2023
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: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ class PlainPrinter(_ctx: Context) extends Printer {

def extendedLocationText(sym: Symbol): Text =
if (!sym.exists) ""
else if isEmptyPrefix(sym.owner) then
" in the empty package"
else {
def recur(ownr: Symbol, innerLocation: String): Text = {
def nextOuter(innerKind: String): Text =
Expand Down
87 changes: 87 additions & 0 deletions tests/neg/i18678.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:11:14 ------------------------------------------------------------
11 |def u: Unit = () // error
| ^^
| Found: Unit
| Required: Unit²
|
| where: Unit is a class in package scala
| Unit² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:12:20 ------------------------------------------------------------
12 |def bool: Boolean = true // error
| ^^^^
| Found: (true : Boolean)
| Required: Boolean²
|
| where: Boolean is a class in package scala
| Boolean² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:13:14 ------------------------------------------------------------
13 |def b: Byte = 1: scala.Byte // error
| ^^^^^^^^^^^^^
| Found: Byte
| Required: Byte²
|
| where: Byte is a class in package scala
| Byte² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:14:15 ------------------------------------------------------------
14 |def s: Short = 2: scala.Short // error
| ^^^^^^^^^^^^^^
| Found: Short
| Required: Short²
|
| where: Short is a class in package scala
| Short² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:15:13 ------------------------------------------------------------
15 |def i: Int = 3 // error
| ^
| Found: (3 : Int)
| Required: Int²
|
| where: Int is a class in package scala
| Int² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:16:14 ------------------------------------------------------------
16 |def l: Long = 4L // error
| ^^
| Found: (4L : Long)
| Required: Long²
|
| where: Long is a class in package scala
| Long² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:17:15 ------------------------------------------------------------
17 |def f: Float = 5.6 // error
| ^^^
| Found: (5.6d : Double)
| Required: Float
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:18:16 ------------------------------------------------------------
18 |def d: Double = 6.7d // error
| ^^^^
| Found: (6.7d : Double)
| Required: Double²
|
| where: Double is a class in package scala
| Double² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:19:14 ------------------------------------------------------------
19 |def c: Char = 'a' // error
| ^^^
| Found: ('a' : Char)
| Required: Char²
|
| where: Char is a class in package scala
| Char² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
19 changes: 19 additions & 0 deletions tests/neg/i18678.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Unit
class Boolean
class Byte
class Short
class Int
class Long
class Double
class Float
class Char

def u: Unit = () // error
def bool: Boolean = true // error
def b: Byte = 1: scala.Byte // error
def s: Short = 2: scala.Short // error
def i: Int = 3 // error
def l: Long = 4L // error
def f: Float = 5.6 // error
def d: Double = 6.7d // error
def c: Char = 'a' // error
4 changes: 2 additions & 2 deletions tests/neg/lambda-rename.check
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| Found: HK[[Y] =>> Foo[(X, X)]]
| Required: HK[[X²] =>> Foo[(X², X²)]]
|
| where: X is a class
| where: X is a class in the empty package
| X² is a type variable
|
| longer explanation available when compiling with `-explain`
Expand All @@ -29,6 +29,6 @@
| Required: HK[[Y] =>> Foo[(X², X²)]]
|
| where: X is a type variable
| X² is a class
| X² is a class in the empty package
|
| longer explanation available when compiling with `-explain`
Loading