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

support instantiated tear-offs #525

Closed
2 of 3 tasks
jmesserly opened this issue Apr 25, 2016 · 3 comments
Closed
2 of 3 tasks

support instantiated tear-offs #525

jmesserly opened this issue Apr 25, 2016 · 3 comments

Comments

@jmesserly
Copy link
Contributor

jmesserly commented Apr 25, 2016

Initial implementation of #301 may not cover this.

  • identify these nodes in the AST by examining the staticType
  • emit the instantiation
  • ensure RTTI is associated

The nodes this can happen to are: PropertyAccess, PrefixedIdentifier and SimpleIdentifier.

You can't write the instantiation explicitly yet (o.m<String>) but it can be inferred by the type system. These do come up in practice, so we shouldn't defer this one too long. For example, passing a generic function to something that expects a non-generic function type.

@jmesserly
Copy link
Contributor Author

Now that the CL is out for #301, I will take a look at this one

@jmesserly
Copy link
Contributor Author

jmesserly commented Apr 29, 2016

Here's an example:

import 'dart:math' show min; // <-- generic: <T extends num>(T, T) -> T
typedef int Int2Int2Int(int x, int y);
main() {
  Int2Int2Int f = min; // Strong mode infers: `min<int>`
  int y = f(123, 456); // should work in DDC
  (f as dynamic)/*<int>*/(123, 456); // runtime error: can't pass type args, `f` doesn't take type args
  (min as dynamic)/*<int>*/(123, 456); // this should work: dynamic call with type args
  (min as dynamic)(123, 456); // this too
  print(y);
}

@jmesserly
Copy link
Contributor Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant