Skip to content

Fix subtyping to match DOT rule TDECL-<: #181

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
wants to merge 1 commit into from

Conversation

smarter
Copy link
Member

@smarter smarter commented Oct 9, 2014

This is based on my understanding of the DOT rules but could be completely wrong/not what we want, feedback welcome.

Review by @odersky @DarkDimius @namin .

@smarter smarter force-pushed the fix/typebounds-subtyping branch from d47b5fe to 89844df Compare October 9, 2014 09:04
@samuelgruetter
Copy link
Contributor

I'm a bit confused, do you really mean this rule?

 G |- S' <: S    G |- T <: T'
------------------------------- (TDECL-<:)
 G |- (L: S..T) <: (L: S'..T')

I can't relate it to the proposed changes, could you please elaborate a bit?

@smarter
Copy link
Member Author

smarter commented Oct 9, 2014

Maybe I'm misinterpreting that rule or the DOT calculus in general, but to me it implies that if:

val a = new Top { z => type T : S'..T' } {};
val b = new Top { z => type T : S..T } {};

Then if S' <: S and T <: T':

(b.T: S..T) <: (a.T: S'..T')

Which I translate in dotty as test_tdecl_lt_colon: https://github.com/lampepfl/dotty/pull/181/files#diff-15bd40012c5ac4213ccb9b567dc3957eR20

@samuelgruetter
Copy link
Contributor

I think you're misinterpreting that rule. Here's my attempt to clarity: L stands only for a type label, something like a string, i.e. just a name, and you cannot substitute b.T for it. Moreover, when we write (L: S..T), the : has nothing to do with the : in type assignment judgments G |- t : T. (L: S..T) is just a way of expressing a "data structure" which contains a type declaration. In Scala, the equivalent would be type L >: S <: T.
Does that make sense?

@smarter
Copy link
Member Author

smarter commented Oct 9, 2014

Alright, I think I get it, the fact that A <: B and a: A, b: B does not imply that a.T <: b.T even if the declaration of T in A subsumes the declaration of T in B, and I now understand why Martin had reservations about A#T <: B#T in #179 .

@smarter smarter closed this Oct 9, 2014
@samuelgruetter
Copy link
Contributor

Yes, exactly.

WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "Fixes for isLegalPrefix change" to 3.3 LTS
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