|
| 1 | +=== tests/cases/compiler/strictAssignment4.ts === |
| 2 | +module StrictAssignment4 { |
| 3 | +>StrictAssignment4 : Symbol(StrictAssignment4, Decl(strictAssignment4.ts, 0, 0)) |
| 4 | + |
| 5 | + class Animal {} |
| 6 | +>Animal : Symbol(Animal, Decl(strictAssignment4.ts, 0, 26)) |
| 7 | + |
| 8 | + class Cat { purr() {} } |
| 9 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 10 | +>purr : Symbol(Cat.purr, Decl(strictAssignment4.ts, 2, 15)) |
| 11 | + |
| 12 | + class Dog { bark() {} } |
| 13 | +>Dog : Symbol(Dog, Decl(strictAssignment4.ts, 2, 27)) |
| 14 | +>bark : Symbol(Dog.bark, Decl(strictAssignment4.ts, 3, 15)) |
| 15 | + |
| 16 | + const cats: Cat[] = [new Cat]; |
| 17 | +>cats : Symbol(cats, Decl(strictAssignment4.ts, 5, 9)) |
| 18 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 19 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 20 | + |
| 21 | + function foo(animals: Cat[]): void |
| 22 | +>foo : Symbol(foo, Decl(strictAssignment4.ts, 5, 34), Decl(strictAssignment4.ts, 7, 38)) |
| 23 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 7, 17)) |
| 24 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 25 | + |
| 26 | + function foo(animals: Animal[]): void { |
| 27 | +>foo : Symbol(foo, Decl(strictAssignment4.ts, 5, 34), Decl(strictAssignment4.ts, 7, 38)) |
| 28 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 8, 17)) |
| 29 | +>Animal : Symbol(Animal, Decl(strictAssignment4.ts, 0, 26)) |
| 30 | + } |
| 31 | + foo(cats); // okay, because there's a safe overload |
| 32 | +>foo : Symbol(foo, Decl(strictAssignment4.ts, 5, 34), Decl(strictAssignment4.ts, 7, 38)) |
| 33 | +>cats : Symbol(cats, Decl(strictAssignment4.ts, 5, 9)) |
| 34 | + |
| 35 | + foo([new Cat]); // okay, because there's a safe overload |
| 36 | +>foo : Symbol(foo, Decl(strictAssignment4.ts, 5, 34), Decl(strictAssignment4.ts, 7, 38)) |
| 37 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 38 | + |
| 39 | + function oof(animals: Animal[]): void |
| 40 | +>oof : Symbol(oof, Decl(strictAssignment4.ts, 11, 19), Decl(strictAssignment4.ts, 13, 41)) |
| 41 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 13, 17)) |
| 42 | +>Animal : Symbol(Animal, Decl(strictAssignment4.ts, 0, 26)) |
| 43 | + |
| 44 | + function oof(animals: Cat[]): void { |
| 45 | +>oof : Symbol(oof, Decl(strictAssignment4.ts, 11, 19), Decl(strictAssignment4.ts, 13, 41)) |
| 46 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 14, 17)) |
| 47 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 48 | + } |
| 49 | + // TODO: make it so this isn't an error |
| 50 | + oof(cats); // okay, because there's a safe overload |
| 51 | +>oof : Symbol(oof, Decl(strictAssignment4.ts, 11, 19), Decl(strictAssignment4.ts, 13, 41)) |
| 52 | +>cats : Symbol(cats, Decl(strictAssignment4.ts, 5, 9)) |
| 53 | + |
| 54 | + oof([new Cat]); // okay, because there's a safe overload |
| 55 | +>oof : Symbol(oof, Decl(strictAssignment4.ts, 11, 19), Decl(strictAssignment4.ts, 13, 41)) |
| 56 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 57 | + |
| 58 | + function bar(animals: Dog[]): void |
| 59 | +>bar : Symbol(bar, Decl(strictAssignment4.ts, 18, 19), Decl(strictAssignment4.ts, 20, 38)) |
| 60 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 20, 17)) |
| 61 | +>Dog : Symbol(Dog, Decl(strictAssignment4.ts, 2, 27)) |
| 62 | + |
| 63 | + function bar(animals: Animal[]): void { |
| 64 | +>bar : Symbol(bar, Decl(strictAssignment4.ts, 18, 19), Decl(strictAssignment4.ts, 20, 38)) |
| 65 | +>animals : Symbol(animals, Decl(strictAssignment4.ts, 21, 17)) |
| 66 | +>Animal : Symbol(Animal, Decl(strictAssignment4.ts, 0, 26)) |
| 67 | + } |
| 68 | + bar(cats); // error, there's no safe overload |
| 69 | +>bar : Symbol(bar, Decl(strictAssignment4.ts, 18, 19), Decl(strictAssignment4.ts, 20, 38)) |
| 70 | +>cats : Symbol(cats, Decl(strictAssignment4.ts, 5, 9)) |
| 71 | + |
| 72 | + bar([new Cat]); // error, there's no safe overload |
| 73 | +>bar : Symbol(bar, Decl(strictAssignment4.ts, 18, 19), Decl(strictAssignment4.ts, 20, 38)) |
| 74 | +>Cat : Symbol(Cat, Decl(strictAssignment4.ts, 1, 19)) |
| 75 | +} |
| 76 | + |
0 commit comments