We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import scala.compiletime.testing.typeChecks import scala.compiletime.error inline def assertDoesNotCompile(inline code: String): Unit = { if (typeChecks(code)) { error("Type-checking succeeded unexpectedly.") } else { } } val test1 = assertDoesNotCompile("1") val test2 = assertDoesNotCompile("1.noSuchMethod")
test1 behaves correctly.
test1
test2 should be unit, but it is a compiletime error.
test2
To get the correct behaviour, this macro works:
def typeChecksOrErrImpl(code: String) given (qctx: QuoteContext): Expr[Unit] = { import qctx.tasty._ if (typing.typeChecks(code)) { error("Type-checking succeeded unexpectedly.", rootPosition) '{} } else { '{} } }
The text was updated successfully, but these errors were encountered:
Fix scala#7040: Add regression test
4a69b27
In general you should use inline if if you what to make sure the condition of the if is constant folded.
inline if
if
inline if (typeChecks(code)) { error("Type-checking succeeded unexpectedly.") } else { }
Sorry, something went wrong.
But #7129 makes the original code work.
b81fb3c
nicolasstucki
No branches or pull requests
minimized code
test1
behaves correctly.expectation
test2
should be unit, but it is a compiletime error.To get the correct behaviour, this macro works:
The text was updated successfully, but these errors were encountered: