From f87d240c97b371c1c3721c840e7cc5d11d5d6fbf Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 30 Oct 2019 14:50:28 +0100 Subject: [PATCH] Fix #7189: Do not try to load contents if file does not exist --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index de33d26d6154..6e3a02fe86e3 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -368,7 +368,8 @@ object Trees { // name (e.g. in a comment) before finding the real definition. // To make this behavior more robust we'd have to change the trees for definitions to contain // a fully positioned Ident in place of a name. - val idx = source.content().indexOfSlice(realName, point) + val contents = if source.exists then source.content() else Array.empty[Char] + val idx = contents.indexOfSlice(realName, point) if (idx >= 0) idx else point // use `point` anyway. This is important if no source exists so scanning fails }