summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-03 01:28:04 +0000
committerPaul Phillips <paulp@improving.org>2011-10-03 01:28:04 +0000
commitbeadafa2d83a539dae8f969b9789f896346484ec (patch)
tree90c69a49397cdb59120d59307b843c54c8f68908 /src/compiler/scala/reflect/internal/Types.scala
parent55109d0d253c7e89660f1b61d17408648c0c53a4 (diff)
downloadscala-beadafa2d83a539dae8f969b9789f896346484ec.tar.gz
scala-beadafa2d83a539dae8f969b9789f896346484ec.tar.bz2
scala-beadafa2d83a539dae8f969b9789f896346484ec.zip
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.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 34c6570c2a..43168190a3 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -1157,7 +1157,7 @@ trait Types extends api.Types { self: SymbolTable =>
override def prefixString =
if (settings.debug.value) sym.nameString + ".this."
else if (sym.isAnonOrRefinementClass) "this."
- else if (sym.printWithoutPrefix) ""
+ else if (sym.isOmittablePrefix) ""
else if (sym.isModuleClass) sym.fullName + "."
else sym.nameString + ".this."
override def safeToString: String =
@@ -1220,8 +1220,9 @@ trait Types extends api.Types { self: SymbolTable =>
override def termSymbol = sym
override def prefix: Type = pre
- override def prefixString: String =
- if ((sym.isEmptyPackage || sym.isInterpreterWrapper || sym.isPredefModule || sym.isScalaPackage) && !settings.debug.value) ""
+ override def prefixString =
+ if (sym.isPackageObjectOrClass) pre.prefixString
+ else if (sym.isOmittablePrefix) ""
else pre.prefixString + sym.nameString + "."
override def kind = "SingleType"
}
@@ -2050,8 +2051,10 @@ A type's typeSymbol should never be inspected directly.
override def prefixString = "" + (
if (settings.debug.value)
super.prefixString
- else if (sym.printWithoutPrefix)
+ else if (sym.isOmittablePrefix)
""
+ else if (sym.isPackageObjectOrClass)
+ sym.owner.fullName + "."
else if (sym.isPackageClass)
sym.fullName + "."
else if (isStable && nme.isSingletonName(sym.name))
@@ -4080,7 +4083,7 @@ A type's typeSymbol should never be inspected directly.
def corresponds(sym1: Symbol, sym2: Symbol): Boolean =
sym1.name == sym2.name && (sym1.isPackageClass || corresponds(sym1.owner, sym2.owner))
if (!corresponds(sym.owner, rebind0.owner)) {
- debuglog("ADAPT1 pre = "+pre+", sym = "+sym+sym.locationString+", rebind = "+rebind0+rebind0.locationString)
+ debuglog("ADAPT1 pre = "+pre+", sym = "+sym.fullLocationString+", rebind = "+rebind0.fullLocationString)
val bcs = pre.baseClasses.dropWhile(bc => !corresponds(bc, sym.owner));
if (bcs.isEmpty)
assert(pre.typeSymbol.isRefinementClass, pre) // if pre is a refinementclass it might be a structural type => OK to leave it in.
@@ -4089,11 +4092,8 @@ A type's typeSymbol should never be inspected directly.
debuglog(
"ADAPT2 pre = " + pre +
", bcs.head = " + bcs.head +
- ", sym = " + sym+sym.locationString +
- ", rebind = " + rebind0 + (
- if (rebind0 == NoSymbol) ""
- else rebind0.locationString
- )
+ ", sym = " + sym.fullLocationString +
+ ", rebind = " + rebind0.fullLocationString
)
}
val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable)