-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Also reduce term projections #19389
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
Also reduce term projections #19389
Conversation
test performance please |
@mbovel Performance tests seem to be inoperational |
I am afraid this PR needs a performance test to be mergeable. |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/19389/ to see the changes. Benchmarks is based on merging with main (bfabc31) |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/19389/ to see the changes. Benchmarks is based on merging with main (bfabc31) |
Looks like it does not affect performance, so I think we should adopt this, since it can make dependent types smaller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way we could write a test for this?
This works:
type T
type T1 = { type A = T } # A
def test = summon[T1 =:= T]
But I can't do:
type S <: Singleton
type S1 = { val x: S } # x
def test = summon[S1 =:= S]
-- [E007] Type Mismatch Error: tests/pos/projection-term-singleton.scala:2:10 --
2 |type S1 = { val x: S } # x
| ^^^^^^^^^^^^
| Found: Object{val x: S}
| Required: ?{ x: ? }
I guess this is because in R # x
, the typer expects R
to have a type member named x
, not a term member?
I also tried:
import scala.reflect.Selectable.reflectiveSelectable
type S <: Singleton
def test =
def foo: { val x: S } = ???
val x: S = foo.x
and
import scala.reflect.Selectable.reflectiveSelectable
def getX[S, R <: {val x: S}](r: R) = r.x
but both already pass before your PR.
We already reduce `R { type A = T } # A` to `T` in most situations when we create types. We now also reduce `R { val x: S } # x` to `S` if `S` is a singleton type. This will simplify types as we go to more term-dependent typing. As a concrete benefit, it will avoid several test-pickling failures due to pickling differences when using dependent types.
833679a
to
daa29e6
Compare
We already reduce
R { type A = T } # A
toT
in most situations when we create types. We now also reduceR { val x: S } # x
toS
ifS
is a singleton type.This will simplify types as we go to more term-dependent typing. As a concrete benefit, it will avoid several test-pickling failures due to pickling differences when using dependent types.