Skip to content

type parameter bounds for generic methods/functions #27256

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

Closed
vsmenon opened this issue Sep 6, 2016 · 4 comments
Closed

type parameter bounds for generic methods/functions #27256

vsmenon opened this issue Sep 6, 2016 · 4 comments
Assignees
Labels
P2 A bug or feature request we're likely to work on soundness web-dev-compiler

Comments

@vsmenon
Copy link
Member

vsmenon commented Sep 6, 2016

From @jmesserly on April 28, 2016 20:26

The initial implementation will not validate type bounds.

We actually have the same issue with generic classes. But there, it can only be triggered via JavaScript interop, because C<InvalidType> would be rejected at compile time. Generic methods must handle this at run time for dynamic calls.

Since we represent these types as a function like (T, S) => dart.functionType(...), once option is to generate an assertion in the body. Same trick would work for generic classes, although we might not want it there, because it would be triggered (once) for every class, whereas if we look up a runtime type signature of a generic method, we're already in the dynamic dispatch code path.

Copied from original issue: dart-archive/dev_compiler#532

@vsmenon
Copy link
Member Author

vsmenon commented Sep 6, 2016

From @jmesserly on April 28, 2016 20:36

(Note, if we ever want mirror support for type bounds, we'll need to store this in a way we can get at it. https://api.dartlang.org/stable/1.16.0/dart-mirrors/TypeVariableMirror-class.html -- that's pretty obscure though, unclear where mirrors is headed for DDC)

@vsmenon vsmenon added web-dev-compiler P2 A bug or feature request we're likely to work on soundness dev-compiler-generic-methods labels Sep 6, 2016
@vsmenon
Copy link
Member Author

vsmenon commented Sep 6, 2016

From @jmesserly on April 28, 2016 23:23

Oh also: we'll need to instantiate to bounds at runtime in dcall/dsend. This is not implemented yet. Perhaps we can do default values on the type parameters. edit: nvm, that would require everything to include dart.dynamic, there are probably better approaches

@vsmenon vsmenon modified the milestone: 1.50 Jan 6, 2017
@dgrove dgrove modified the milestones: 1.50, 1.23 Feb 14, 2017
@vsmenon vsmenon modified the milestone: 1.23 Mar 6, 2017
@jmesserly jmesserly self-assigned this Apr 7, 2017
@jmesserly jmesserly changed the title validate type bounds in dynamic generic method call type parameter bounds for generic methods/functions Apr 18, 2017
@jmesserly
Copy link

Note, this also affects our ability to do subtype checks on the bounds given two generic function types..

@jmesserly
Copy link

jmesserly pushed a commit that referenced this issue May 9, 2017
This reverts commit 3a23e60.

The problem was unrelated to the CL; it appears to be a dart:async break of package:async.

In the meantime we have turned on --unsafe-force-compile to DDC's shapshotting step

Review-Url: https://codereview.chromium.org/2869733006 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on soundness web-dev-compiler
Projects
None yet
Development

No branches or pull requests

3 participants