Skip to content

Allow generic function instantiation of an existing function object #1812

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 5 commits into from
Sep 2, 2021

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Aug 20, 2021

Update section "Generic Function Instantiation" to allow this operation on an existing function object, in addition to the currently supported cases (where the expression denotes a declaration).

This update does not yet mention explicit instantiation, but I think the work needed to allow the current generalization and the work needed to support explicit instantiation are rather well separated. So it's not a waste of time to those two things in two steps (and we can then do 'constructor-tearoffs' as one single update, which is probably also nice).

@eernstg eernstg requested a review from lrhn August 20, 2021 17:48
@eernstg eernstg changed the title Allow generic function instantiation on an existing function object Allow generic function instantiation of an existing function object Aug 20, 2021
@eernstg
Copy link
Member Author

eernstg commented Aug 23, 2021

@lrhn, I removed the review request because I'm revising this PR. I'll restore it when the text is stable again.

@eernstg eernstg removed the request for review from lrhn August 23, 2021 08:09
@eernstg eernstg requested a review from lrhn August 23, 2021 08:42
@eernstg
Copy link
Member Author

eernstg commented Aug 23, 2021

The rules are now much more compositional (identical/== for the whole is determined by identical/== on the parts). Restored the review request.

Copy link
Member Author

@eernstg eernstg left a comment

Choose a reason for hiding this comment

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

Review response.

@eernstg
Copy link
Member Author

eernstg commented Aug 24, 2021

Added one change which was omitted by accident at first: The PR now also removes the rule which makes it an error to perform a generic method instantiation on the call method of a function object. We only introduced that error because we thought we couldn't do that, but this whole PR is about doing it anyway.

Copy link
Member Author

@eernstg eernstg left a comment

Choose a reason for hiding this comment

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

Review response.

@eernstg
Copy link
Member Author

eernstg commented Aug 30, 2021

A few experiments with the current implementations show that we do actually allow for the tearoff.

One might think "Sure, why not?", but we specified that it isn't possible, so I created #1827 to raise the question and perhaps decide that we should just support both the closurization and the generic function instantiation on an e that has been desugared to e.call (including e<T> which has been extended to e.call<T>).

dart-bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 1, 2021
…ions

This allows local variables and other expressions, as long as the
static type is a generic function type, to be explicitly type
instantiated.

* Expressions with a non-generic function type cannot be type
  instantiated.
* Expressions with a type of `Function` cannot be type instantiated.
* Expressions with other non-function types cannot be type instantiated.

This results in doubling-up of errors in a few situations. I think these
are generally rare occurrences, and tricky to prevent double reporting,
so I've left them for now.

Bug: #46020,
Change-Id: Iad212fd95773f39f3202480b3fa71f6a28c7698f
dart-lang/language#1812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211941
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
@eernstg eernstg merged commit ec8ec1b into master Sep 2, 2021
@eernstg eernstg deleted the specify_instantiate_function_aug21 branch September 2, 2021 17:39
dart-bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 8, 2021
dart-lang/language#1812

Closes #47147

Change-Id: Iaba365a583bca456c19a6edba8801bab630304c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212590
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants