Skip to content

Add typeChecks to the library #6175

New issue

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

Merged
merged 4 commits into from
Mar 27, 2019
Merged

Conversation

nicolasstucki
Copy link
Contributor

Follow up of #6135

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

private def typeChecksImpl(code: String)(implicit reflect: Reflection): Expr[Boolean] = {
import reflect._
typing.typeChecks(code).toExpr
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove private, as inlining will create an accessor if it's private.

Can we use top-level definitions to get rid of object TypeChecking?

Regarding scala.tests, what about scala.test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try the top level definition and change to scala.test. typeChecksImpl must be private or it would be visible under import scala.test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, we will also support arbitrary code in top-level splices. Which will allow us to implement it like

inline def typeChecks(inline code: String): Boolean = ${
  val reflect = implicitly[Reflection]
  import reflect._
  typing.typeChecks(code).toExpr
}

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liufengyun liufengyun merged commit 77b7a3c into scala:master Mar 27, 2019
@liufengyun liufengyun deleted the add-typeChecks-2 branch March 27, 2019 15:37
@ghost ghost removed the stat:needs review label Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants