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

when promoting a type parameter, promote the upper bound #27040

Closed
jmesserly opened this issue Aug 9, 2016 · 5 comments
Closed

when promoting a type parameter, promote the upper bound #27040

jmesserly opened this issue Aug 9, 2016 · 5 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@jmesserly
Copy link

jmesserly commented Aug 9, 2016

given:

void fn/*<T>*/(/*=T*/ object) {
  if (object is String) print(object.substring(1));
}

we will now promote to String (fix for #26965) but even better would be to promote to T extends String

original context here: #26965 (comment)

@jmesserly jmesserly added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-strong-mode P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Aug 9, 2016
@jmesserly
Copy link
Author

This could probably be accomplished by moving the bound to the TypeParameterType. That way you could have multiple TypeParameterTypes that point at the same TypeParameterElement.

@jmesserly
Copy link
Author

Oh for what it's worth ... having type parameters that can track bounds (lower and upper) is essentially what we need for generic method inference. So this might become a lot more tractable when we address https://github.com/dart-lang/sdk/issues/25490 (unified upwards & downwards inference)

@jmesserly
Copy link
Author

Oh wow ... I just stumbled across 66e1a1d ... apparently we have a thing called TypeParameterMember. I wonder if it could be adapted to this use case here.

@jmesserly jmesserly self-assigned this Aug 29, 2016
@jmesserly jmesserly removed their assignment Sep 1, 2016
@jmesserly jmesserly self-assigned this Sep 29, 2016
@jmesserly
Copy link
Author

This shouldn't actually be hard to fix now. Taking a look.

@jmesserly
Copy link
Author

CL has been out for a while now: https://codereview.chromium.org/2375373002, I'm adding some tests based on the feedback. There's still some problematic behavior due to how operator== works for TypeParameterTypeImpl. So it'll be worth thinking over if we want this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

1 participant