Skip to content

Commit da1efa1

Browse files
committed
add Scala 3 version of ShouldNotTypecheck
1 parent 41d6255 commit da1efa1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

build.sbt

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,12 @@ lazy val testmacros = project.in(file("testmacros"))
4444
.settings(commonSettings)
4545
.settings(
4646
libraryDependencies += scalaOrganization.value % "scala-compiler" % scalaVersion.value,
47-
publish / skip := true
47+
publish / skip := true,
48+
Compile / unmanagedSourceDirectories += {
49+
val major = CrossVersion.partialVersion(scalaVersion.value) match {
50+
case Some((0 | 3, _)) => "3"
51+
case _ => "2"
52+
}
53+
baseDirectory.value / "src" / "main" / s"scala-$major"
54+
},
4855
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package testutil
14+
15+
import scala.compiletime.testing._
16+
17+
/**
18+
* Ensures that a code snippet does not typecheck.
19+
*/
20+
object ShouldNotTypecheck {
21+
inline def apply(code: String): Unit = assert(!typeChecks(code))
22+
inline def apply(code: String, expected: String): Unit = apply(code)
23+
}

0 commit comments

Comments
 (0)