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

Polymorphic types and subtyping #46

Open
panagosg7 opened this issue Sep 24, 2014 · 0 comments
Open

Polymorphic types and subtyping #46

panagosg7 opened this issue Sep 24, 2014 · 0 comments

Comments

@panagosg7
Copy link
Contributor

Assume we have a type:

interface A {
  c: int;
  f: forall T . (T) => T; 
}

Then for doing the subtyping:

A <: { f: (int) => int }

we'd have to first unfold A into

{
  c: number;
  f: forall T . (T) => T; 
}

Then deeply instantiate all quantified types:

{
  c: number;
  f: (T0) => T0; 
}

Unify: T0 := int

Finally, do the subtyping:

{ c: number; f: (T0) => T0; } [T0: int] <: { f: (int) => int; } ~> UPCAST

Example:
https://github.com/UCSD-PL/RefScript/blob/poly-subt/tests/pos/simple/contextual.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant