Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove locale dependent FileSystemException check #21633

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,11 @@ object SourceFile {

def apply(file: AbstractFile | Null, codec: Codec): SourceFile =
// Files.exists is slow on Java 8 (https://rules.sonarsource.com/java/tag/performance/RSPEC-3725),
// so cope with failure; also deal with path prefix "Not a directory".
// so cope with failure.
val chars =
try new String(file.toByteArray, codec.charSet).toCharArray
catch
case _: NoSuchFileException => Array.empty[Char]
case fse: FileSystemException if fse.getMessage.endsWith("Not a directory") => Array.empty[Char]
case _: FileSystemException => Array.empty[Char]

if isScript(file, chars) then
ScriptSourceFile(file, chars)
Expand Down
Loading