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

[Errors] Type argument inference from signatures infers fewer candidates #49

Closed
mhegazy opened this issue Jul 17, 2014 · 4 comments · Fixed by #624
Closed

[Errors] Type argument inference from signatures infers fewer candidates #49

mhegazy opened this issue Jul 17, 2014 · 4 comments · Fixed by #624
Labels
Fixed A PR has been merged for this issue Spec Issues related to the TypeScript language specification

Comments

@mhegazy
Copy link
Contributor

mhegazy commented Jul 17, 2014

interface Promise<T> {
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>;
done<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}

interface IPromise<T> {
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}

declare function testFunction11(x: number): IPromise<number>;
declare function testFunction11(x: string): IPromise<string>;
declare function testFunction11P(x: number): Promise<number>;
declare function testFunction11P(x: string): Promise<string>; 

var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok

Used to all succeed, but now they all fail. This is because when we collect candidates for U from testFunction11 and testFunction11P, we only use the last overload instead of all the overloads. This is an algorithmic change in the new compiler.

They used to all succeed, but they were Promise<{}>, which is not super meaningful anyway.

r11a has similar behavior in promisePermutations3.ts

@mhegazy mhegazy added this to the TypeScript 1.1 milestone Jul 17, 2014
@mhegazy mhegazy assigned sophiajt and ahejlsberg and unassigned sophiajt and ahejlsberg Jul 17, 2014
@sophiajt sophiajt changed the title [Errors][Design] Type argument inference from signatures infers fewer candidates [Errors] Type argument inference from signatures infers fewer candidates Aug 1, 2014
@sophiajt sophiajt removed the Spec label Aug 1, 2014
@sophiajt
Copy link
Contributor

Treating this like other performance improvements that may have an impact on real world code. Please ensure this does not impact known code before we make this change to the spec.

@sophiajt sophiajt assigned mhegazy and unassigned sophiajt Aug 18, 2014
@mhegazy mhegazy assigned JsonFreeman and unassigned mhegazy Aug 19, 2014
@JsonFreeman
Copy link
Contributor

Keep in mind that this is also addressed by issue #248, which has a proposal for a third algorithm we are considering.

@mhegazy mhegazy modified the milestones: TypeScript 1.1, TypeScript 1.2 Aug 29, 2014
@JsonFreeman
Copy link
Contributor

Closing because we have a new algorithm to try out (namely the one proposed in issue #248)

@JsonFreeman
Copy link
Contributor

Anders, please change the spection 3.8.6 to reflect the new design (that is until we try the new proposal).

@JsonFreeman JsonFreeman reopened this Sep 6, 2014
@JsonFreeman JsonFreeman removed the Bug label Sep 6, 2014
@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Sep 8, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Spec Issues related to the TypeScript language specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants