Skip to content

Do explicit partial generic instantiation generalize to function typed expressions? #1604

Closed
@leafpetersen

Description

@leafpetersen

Implicit instantiation of generic functions, e.g:

void main() {
  void localFn<T>(T x) {
    print(T);
  }

  void Function(int) k0 = localFn;
}

are restricted to cases where the thing being partially instantiated is an identifier which names a function or method declaration. It may not be an arbitrary expression (e.g. a local variable).

Question 1: For the explicit variant, do we intend to relax this (for implicit also?)?
Question 2: If so, we we allow explicit instantiation of this (for implicit and/or explicit)?

extension on void Function<T>(T x) {
  void foo() {
    void Function(int) f = this<int>; // Ok?
    void Function(int) g = this; // Ok?
  }
}

cc @lrhn @eernstg @munificent @natebosch @jakemac53 @stereotype441

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions