Skip to content

Allow refinements that refine already refined types. #243

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 2 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 26, 2014

Previously, a double definition errorfor T was produced in a case like this:

 type T1 = C { T <: A }
 type T2 = T1 { T <: B }

This was caused by the way T1 was treated in the refinement class
that is used to typecheck the type. Desugaring of T2 with refinedTypeToClass
would give

 trait <refinement> extends T1 { type T <: B }

and normalizeToClassRefs would transform this to:

 trait <refinement> extends C { type T <: A; type T <: B }

Hence the double definition. The new scheme desugars the rhs of T2 to:

 trait <refinement> extends C { this: T1 => type T <: B }

which avoids the problem.

Also, added tests that #232 (fix/boundsPropagation) indeed considers all refinements
together when comparing refined types.

Review by @retronym please.

Previously, a double definition errorfor `T` was produced in a case like this:

     type T1 = C { T <: A }
     type T2 = T1 { T <: B }

This was caused by the way T1 was treated in the refinement class
that is used to typecheck the type. Desugaring of T2 with `refinedTypeToClass`
would give

     trait <refinement> extends T1 { type T <: B }

and `normalizeToClassRefs` would transform this to:

     trait <refinement> extends C { type T <: A; type T <: B }

Hence the double definition. The new scheme desugars the rhs of `T2` to:

     trait <refinement> extends C { this: T1 => type T <: B }

which avoids the problem.

Also, added tests that scala#232 (fix/boundsPropagation) indeed considers all refinements
together when comparing refined types.
@odersky
Copy link
Contributor Author

odersky commented Nov 26, 2014

The new test in neg had a wrongly capitalized name: refinedSubTyping instead of refinedSubtyping.
For some reason I was unable to convince git to change the capitalization of the name in a new commit.
Therefore I will close this and refer to #244.

@odersky odersky closed this Nov 26, 2014
tgodzik added a commit to tgodzik/scala3 that referenced this pull request Apr 29, 2025
Backport "fix: Only fallback to the definition of a synthetic valdef if it is zero extent" 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.

1 participant