Skip to content

Commit e732ee5

Browse files
committed
Drop error messages tests
I believe error messages tests should be dropped, unless they test something really specific. E.g. a way information is represented that is easy to break. For normal tests we have check files, or (most of the time even better) `// error` annotations. The problem with over-engineered solutions like error messages tests is that they cause a huge friction when things change. I lost an inordinate amount of time getting the extensions PR over the line since in the meantime there landed an elaborate error messages commit. Fixing rebase breakages over this PR is not a good use of my time! Two things could improve that situation: - we go slower on inessential PRs like error messages, _in particular_ if there is a pending conflict with a pending PR - we go faster merging essential PRs.
1 parent 2c88bb5 commit e732ee5

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTests.scala

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,74 +1840,6 @@ class ErrorMessagesTests extends ErrorMessagesTest {
18401840
assertEquals("given x @ String", x.show)
18411841
}
18421842

1843-
@Test def extensionMethodsNotAllowed =
1844-
checkMessagesAfter(RefChecks.name) {
1845-
"""object Test {
1846-
| extension on[T] (t: T) {
1847-
| def (c: T).f: T = ???
1848-
| }
1849-
|}
1850-
""".stripMargin
1851-
}
1852-
.expect { (ictx, messages)
1853-
implicit val ctx: Context = ictx
1854-
assertMessageCount(1, messages)
1855-
val errorMsg = messages.head.msg
1856-
val NoExtensionMethodAllowed(x) :: Nil = messages
1857-
assertEquals("No extension method allowed here, since collective parameters are given", errorMsg)
1858-
assertEquals("def (c: T) f: T = ???", x.show)
1859-
}
1860-
1861-
@Test def extensionMethodTypeParamsNotAllowed =
1862-
checkMessagesAfter(RefChecks.name) {
1863-
"""object Test {
1864-
| extension on[T] (t: T) {
1865-
| def f[U](u: U): T = ???
1866-
| }
1867-
|}
1868-
""".stripMargin
1869-
}
1870-
.expect { (ictx, messages)
1871-
implicit val ctx: Context = ictx
1872-
assertMessageCount(1, messages)
1873-
val errorMsg = messages.head.msg
1874-
val ExtensionMethodCannotHaveTypeParams(x) :: Nil = messages
1875-
assertEquals("Extension method cannot have type parameters since some were already given previously", errorMsg)
1876-
assertEquals("def f[U](u: U): T = ???", x.show)
1877-
}
1878-
1879-
@Test def extensionMethodCanOnlyHaveDefs =
1880-
checkMessagesAfter(RefChecks.name) {
1881-
"""object Test {
1882-
| extension on[T] (t: T) {
1883-
| val v: T = t
1884-
| }
1885-
|}
1886-
""".stripMargin
1887-
}
1888-
.expect { (ictx, messages)
1889-
implicit val ctx: Context = ictx
1890-
assertMessageCount(1, messages)
1891-
val errorMsg = messages.head.msg
1892-
val ExtensionCanOnlyHaveDefs(x) :: Nil = messages
1893-
assertEquals("Only methods allowed here, since collective parameters are given", errorMsg)
1894-
assertEquals("val v: T = t", x.show)
1895-
}
1896-
1897-
@Test def anonymousInstanceMustImplementAType =
1898-
checkMessagesAfter(RefChecks.name) {
1899-
"""object Test {
1900-
| extension on[T] (t: T) { }
1901-
|}
1902-
""".stripMargin
1903-
}
1904-
.expect { (ictx, messages)
1905-
implicit val ctx: Context = ictx
1906-
assertMessageCount(1, messages)
1907-
val errorMsg = messages.head.msg
1908-
assertEquals("anonymous instance must implement a type or have at least one extension method", errorMsg)
1909-
}
1910-
19111843
@Test def typeSplicesInValPatterns =
19121844
checkMessagesAfter(RefChecks.name) {
19131845
s"""import scala.quoted._

0 commit comments

Comments
 (0)