Skip to content

Commit 5007f97

Browse files
committed
sourcepath: avoid warnings spanning a whole class
1 parent 3bdb0eb commit 5007f97

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ object SymbolLoaders {
131131
ctx.warning(i"""$what ${tree.name} is in the wrong directory.
132132
|It was declared to be in package ${path.reverse.mkString(".")}
133133
|But it is found in directory ${filePath.reverse.mkString(File.separator)}""",
134-
tree.sourcePos)
134+
tree.sourcePos.focus)
135135
ok
136136
}
137137

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class CompilationTests extends ParallelTesting {
136136
compileFile("tests/neg-custom-args/i3627.scala", allowDeepSubtypes),
137137
compileFile("tests/neg-custom-args/matchtype-loop.scala", allowDeepSubtypes),
138138
compileFile("tests/neg-custom-args/sourcepath/outer/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath")),
139+
compileDir("tests/neg-custom-args/sourcepath2/hi", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath2", "-Xfatal-warnings")),
139140
compileList("duplicate source", List(
140141
"tests/neg-custom-args/toplevel-samesource/S.scala",
141142
"tests/neg-custom-args/toplevel-samesource/nested/S.scala"),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/neg-custom-args/sourcepath2/hi/A.scala:3:6 -------------------------------------------------------------
2+
3 |class Hello { // error
3+
| ^
4+
| class Hello is in the wrong directory.
5+
| It was declared to be in package <empty>
6+
| But it is found in directory hi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Missing `package hi`
2+
3+
class Hello { // error
4+
val x: Int = 1
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package hi
2+
class B

0 commit comments

Comments
 (0)