@@ -122,11 +122,16 @@ abstract class SymbolLoaders {
122
122
* and give them `completer` as type.
123
123
*/
124
124
def enterClassAndModule (root : Symbol , name : String , getCompleter : (ClassSymbol , ModuleSymbol ) => SymbolLoader ) {
125
- val clazz = newClass(root, name)
126
- val module = newModule(root, name)
127
- val completer = getCompleter(clazz, module)
128
- enterClass(root, clazz, completer)
129
- enterModule(root, module, completer)
125
+ val clazz0 = newClass(root, name)
126
+ val module0 = newModule(root, name)
127
+ val completer = getCompleter(clazz0, module0)
128
+ // enterClass/Module may return an existing symbol instead of the ones we created above
129
+ // this may happen when there's both sources and binaries on the classpath, but the class
130
+ // name is different from the file name, so the classpath can't match the binary and source
131
+ // representation. `companionModule/Class` prefers the source version, so we should be careful
132
+ // to reuse the symbols returned below.
133
+ val clazz = enterClass(root, clazz0, completer)
134
+ val module = enterModule(root, module0, completer)
130
135
if (! clazz.isAnonymousClass) {
131
136
// Diagnostic for SI-7147
132
137
def msg : String = {
0 commit comments