-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Class<> annotations for subtyping, and require subtyping on inter…
…face statics
- Loading branch information
Showing
3 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class A {} | ||
class B extends A {} | ||
|
||
class K { | ||
static gn() { | ||
return this; | ||
} | ||
} | ||
|
||
class L extends K { | ||
static gn() { // NG Bug: False positive. | ||
return L; | ||
} | ||
} | ||
|
||
class W { | ||
fn(): Class<A> { | ||
return B; | ||
} | ||
static fn(): Class<A> { | ||
return B; | ||
} | ||
static gn(): Class<W> { | ||
return W; | ||
} | ||
} | ||
|
||
class X extends W { | ||
static gn(): Class<this> { | ||
return this; | ||
} | ||
} | ||
|
||
class Y extends X { | ||
static gn(): Class<Y> { //NG | ||
return Y; | ||
} | ||
} | ||
|
||
var a: Class<W> = X.gn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
interface I { | ||
fn(): number; | ||
static gn(): number; | ||
} | ||
|
||
class A {} | ||
var a = new A(); | ||
var p: A & I = a; // NG | ||
var P: Class<A> & Class<I> = A; // NG | ||
|
||
class B extends A { | ||
fn(): number { | ||
return 1; | ||
} | ||
static gn(): number { | ||
return 2; | ||
} | ||
} | ||
var b = new B(); | ||
var q: A & I = b; // OK | ||
var Q: Class<A> & Class<I> = B; // OK |