Skip to content

Commit d150664

Browse files
committed
Warn if files containing the same toplevel def come from different directories.
1 parent 7e86070 commit d150664

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,18 +2174,18 @@ object SymDenotations {
21742174
if youngest.size > 1 then
21752175
throw TypeError(i"""${ambiguousFilesMsg(youngest.tail.head)}
21762176
|One of these files should be removed from the classpath.""")
2177-
def sameContainer(f: AbstractFile): Boolean =
2178-
try f.container == chosen.container catch case NonFatal(ex) => true
21792177

21802178
// Warn if one of the older files comes from a different container.
21812179
// In that case picking the youngest file is not necessarily what we want,
21822180
// since the older file might have been loaded from a jar earlier in the
21832181
// classpath.
2182+
def sameContainer(f: AbstractFile): Boolean =
2183+
try f.container == chosen.container catch case NonFatal(ex) => true
21842184
if !ambiguityWarningIssued then
21852185
for conflicting <- assocFiles.find(!sameContainer(_)) do
2186-
ctx.warning(i"""${ambiguousFilesMsg(youngest.tail.head)}
2186+
ctx.warning(i"""${ambiguousFilesMsg(conflicting)}
21872187
|Keeping only the definition in $chosen""")
2188-
ambiguityWarningIssued = true
2188+
ambiguityWarningIssued = true
21892189
multi.filterWithPredicate(_.symbol.associatedFile == chosen)
21902190
end dropStale
21912191

0 commit comments

Comments
 (0)