Skip to content

Commit d180287

Browse files
committed
Add diagnostics test for "pure expression" warning
Also do not reuse the compiler options used in the Dotty build for the tests, since they can influence their result (e.g. -Xfatal-warnings)
1 parent 38c6d46 commit d180287

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

language-server/test/dotty/tools/languageserver/DiagnosticsTest.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,17 @@ class DiagnosticsTest {
2525
(m1 to m1, """found: Null
2626
|required: Boolean""".stripMargin, Error, Some(TypeMismatchID))
2727
)
28+
29+
@Test def diagnosticPureExpression: Unit =
30+
code"""object Test {
31+
| ${m1}1$m2
32+
|}""".withSource
33+
.diagnostics(m1,
34+
(m1 to m2,
35+
"a pure expression does nothing in statement position; you may be omitting necessary parentheses",
36+
Warning, Some(PureExpressionInStatementPositionID)))
37+
38+
@Test def diagnosticWorksheetPureExpression: Unit =
39+
ws"""${m1}1""".withSource
40+
.diagnostics(m1 /* no "pure expression" warning because this is a worksheet */)
2841
}

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ object Build {
894894
).
895895
settings(
896896
ideTestsCompilerVersion := (version in `dotty-compiler`).value,
897-
ideTestsCompilerArguments := (scalacOptions in `dotty-compiler`).value,
897+
ideTestsCompilerArguments := Seq(),
898898
ideTestsDependencyClasspath := {
899899
val dottyLib = (classDirectory in `dotty-library-bootstrapped` in Compile).value
900900
val scalaLib =

0 commit comments

Comments
 (0)