1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
=== tests/cases/compiler/objectCreationOfElementAccessExpression.ts ===
class Food {
>Food : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
private amount: number;
>amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
constructor(public name: string) {
>name : Symbol(Food.name, Decl(objectCreationOfElementAccessExpression.ts, 2, 16))
this.amount = 100;
>this.amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
>this : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
}
public eat(amountToEat: number): boolean {
>eat : Symbol(Food.eat, Decl(objectCreationOfElementAccessExpression.ts, 4, 5))
>amountToEat : Symbol(amountToEat, Decl(objectCreationOfElementAccessExpression.ts, 5, 15))
this.amount -= amountToEat;
>this.amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
>this : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
>amountToEat : Symbol(amountToEat, Decl(objectCreationOfElementAccessExpression.ts, 5, 15))
if (this.amount <= 0) {
>this.amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
>this : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
this.amount = 0;
>this.amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
>this : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>amount : Symbol(Food.amount, Decl(objectCreationOfElementAccessExpression.ts, 0, 12))
return false;
}
else {
return true;
}
}
}
class MonsterFood extends Food {
>MonsterFood : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
>Food : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
constructor(name: string, public flavor: string) {
>name : Symbol(name, Decl(objectCreationOfElementAccessExpression.ts, 17, 16))
>flavor : Symbol(MonsterFood.flavor, Decl(objectCreationOfElementAccessExpression.ts, 17, 29))
super(name);
>super : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>name : Symbol(name, Decl(objectCreationOfElementAccessExpression.ts, 17, 16))
}
}
class IceCream extends MonsterFood {
>IceCream : Symbol(IceCream, Decl(objectCreationOfElementAccessExpression.ts, 20, 1))
>MonsterFood : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
private isDairyFree: boolean;
>isDairyFree : Symbol(IceCream.isDairyFree, Decl(objectCreationOfElementAccessExpression.ts, 21, 36))
constructor(public flavor: string) {
>flavor : Symbol(IceCream.flavor, Decl(objectCreationOfElementAccessExpression.ts, 23, 16))
super("Ice Cream", flavor);
>super : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
>flavor : Symbol(flavor, Decl(objectCreationOfElementAccessExpression.ts, 23, 16))
}
}
class Cookie extends MonsterFood {
>Cookie : Symbol(Cookie, Decl(objectCreationOfElementAccessExpression.ts, 26, 1))
>MonsterFood : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
constructor(public flavor: string, public isGlutenFree: boolean) {
>flavor : Symbol(Cookie.flavor, Decl(objectCreationOfElementAccessExpression.ts, 28, 16))
>isGlutenFree : Symbol(Cookie.isGlutenFree, Decl(objectCreationOfElementAccessExpression.ts, 28, 38))
super("Cookie", flavor);
>super : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
>flavor : Symbol(flavor, Decl(objectCreationOfElementAccessExpression.ts, 28, 16))
}
}
class PetFood extends Food {
>PetFood : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
>Food : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
constructor(name: string, public whereToBuy: number) {
>name : Symbol(name, Decl(objectCreationOfElementAccessExpression.ts, 33, 16))
>whereToBuy : Symbol(PetFood.whereToBuy, Decl(objectCreationOfElementAccessExpression.ts, 33, 29))
super(name);
>super : Symbol(Food, Decl(objectCreationOfElementAccessExpression.ts, 0, 0))
>name : Symbol(name, Decl(objectCreationOfElementAccessExpression.ts, 33, 16))
}
}
class ExpensiveOrganicDogFood extends PetFood {
>ExpensiveOrganicDogFood : Symbol(ExpensiveOrganicDogFood, Decl(objectCreationOfElementAccessExpression.ts, 36, 1))
>PetFood : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
constructor(public whereToBuy: number) {
>whereToBuy : Symbol(ExpensiveOrganicDogFood.whereToBuy, Decl(objectCreationOfElementAccessExpression.ts, 38, 16))
super("Origen", whereToBuy);
>super : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
>whereToBuy : Symbol(whereToBuy, Decl(objectCreationOfElementAccessExpression.ts, 38, 16))
}
}
class ExpensiveOrganicCatFood extends PetFood {
>ExpensiveOrganicCatFood : Symbol(ExpensiveOrganicCatFood, Decl(objectCreationOfElementAccessExpression.ts, 41, 1))
>PetFood : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
constructor(public whereToBuy: number, public containsFish: boolean) {
>whereToBuy : Symbol(ExpensiveOrganicCatFood.whereToBuy, Decl(objectCreationOfElementAccessExpression.ts, 43, 16))
>containsFish : Symbol(ExpensiveOrganicCatFood.containsFish, Decl(objectCreationOfElementAccessExpression.ts, 43, 42))
super("Nature's Logic", whereToBuy);
>super : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
>whereToBuy : Symbol(whereToBuy, Decl(objectCreationOfElementAccessExpression.ts, 43, 16))
}
}
class Slug {
>Slug : Symbol(Slug, Decl(objectCreationOfElementAccessExpression.ts, 46, 1))
// This is NOT a food!!!
}
// ElementAccessExpressions can only contain one expression. There should be a parse error here.
var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
>foods : Symbol(foods, Decl(objectCreationOfElementAccessExpression.ts, 52, 3))
>PetFood : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
>IceCream : Symbol(IceCream, Decl(objectCreationOfElementAccessExpression.ts, 20, 1))
>Cookie : Symbol(Cookie, Decl(objectCreationOfElementAccessExpression.ts, 26, 1))
>Cookie : Symbol(Cookie, Decl(objectCreationOfElementAccessExpression.ts, 26, 1))
var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
>foods2 : Symbol(foods2, Decl(objectCreationOfElementAccessExpression.ts, 53, 3))
>MonsterFood : Symbol(MonsterFood, Decl(objectCreationOfElementAccessExpression.ts, 15, 1))
>PetFood : Symbol(PetFood, Decl(objectCreationOfElementAccessExpression.ts, 31, 1))
>IceCream : Symbol(IceCream, Decl(objectCreationOfElementAccessExpression.ts, 20, 1))
>Cookie : Symbol(Cookie, Decl(objectCreationOfElementAccessExpression.ts, 26, 1))
>Cookie : Symbol(Cookie, Decl(objectCreationOfElementAccessExpression.ts, 26, 1))
|