Skip to content
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

Allow embedded type parameters in references #2772

Merged

Conversation

jcollins-g
Copy link
Contributor

@jcollins-g jcollins-g commented Sep 3, 2021

Continues work for #2655.

Given that type parameters have more interesting uses with tearoffs now, add the capacity to embed (and ignore) type parameters inside comment references. They are ignored because a single reference can still only point to a single page.

@google-cla google-cla bot added the cla: yes Google CLA check succeeded. label Sep 3, 2021
@@ -203,6 +203,31 @@ void main() {
expect(referenceLookup(constructorTearoffs, 'Ft.new'),
equals(MatchingLinkResult(Fnew)));
});

test('we can use (ignored) type parameters in references', () {
expect(referenceLookup(E, 'D<String>.new'),
Copy link
Member

Choose a reason for hiding this comment

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

A type argument can also be a prefixed identifier, like <core.String>.

By all means, does not have to be addressed in this CL, but maybe a TODO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Didn't add a test for that, but should be supported by the code here as well.

@srawlins
Copy link
Member

srawlins commented Sep 3, 2021

Everything in this PR refers to "type parameters" but is really concerned with "type arguments", at least as far as the analyzer API and language spec are concerned. In that verbiage:

  • Type parameter is an element specifying a generic type on a class, function type, alias, mixin, extension, or function, (like T in class A<T> {})
  • Type argument is a type which is being used to instantiate a type parameter, e.g. int in List<int> a or T in List<T> a.
  • Type variable is a classification of a static type, separating it from "class" or "interface type." E.g. T in T get first => ...`. I'm less certain of this one; it might just be an informal term I've seen used.

If "type parameters" are the term used throughout dartdoc though, than I think its fine to keep using in this PR for consistency. WDYT?

@jcollins-g
Copy link
Contributor Author

@srawlins Part of the problem here is we allow people to pretend they are using arguments or type parameters interchangeably in dartdoc comment references and unfortunately that has spilled out not only into the rest of the code but into my brain when I talk about them. I really should go back and fix all of that, I'll give that a try for this PR.

jcollins-g added a commit to jcollins-g/dartdoc that referenced this pull request Sep 7, 2021
@jcollins-g
Copy link
Contributor Author

renamed some things here. PTAL

@jcollins-g jcollins-g merged commit a6b2eb9 into dart-lang:master Sep 8, 2021
@jcollins-g jcollins-g deleted the constructor-tearoffs+typeparams branch September 8, 2021 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants