Skip to content

Conversation

nicolasstucki
Copy link
Contributor

Alternative to #12200 where we deprecate Typed to keep a single abstraction.

Currently, we are missing in the API the Wildcard concept for `case _ =>` patterns.
These are encoded as term `Ident` with name `_`. This tree can be inconsistently
 matched by `Ident`, `TypeIdent` or `WildcardTypeTree`. There is also no way to create an `Ident(_)`.

The typed expression can contain non-Term trees: Wildcard, Alternatives, Bind and Unapply.
The solution is to add a TypedTree supertype of Typed that contains a Tree.

Changes
* `Ident` does not match `Ident(_)`
* `TypeIdent` does not match `Ident(_)`
* `WildcardTypeTree` does not match `Ident(_)` if it is a term
* Add `WildcardPattern` type that matches a term `Ident(_)`
* `Typed` only matched if the expr is a `Term`
* Add `TypedTree`

Fixes scala#12188
@nicolasstucki nicolasstucki changed the title Fix wildcard abstaction 3 Fix Reflection wildcard and Typed abstraction (alt 2) Aug 20, 2021
@nicolasstucki nicolasstucki force-pushed the fix-wildcard-abstaction-3 branch from 5177cb3 to d1393b0 Compare August 20, 2021 09:06
@nicolasstucki nicolasstucki force-pushed the fix-wildcard-abstaction-3 branch from d1393b0 to 17336fd Compare August 20, 2021 09:06
@nicolasstucki
Copy link
Contributor Author

We cannot compile the stlib with this variant

@smarter
Copy link
Member

smarter commented Aug 20, 2021

Is the problem just that there's some deprecation warnings? I believe we can ignore them with -Wconf if we can't fix them now.

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