aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/Run.scala
diff options
context:
space:
mode:
authorÓlafur Páll Geirsson <olafurpg@gmail.com>2016-10-04 16:39:43 +0200
committerÓlafur Páll Geirsson <olafurpg@gmail.com>2016-10-10 11:00:19 +0200
commit73aa6dd7d3047545b1b753bae5802e267453095b (patch)
tree037ef5e6a415d92fc9c23ab53de73b78874217fc /src/dotty/tools/dotc/Run.scala
parenta6ba02557df10af1340a0077e2f65e1849ed2489 (diff)
downloaddotty-73aa6dd7d3047545b1b753bae5802e267453095b.tar.gz
dotty-73aa6dd7d3047545b1b753bae5802e267453095b.tar.bz2
dotty-73aa6dd7d3047545b1b753bae5802e267453095b.zip
Improve message when directory is passed dotc.
Previously, running ./bin/dotc <directory> caused a null pointer exception. Now, the error is: error: expected file, received directory 'bin'
Diffstat (limited to 'src/dotty/tools/dotc/Run.scala')
-rw-r--r--src/dotty/tools/dotc/Run.scala10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index fa69530b5..f5ba56a7e 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -29,10 +29,14 @@ class Run(comp: Compiler)(implicit ctx: Context) {
var units: List[CompilationUnit] = _
def getSource(fileName: String): SourceFile = {
- val encoding = ctx.settings.encoding.value
val f = new PlainFile(fileName)
- if (f.exists) new SourceFile(f, Codec(encoding))
- else {
+ if (f.isDirectory) {
+ ctx.error(s"expected file, received directory '$fileName'")
+ NoSource
+ } else if (f.exists) {
+ val encoding = ctx.settings.encoding.value
+ new SourceFile(f, Codec(encoding))
+ } else {
ctx.error(s"not found: $fileName")
NoSource
}