|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change should be transparent to anything using sourceFile,
unless it was drinking from the inheritance well too deeply. Rather
than squander the already allocated field for every ClassSymbol not
being compiled from source, I'm now populating it with the file
representing the class. This will make a broad range of things easier,
like debugging, issuing useful error messages, symbol invalidation,
signature verification, you name it.
def sourceFile - still returns only source code files
def binaryFile - returns only class files
def associatedFile - returns whatever is there, if anything
Performance: I may be mistaken, but I believe this is a zero-impact
change. No new fields are allocated; fields which were null now hold
a useful reference. The reference is to a file instance which was
already being allocated and already long-lived.
Compare error messages:
// Version 1
% scalac a.scala
error: type _$1 is defined twice
// Version 2
% scalac a.scala
error: type _$1 is defined twice
conflicting symbols both originated in file './foo/package.class'
Note: this may be due to a bug in the compiler involving wildcards in package objects
one error found
Bonus for people who read commit logs. Try this in the repl
after starting power mode.
ListClass.info.members groupBy (_.associatedFile) foreach {
case (k, vs) => println("%s\n %s\n".format(k, vs map (_.defString) mkString "\n "))
}
|
|
Another lap around the track with generic signatures. At the root of the
issue reported in #4214 is our old friend (fondly remembered from the
days of primitive equality) boxed/primitive unification.
// scala
trait T[A] {
def f(): A
}
// the generic signature spec doesn't allow for parameterizing
// on primitive types, so this cannot remain Char. However
// translating it to Character, as was done, also has issues.
class C extends T[Char] {
def f(): Char = 'a'
}
// Note that neither of the signatures for f, the implementation // or
the bridge method, matches the type parameter. Generic interfaces in
class: T<java.lang.Character> Generic signatures: public char C.f()
public java.lang.Object C.f()
After this commit, primitive type parameters are translated into Object
instead of the boxed type. It was martin's idea, so no review. Closes
#4214.
|