Skip to content

Commit e2aaf2c

Browse files
authored
Merge pull request scala#5723 from dragos/issue/regression-assert-ide
Fix regression introduced by 5751763
2 parents f174bfb + e5c957e commit e2aaf2c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,16 @@ abstract class SymbolLoaders {
122122
* and give them `completer` as type.
123123
*/
124124
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)
130135
if (!clazz.isAnonymousClass) {
131136
// Diagnostic for SI-7147
132137
def msg: String = {

0 commit comments

Comments
 (0)