Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Support API profiles in the style of -release #17690

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

Closed
som-snytt opened this issue Oct 1, 2022 · 3 comments
Closed

Support API profiles in the style of -release #17690

som-snytt opened this issue Oct 1, 2022 · 3 comments

Comments

@som-snytt
Copy link
Contributor

A sample homework:

Hey does anyone know how I can add an element to the end of a list in scala WITHOUT using :+?
I'm working on this recursion problem for my homework and the instruction is that I can only use List.empty, .isEmpty, .nonEmpty, .:: (cons), .head, .tail

It would be nice if a student could scalac --profile:homework1 which would surface only the allowed API on the classpath. This would work similarly to --release. The trick might be how to make it easy to specify and generate the permitted API as a ct.sym file.

IRL projects could use such a facility to restrict API usage. In particular, it would not only restrict to a platform version like -release, but disallow methods deemed substandard for any reason.

@som-snytt
Copy link
Contributor Author

This is a great idea! I'm glad I checked existing tickets before creating a new one. 💯

@smarter
Copy link
Member

smarter commented Nov 17, 2022

This seems like something that could be done with a scalafix rule considering that there's already one to disallow a set of symbols: https://github.com/vovapolu/scaluzzi/blob/6deedfd4c3d05b2fc33bf8d8080d05011d473613/scalafix/input/src/main/scala/test/DisableSimple.scala#L3-L20, so the dual should be possible too.

@som-snytt
Copy link
Contributor Author

This would be a stronger feature, as only the specified profile is available for typechecking.

@ckipp01 ckipp01 transferred this issue from lampepfl/dotty-feature-requests May 31, 2023
@scala scala locked and limited conversation to collaborators May 31, 2023
@ckipp01 ckipp01 converted this issue into discussion #17691 May 31, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants