Skip to content

Commit 9ef0341

Browse files
authored
Merge pull request #1556 from olafurpg/directory-arg
Improve message when directory is passed dotc.
2 parents a6ba025 + 73aa6dd commit 9ef0341

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dotty/tools/dotc/Run.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ class Run(comp: Compiler)(implicit ctx: Context) {
2929
var units: List[CompilationUnit] = _
3030

3131
def getSource(fileName: String): SourceFile = {
32-
val encoding = ctx.settings.encoding.value
3332
val f = new PlainFile(fileName)
34-
if (f.exists) new SourceFile(f, Codec(encoding))
35-
else {
33+
if (f.isDirectory) {
34+
ctx.error(s"expected file, received directory '$fileName'")
35+
NoSource
36+
} else if (f.exists) {
37+
val encoding = ctx.settings.encoding.value
38+
new SourceFile(f, Codec(encoding))
39+
} else {
3640
ctx.error(s"not found: $fileName")
3741
NoSource
3842
}

0 commit comments

Comments
 (0)