Skip to content

Fix #2201: Less aggressive type application reduction for better inference #2204

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
Apr 9, 2017

Conversation

smarter
Copy link
Member

@smarter smarter commented Apr 8, 2017

Previously we believed that reducing type applications did not affect
type inference as long as the reduced type constructor had the same
arity as the unreduced one, for example reducing Foo[X, Y] is fine
when Foo is defined as:

type Foo[A, B] = Bar[A, B]

but not when it's defined as:

type Foo[A] = Bar[A, A]

But this is not a sufficient condition: the bounds of the type
constructor arguments also matter for type inference, so we need to be
more strict and disallow reductions in cases like:

type Foo[A, B] = Bar[B, A]

and:

type Foo[A, B] = Bar[A, Int]

… inference

Previously we believed that reducing type applications did not affect
type inference as long as the reduced type constructor had the same
arity as the unreduced one, for example reducing `Foo[X, Y]` is fine
when `Foo` is defined as:

type Foo[A, B] = Bar[A, B]

but not when it's defined as:

type Foo[A] = Bar[A, A]

But this is not a sufficient condition: the bounds of the type
constructor arguments also matter for type inference, so we need to be
more strict and disallow reductions in cases like:

type Foo[A, B] = Bar[B, A]

and:

type Foo[A, B] = Bar[A, Int]
@odersky
Copy link
Contributor

odersky commented Apr 9, 2017

LGTM

@odersky odersky merged commit b8bb34d into scala:master Apr 9, 2017
@allanrenucci allanrenucci deleted the fix/i2201 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.

2 participants