Skip to content

Placeholder types: take two #36740

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 13 commits into from
Aug 20, 2021
Merged

Placeholder types: take two #36740

merged 13 commits into from
Aug 20, 2021

Conversation

Jumhyn
Copy link
Member

@Jumhyn Jumhyn commented Apr 3, 2021

Implements the placeholder types proposal.

@Jumhyn

This comment has been minimized.

@Jumhyn Jumhyn force-pushed the placeholder-types branch 3 times, most recently from 0464850 to 1ea1cf7 Compare April 4, 2021 18:37
@Jumhyn
Copy link
Member Author

Jumhyn commented Apr 5, 2021

cc @xedin @CodaFi @hborla since y'all looked at the last PR on placeholder types 🙂

@xedin xedin requested review from xedin and hborla April 6, 2021 18:37
@xedin
Copy link
Contributor

xedin commented Apr 6, 2021

@Jumhyn This is in my queue, going to try to look asap.

@Jumhyn Jumhyn force-pushed the placeholder-types branch from 5e0c19d to 11ac05d Compare April 12, 2021 15:24
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I have left some comments inline, but they are mostly minor. I also think it might be worth it to land some part of this PR separately.

@Jumhyn Jumhyn force-pushed the placeholder-types branch from 9901570 to 8e5519e Compare April 17, 2021 03:01
@Jumhyn Jumhyn force-pushed the placeholder-types branch 2 times, most recently from 5403358 to 0c614e3 Compare April 17, 2021 19:23
@Jumhyn
Copy link
Member Author

Jumhyn commented Apr 19, 2021

@xedin So it seems like things mostly work out just fine. The only additional failure is in test/AutoDiff/Sema/differentiable_func_type.swift, where issues that were previously diagnosed as ambiguities now get more specific error messages because some overloads became unviable (now that their parameter types are ErrorType). Also, we no longer diagnose two layers deep on a non-differentiable function with a non-differentiable function result—we'll only diagnose the innermost issue, looks like. The full diff of the necessary diagnostic changes is below—if you think this is acceptable I'll push up the changes!

-// expected-error @+2 {{result type 'Int' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
-// expected-error @+1 {{result type '@differentiable(reverse) (U) -> Int' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
+// expected-error @+1 {{result type 'Int' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
 func test3<T: Differentiable, U: Differentiable>(_: @differentiable(reverse) (T) -> @differentiable(reverse) (U) -> Int) {}
...
-// expected-note  @+5 2 {{found this candidate}}
...
-// expected-error @+1 {{no exact matches in call to global function 'inferredConformancesGenericLinear'}}
+// expected-error @+2 {{global function 'inferredConformancesGenericLinear' requires that 'Int' conform to 'Differentiable'}}
+// expected-error @+1 {{global function 'inferredConformancesGenericLinear' requires that 'Int' conform to 'Differentiable'}}
 inferredConformancesGenericLinear(nondiff)

-// expected-note @+1 2 {{found this candidate}}
+// expected-note  @+2 2 {{where 'T' = 'Int'}}
+// expected-note  @+1 2 {{where 'U' = 'Int'}}
 func inferredConformancesGenericLinear<T, U>(_: @differentiable(_linear) (Linear<T>) -> Linear<U>) {}
...
-// expected-error @+1 {{no exact matches in call to global function 'inferredConformancesGenericLinear'}}
+// expected-error @+2 {{global function 'inferredConformancesGenericLinear' requires that 'Int' conform to 'Differentiable'}}
+// expected-error @+1 {{global function 'inferredConformancesGenericLinear' requires that 'Int' conform to 'Differentiable'}}
 inferredConformancesGenericLinear(nondiff)

Note: we get the diagnostic twice because the parameter and result type both require that Int conform to Differentiable.

@xedin
Copy link
Contributor

xedin commented Apr 22, 2021

@Jumhyn Sorry it took me a bit to respond, I'm on vacation this week. I think new diagnostics make sense, they are definitely better than ambiguities especially considering that other overload is invalid, so I'd say we should proceed with failing in type resolution + failing on coerceToType.

@Jumhyn Jumhyn force-pushed the placeholder-types branch from 0c614e3 to b7a0556 Compare April 22, 2021 13:35
@Jumhyn
Copy link
Member Author

Jumhyn commented Apr 22, 2021

No worries at all @xedin, hope you're having a nice vacation! Please feel free to ignore me until you're back. :)

For whenever you're back: yes, I agree the diagnostics are improved! Just wanted to make sure I wasn't missing anything. I've rebased to fold the type resolution failure into these changes, so I believe all your comments should be addressed at this point.

@Jumhyn Jumhyn requested a review from xedin April 22, 2021 13:36
@Jumhyn Jumhyn force-pushed the placeholder-types branch from b7a0556 to 6b95569 Compare April 23, 2021 20:02
@Jumhyn
Copy link
Member Author

Jumhyn commented May 4, 2021

Hey @xedin, if you're still on vacation then disregard, just wanted to put this back on your radar in case it slipped off while you were out!

@xedin
Copy link
Contributor

xedin commented May 4, 2021

I'm back and it did slip from my radar unfortunately but now it's back in the fold :)

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Jumhyn Jumhyn force-pushed the placeholder-types branch from 6b95569 to 822e947 Compare May 6, 2021 14:29
@Jumhyn
Copy link
Member Author

Jumhyn commented May 6, 2021

@xedin Alright, updated with clang-format's preferred line breaks for that snippet. Thank you!

@Jumhyn Jumhyn requested a review from xedin May 6, 2021 14:31
@jckarter
Copy link
Contributor

Is the [DNM] marker in this title still relevant? Any changes you still want to make before I merge this?

@Jumhyn
Copy link
Member Author

Jumhyn commented May 17, 2021

@jckarter No, assuming that all tests are still passing (🤞) there aren't any changes I intend to make here. Should be merge-ready!

@hborla
Copy link
Member

hborla commented Aug 19, 2021

I think the source compatibility failure will be fixed by #38928, which was just merged.

@swift-ci please test source compatibility

@Jumhyn
Copy link
Member Author

Jumhyn commented Aug 19, 2021

Thank you @hborla! @xedin, looks like this is good to go!

@xedin
Copy link
Contributor

xedin commented Aug 19, 2021

@hborla, @rintaro please take a look and we'll land this if everything looks good.

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a couple of nitpicks

@Jumhyn Jumhyn force-pushed the placeholder-types branch from a7d76ff to c1ed499 Compare August 19, 2021 18:54
@Jumhyn
Copy link
Member Author

Jumhyn commented Aug 19, 2021

Thanks @rintaro, your comments have been addressed!

@Jumhyn Jumhyn requested a review from rintaro August 19, 2021 18:56
@xedin
Copy link
Contributor

xedin commented Aug 19, 2021

@swift-ci please test

@Jumhyn
Copy link
Member Author

Jumhyn commented Aug 19, 2021

@swift-ci please test

@Jumhyn
Copy link
Member Author

Jumhyn commented Aug 20, 2021

@xedin Good to merge?

@rintaro
Copy link
Member

rintaro commented Aug 20, 2021

🎉 @Jumhyn Could you update CHANGELOG.md too?

@Jumhyn
Copy link
Member Author

Jumhyn commented Aug 20, 2021

@rintaro Already opened the PR here, just waiting for tests to complete after the CI outage :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants