-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
a path dependent type does not conform to its projection type #17064
Comments
This can be minimized to: class Outer {
type This = this.type
val x: Outer#This = this // error
} What's happening here is that There is a discussion up at lampepfl/dotty-feature-requests#14 about relaxing the subtype checking for type projections which would fix this. The relaxed rule has been proved sound, but it still needs a SIP and some careful consideration of possible interactions with other features. |
Note that we don't need the full power of lampepfl/dotty-feature-requests#14 for the original example in this issue, but the more limited rule mentioned in lampepfl/dotty-feature-requests#14 (comment):
which should be even less controversial. |
We already implemented in essence the rule suggested in lampepfl/dotty-feature-requests#14: ``` Γ ⊨ p : T ------------------------ (Sel-<:-Proj) Γ ⊨ p.A <: T#A ``` This rule is implemented in `isSubPrefix`. But we did not get to check that since we concluded prematurely that an alias type would never match. The alias type in question in i17064.scala was ```scala Outer#Inner ``` Since `Outer` is not a path, the asSeenFrom to recover the info of `Outer#Inner this got approximated with a `Nothing` argument and therefore the alias failed. It is important in this case that we could still succeed with a `isSubPrefix` test, which comes later. So we should not return `false` when the prefix is not a singleton. Fixes scala#17064
We already implemented in essence the rule suggested in lampepfl/dotty-feature-requests#14: ``` Γ ⊨ p : T ------------------------ (Sel-<:-Proj) Γ ⊨ p.A <: T#A ``` This rule is implemented in `isSubPrefix`. But we did not get to check that since we concluded prematurely that an alias type would never match. The alias type in question in i17064.scala was ```scala Outer#Inner ``` Since `Outer` is not a path, the asSeenFrom to recover the info of `Outer#Inner` got approximated with a `Nothing` argument and therefore the alias failed. It is important in this case that we could still succeed with a `isSubPrefix` test, which comes later. So we should not return `false` when the prefix is not a singleton. Fixes #17064
This comment was marked as off-topic.
This comment was marked as off-topic.
We already implemented in essence the rule suggested in lampepfl/dotty-feature-requests#14: ``` Γ ⊨ p : T ------------------------ (Sel-<:-Proj) Γ ⊨ p.A <: T#A ``` This rule is implemented in `isSubPrefix`. But we did not get to check that since we concluded prematurely that an alias type would never match. The alias type in question in i17064.scala was ```scala Outer#Inner ``` Since `Outer` is not a path, the asSeenFrom to recover the info of `Outer#Inner this got approximated with a `Nothing` argument and therefore the alias failed. It is important in this case that we could still succeed with a `isSubPrefix` test, which comes later. So we should not return `false` when the prefix is not a singleton. Fixes scala#17064
Compiler version
3.2.2 , 3.3.0-RC3
Minimized code
Output
Expectation
Code should compile:
o.Inner
conforms toOuter#Inner
.Note
Outer
is a class, soOuter#Inner
is legal (sound) in scala3.Compiles in scala 2.13.
Intention
The intention is to make
Inner
behave almost as inner class ofOuter
.The text was updated successfully, but these errors were encountered: