You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objecto {
opaquetypeT=String
summon[o.T=:=T] // OK
summon[o.T=:=String] // OKdeftest1(t: T):Int=
t.length // OKdeftest2(t: o.T):Int=
t.length // Error: value length is not a member of Playground.o.T
}
we have inside the object (also for non-opaque types) that o.T is equal to T or its expanded form o.this.T. Equality is understood here as mutual subtyping, i.e. o.T <: o.this.T and o.this.T <: o.T. Furthermore, we have by the rules of opaque type aliases that o.this.T equals R. The two equalities compose. That is, inside o, it is also known that o.T is equal to R.
it should hold, inside the object o, that o.T is equal to o.this.T is equal to String. Therefore, t.length should typecheck.
The text was updated successfully, but these errors were encountered:
Edit: im hiding my original statement because o.Foo != o.this.Foo if you use the compilers internal API, but I guess I'm not sure what happens if you write it in the source code
There is a difference between the internal type system (at the TASTy level, let's say) and the external type system that the users see. In the internal type system, only o.this.T can see the alias. But at the user level, the elaboration is supposed to make o.T =:= o.this.T appear to be true as well, and insert casts if necessary.
@dwijnand I think you looked at a similar issue not too long ago. Does this ring a bell?
Compiler version
3.3.1
3.3.2-RC3
3.4.0-RC4
Minimized code
https://scastie.scala-lang.org/CN2ydzIkSBSKNUsY10NYgQ
Output
Expectation
According to https://docs.scala-lang.org/scala3/reference/other-new-features/opaques-details.html#type-checking-10
it should hold, inside the object
o
, thato.T
is equal too.this.T
is equal toString
. Therefore,t.length
should typecheck.The text was updated successfully, but these errors were encountered: