Skip to content

TypeComparer: delay looking up members of AndTypes #979

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

Merged
merged 1 commit into from
Dec 6, 2015

Conversation

smarter
Copy link
Member

@smarter smarter commented Nov 26, 2015

In ParFactory.scala we have checks that look like:

  (Foo { type Bar = X }) & (Foo { type Bar = X }) <:< (Foo { type Bar = X })

where Foo is a recursive type.

Before this commit, we would first try to check this by looking up Bar
in the AndType on the left, which means looking it up in both branches
and then merging the result, but the merge requires more subtyping
checks, which in turn require looking up a member inside an AndType,
seemingly ad infinitum.

We now avoid this by checking if either branch of the AndType on the left
is a subtype of the RefinedType on the right before looking up a member
in the AndType itself.

Review by @odersky

In ParFactory.scala we have checks that look like:
  (Foo { type Bar = X }) & (Foo { type Bar = X }) <:< (Foo { type Bar = X })
where `Foo` is a recursive type.

Before this commit, we would first try to check this by looking up `Bar`
in the `AndType` on the left, which means looking it up in both branches
and then merging the result, but the merge requires more subtyping
checks, which in turn require looking up a member inside an `AndType`,
seemingly ad infinitum.

We now avoid this by checking if either branch of the `AndType` on the left
is a subtype of the `RefinedType` on the right before looking up a member
in the `AndType` itself.
@smarter smarter force-pushed the fix/hk-deep-subtype-2 branch from 8b41b27 to 6e4b4f4 Compare November 30, 2015 21:30
@odersky
Copy link
Contributor

odersky commented Dec 6, 2015

LGTM. I think the logic can be slightly simplified since AndTypes never need an eta lift. I'll take care of that in the higher-kinded PR.

odersky added a commit that referenced this pull request Dec 6, 2015
TypeComparer: delay looking up members of AndTypes
@odersky odersky merged commit 7e63af3 into scala:master Dec 6, 2015
@allanrenucci allanrenucci deleted the fix/hk-deep-subtype-2 branch December 14, 2017 19:22
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.

3 participants