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

VM: Type argument confusion for generic method with generic function typed parameter #37382

Closed
eernstg opened this issue Jun 27, 2019 · 0 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@eernstg
Copy link
Member

eernstg commented Jun 27, 2019

Consider the following program, which was executed with dart from c4af35c:

class A<X> {
  R f<R>(R Function<X>(A<X>) f) => f<X>(this);
}

main() {
  A<num> a = A<int>();
  print(a.f.runtimeType); // `dart` prints '<R>(<X>(A<R>) => R) => R'.
}

The type of A<int>().f should be R Function<R>(R Function<X>(A<X>)), but the printed text means R Function<R>(R Function<X>(A<R>)), so somehow the type parameter R of the method is used in a location where the type argument X of the parameter type should be.

Note that dart2js prints <T1>(<T2>(A<T2>) => T1) => T1, which is correct, so there must be some dart specific part to this.

Note the related issue #37381.

@eernstg eernstg added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jun 27, 2019
@zichangg zichangg self-assigned this Jul 1, 2019
dart-bot pushed a commit that referenced this issue Jul 10, 2019
When calling SetupFunctionParameters, Function type arguments were copied into local type parameters. Local type parameters = previous type parameter + function type parameters.
At BuildTypeParameterType(), local type parameters contains duplicated type parameter from function, which ends up with returning wrong type.

Bug: #37382
Change-Id: I8f486b0b9a9120845349fe1734bbfcc35f1126a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108501
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants