Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

validate type bounds in dynamic generic method call #532

Closed
jmesserly opened this issue Apr 28, 2016 · 3 comments
Closed

validate type bounds in dynamic generic method call #532

jmesserly opened this issue Apr 28, 2016 · 3 comments

Comments

@jmesserly
Copy link
Contributor

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.

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.

@jmesserly
Copy link
Contributor Author

(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)

@jmesserly
Copy link
Contributor Author

jmesserly commented Apr 28, 2016

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
Copy link
Contributor

vsmenon commented Sep 6, 2016

This issue was moved to dart-lang/sdk#27256

@vsmenon vsmenon closed this as completed Sep 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants