Skip to content

Commit 8296e32

Browse files
paulpadriaanm
authored andcommitted
Selective dealiasing when printing errors.
*** Important note for busy commit log skimmers *** Symbol method "fullName" has been trying to serve the dual role of "how to print a symbol" and "how to find a class file." It cannot serve both these roles simultaneously, primarily because of package objects but other little things as well. Since in the majority of situations we want the one which corresponds to the idealized scala world, not the grubby bytecode, I went with that for fullName. When you require the path to a class (e.g. you are calling Class.forName) you should use javaClassName. package foo { package object bar { class Bippy } } If sym is Bippy's symbol, then sym.fullName == foo.bar.Bippy sym.javaClassName == foo.bar.package.Bippy *** End important note *** There are many situations where we (until now) forewent revealing everything we knew about a type mismatch. For instance, this isn't very helpful of scalac (at least in those more common cases where you didn't define type X on the previous repl line.) scala> type X = Int defined type alias X scala> def f(x: X): Byte = x <console>:8: error: type mismatch; found : X required: Byte def f(x: X): Byte = x ^ Now it says: found : X (which expands to) Int required: Byte def f(x: X): Byte = x ^ In addition I rearchitected a number of methods involving: - finding a symbol's owner - calculating a symbol's name - determining whether to print a prefix No review.
1 parent 22738dd commit 8296e32

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/files/jvm/interpreter.check

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ four: anotherint = 4
3535

3636
scala> val bogus: anotherint = "hello"
3737
<console>:8: error: type mismatch;
38-
found : java.lang.String("hello")
38+
found : String("hello")
3939
required: anotherint
40+
(which expands to) Int
4041
val bogus: anotherint = "hello"
4142
^
4243

@@ -73,7 +74,7 @@ fish: S = fish
7374
scala> // Test that arrays pretty print nicely.
7475

7576
scala> val arr = Array("What's", "up", "doc?")
76-
arr: Array[java.lang.String] = Array(What's, up, doc?)
77+
arr: Array[String] = Array(What's, up, doc?)
7778

7879
scala> // Test that arrays pretty print nicely, even when we give them type Any
7980

@@ -263,7 +264,7 @@ scala> xs filter (_ == 2)
263264
res4: Array[_] = Array(2)
264265

265266
scala> xs map (_ => "abc")
266-
res5: Array[java.lang.String] = Array(abc, abc)
267+
res5: Array[String] = Array(abc, abc)
267268

268269
scala> xs map (x => x)
269270
res6: scala.collection.mutable.ArraySeq[_] = ArraySeq(1, 2)
@@ -322,7 +323,7 @@ scala> """
322323
hello
323324
there
324325
"""
325-
res9: java.lang.String =
326+
res9: String =
326327
"
327328
hello
328329
there
@@ -368,7 +369,7 @@ scala>
368369
scala>
369370
plusOne: (x: Int)Int
370371
res0: Int = 6
371-
res1: java.lang.String = after reset
372+
res1: String = after reset
372373
<console>:8: error: not found: value plusOne
373374
plusOne(5) // should be undefined now
374375
^

0 commit comments

Comments
 (0)