Skip to content

Remove Reflection.TypeOrBounds abstraction #9706

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

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Sep 2, 2020

  • Align with TASTy format
  • Make it simpler to handle types with the reflection API
  • Remove ParamInfo from LambdaType (it was unused)

This abstraction is there for historical reasons only, from the time when there was split between TypeTree, TypeBoundsTree and Tree. This distinction is no longer in the API and the types should follow the same design.

Migration help
If there match on Type that matched agaist a TypeOrBound

def f(t: TypeOrBound) =
  t match
    case t: Type =>
    ...

The cases for TypeBounds and NoPrefix should be added before the Type test

def f(t: Type) =
  t match
    case t: TypeBounds =>
    case NoPrefix() =>
    case t => // t: Type
    ...

Then reflector. Those cases might not be needed in most situations.

@nicolasstucki nicolasstucki self-assigned this Sep 2, 2020
@nicolasstucki nicolasstucki force-pushed the remove-reflect-TypeOrBounds branch 5 times, most recently from 67f118b to 9c09b42 Compare September 3, 2020 07:35
* Align with TASTy format
* Make it simpler to handle types with the reflection API
* Remove ParamInfo from LambdaType (it was unused)

This abstraction is there for historical reasons only, from the time when there was split between TypeTree, TypeBoundsTree and Tree. This distinction is no longer in the API and the types should follow the same design.

Migration help: If there match on `Type` that matched agaist a `TypeOrBound`
```scala
def f(t: TypeOrBound) =
  t match
    case t: Type =>
    ...
```
The cases for `TypeBounds` and `NoPrefix` should be added before the `Type` test

```scala
def f(t: Type) =
  t match
    case t: TypeBounds =>
    case NoPrefix() =>
    case t => // t: Type
    ...
```
@nicolasstucki nicolasstucki force-pushed the remove-reflect-TypeOrBounds branch from 9c09b42 to 6872bdb Compare September 3, 2020 08:17
@nicolasstucki
Copy link
Contributor Author

@nicolasstucki nicolasstucki marked this pull request as ready for review September 3, 2020 09:28
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, nice improvement of API friendliness 👍

@nicolasstucki nicolasstucki merged commit 0f757c5 into scala:master Sep 3, 2020
@nicolasstucki nicolasstucki deleted the remove-reflect-TypeOrBounds branch September 3, 2020 10:50
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

3 participants