Skip to content

TASTY: no way to access baseClasses of AppliedType #8514

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
pshirshov opened this issue Mar 11, 2020 · 9 comments · Fixed by #8961 or #9481
Closed

TASTY: no way to access baseClasses of AppliedType #8514

pshirshov opened this issue Mar 11, 2020 · 9 comments · Fixed by #8961 or #9481
Assignees

Comments

@pshirshov
Copy link
Contributor

pshirshov commented Mar 11, 2020

I'm working on re-implementation of izumi-reflect for Dotty.

So far I made some substantial progress but seems like there is a blocker.

The primary problem is: seems like there is no way to get access to baseClasses of a type:

Let's assume that we have the following definitions:

trait X[A, B]
trait A[F[_]]
trait B extends A[X[Int, *]]

On scala2 I can call .baseClasses method on a type of B and get a list containing A[[T] => X[Int, T]].

In dotty AppliedType has only tycon method which does not allow me to inspect applied parents.

See also: 7mind/dotty-typetag-research#2 ; zio/izumi-reflect#22

@pshirshov
Copy link
Contributor Author

@nicolasstucki could you check this issue please?

@nicolasstucki nicolasstucki self-assigned this Mar 11, 2020
@Blaisorblade

This comment has been minimized.

@pshirshov

This comment has been minimized.

@Blaisorblade
Copy link
Contributor

Blaisorblade commented Mar 18, 2020

(On the main issue: I’m aware the API is incomplete and extensions are being considered, and things like this should be fine, but I cannot say more).

@jdegoes
Copy link

jdegoes commented Apr 1, 2020

This seems like a useful improvement regardless, but speaking as a ZIO contributor, I know we are relying on this functionality (or its equivalent) for the new environment encoding, which has proven to be a smash hit among ZIO users, but which only has partial support in Dotty.

Thanks for reporting!

@pshirshov
Copy link
Contributor Author

Seem like this is not enough. Seems like just this method does not allow to get applied supertype:

trait Super[X]
trait Sub extends Super[X]

I can get Super from .baseClasses output but not Super[X].

Seems like TypeApi#baseClass would solve my problem, but it's not exposed.
Could you expose it as well?

    /** The least type instance of given class which is a super-type
     *  of this type.  Example:
     *  {{{
     *    class D[T]
     *    class C extends p.D[Int]
     *    ThisType(C).baseType(D) = p.D[Int]
     * }}}
     */
    def baseType(clazz: Symbol): Type

@smarter
Copy link
Member

smarter commented Aug 1, 2020

If you need some API to be exposed, I encourage you to make a PR to do so yourself.

@pshirshov
Copy link
Contributor Author

Yup, trying to do that.

pshirshov added a commit to pshirshov/dotty that referenced this issue Aug 1, 2020
pshirshov added a commit to pshirshov/dotty that referenced this issue Aug 1, 2020
@pshirshov
Copy link
Contributor Author

pshirshov commented Aug 1, 2020

@smarter : #9481 - what would you say? Just copycatted the original PR.

@nicolasstucki nicolasstucki linked a pull request Aug 3, 2020 that will close this issue
pshirshov added a commit to pshirshov/dotty that referenced this issue Aug 3, 2020
nicolasstucki added a commit that referenced this issue Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants