Skip to content

Commit f73eec7

Browse files
Merge pull request #7476 from dotty-staging/fix-#7189
Fix #7189: Do not try to load contents if file does not exist
2 parents 1fe9555 + f87d240 commit f73eec7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ object Trees {
368368
// name (e.g. in a comment) before finding the real definition.
369369
// To make this behavior more robust we'd have to change the trees for definitions to contain
370370
// a fully positioned Ident in place of a name.
371-
val idx = source.content().indexOfSlice(realName, point)
371+
val contents = if source.exists then source.content() else Array.empty[Char]
372+
val idx = contents.indexOfSlice(realName, point)
372373
if (idx >= 0) idx
373374
else point // use `point` anyway. This is important if no source exists so scanning fails
374375
}

0 commit comments

Comments
 (0)