Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Singleton improvements #17

Open
sir-wabbit opened this issue Jun 28, 2018 · 4 comments
Open

Singleton improvements #17

sir-wabbit opened this issue Jun 28, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@sir-wabbit
Copy link
Contributor

sir-wabbit commented Jun 28, 2018

Convince Scalac that all instances of a typeclass or a proposition have the same singleton type. Could be crucial for associated types...

Convince Scalac that val x = ...; val y = x implies x.type = y.type.

@sir-wabbit sir-wabbit added the enhancement New feature or request label Jun 29, 2018
@Blaisorblade
Copy link

Convince Scalac that val x = ...; val y = x implies x.type = y.type.

You just need to drop the widen for that — but if you extend it to template bodies, that will make val y = x part of the computed APIs and harder to change. And if you don't extend it to bodies, it will make val have context-dependent semantics.

@sir-wabbit
Copy link
Contributor Author

I am fine with context-dependent semantics, but I would prefer x.type = y.type to be visible only within the scope / package / file / module. The second part of this issue is not really important and mostly just for convenience in some very rare cases, so let's just drop it.

@edmundnoble
Copy link
Contributor

edmundnoble commented Sep 13, 2018

IMO there's another thing to solve, which is making x.type#A equal Y#A when Y <: Singleton if x: Y. This is only a problem because of null; I think it's safe to assume that if you're using singleton types with type projections deliberately, null isn't likely a problem for you.

@Blaisorblade
Copy link

@edmundnoble Even better, make x.type = Y when Y <: Singleton if x: Y, which is stronger. I filed this as scala/scala3#4583 and scala/bug#10905 (and it looks fixable on Dotty). Good points on null (speculation on Dotty in scala/scala3#4583 (comment)).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants