Skip to content

Commit 000d952

Browse files
committed
Explicitly state empty package in extendedLocationText
[Cherry-picked a6ef339][modified]
1 parent 53ff1ec commit 000d952

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

+2
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
557557

558558
def extendedLocationText(sym: Symbol): Text =
559559
if (!sym.exists) ""
560+
else if isEmptyPrefix(sym.owner) then
561+
" in the empty package"
560562
else {
561563
def recur(ownr: Symbol, innerLocation: String): Text = {
562564
def nextOuter(innerKind: String): Text =

tests/neg/i18678.check

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:11:14 ------------------------------------------------------------
2+
11 |def u: Unit = () // error
3+
| ^^
4+
| Found: Unit
5+
| Required: Unit²
6+
|
7+
| where: Unit is a class in package scala
8+
| Unit² is a class in the empty package
9+
|
10+
| longer explanation available when compiling with `-explain`
11+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:12:20 ------------------------------------------------------------
12+
12 |def bool: Boolean = true // error
13+
| ^^^^
14+
| Found: (true : Boolean)
15+
| Required: Boolean²
16+
|
17+
| where: Boolean is a class in package scala
18+
| Boolean² is a class in the empty package
19+
|
20+
| longer explanation available when compiling with `-explain`
21+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:13:14 ------------------------------------------------------------
22+
13 |def b: Byte = 1: scala.Byte // error
23+
| ^^^^^^^^^^^^^
24+
| Found: Byte
25+
| Required: Byte²
26+
|
27+
| where: Byte is a class in package scala
28+
| Byte² is a class in the empty package
29+
|
30+
| longer explanation available when compiling with `-explain`
31+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:14:15 ------------------------------------------------------------
32+
14 |def s: Short = 2: scala.Short // error
33+
| ^^^^^^^^^^^^^^
34+
| Found: Short
35+
| Required: Short²
36+
|
37+
| where: Short is a class in package scala
38+
| Short² is a class in the empty package
39+
|
40+
| longer explanation available when compiling with `-explain`
41+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:15:13 ------------------------------------------------------------
42+
15 |def i: Int = 3 // error
43+
| ^
44+
| Found: (3 : Int)
45+
| Required: Int²
46+
|
47+
| where: Int is a class in package scala
48+
| Int² is a class in the empty package
49+
|
50+
| longer explanation available when compiling with `-explain`
51+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:16:14 ------------------------------------------------------------
52+
16 |def l: Long = 4L // error
53+
| ^^
54+
| Found: (4L : Long)
55+
| Required: Long²
56+
|
57+
| where: Long is a class in package scala
58+
| Long² is a class in the empty package
59+
|
60+
| longer explanation available when compiling with `-explain`
61+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:17:15 ------------------------------------------------------------
62+
17 |def f: Float = 5.6 // error
63+
| ^^^
64+
| Found: (5.6d : Double)
65+
| Required: Float
66+
|
67+
| longer explanation available when compiling with `-explain`
68+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:18:16 ------------------------------------------------------------
69+
18 |def d: Double = 6.7d // error
70+
| ^^^^
71+
| Found: (6.7d : Double)
72+
| Required: Double²
73+
|
74+
| where: Double is a class in package scala
75+
| Double² is a class in the empty package
76+
|
77+
| longer explanation available when compiling with `-explain`
78+
-- [E007] Type Mismatch Error: tests/neg/i18678.scala:19:14 ------------------------------------------------------------
79+
19 |def c: Char = 'a' // error
80+
| ^^^
81+
| Found: ('a' : Char)
82+
| Required: Char²
83+
|
84+
| where: Char is a class in package scala
85+
| Char² is a class in the empty package
86+
|
87+
| longer explanation available when compiling with `-explain`

tests/neg/i18678.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Unit
2+
class Boolean
3+
class Byte
4+
class Short
5+
class Int
6+
class Long
7+
class Double
8+
class Float
9+
class Char
10+
11+
def u: Unit = () // error
12+
def bool: Boolean = true // error
13+
def b: Byte = 1: scala.Byte // error
14+
def s: Short = 2: scala.Short // error
15+
def i: Int = 3 // error
16+
def l: Long = 4L // error
17+
def f: Float = 5.6 // error
18+
def d: Double = 6.7d // error
19+
def c: Char = 'a' // error

0 commit comments

Comments
 (0)