fix(ivy): don't accidently read the inherited definition (#25736)

Create getter methods `getXXXDef` for each definition which
uses `hasOwnProperty` to verify that we don't accidently read form the
parent class.

Fixes: #24011
Fixes: #25026

PR Close #25736
This commit is contained in:
Miško Hevery
2018-08-29 16:34:44 -07:00
committed by Igor Minar
parent a9099e8f70
commit d5bd86ae5d
29 changed files with 245 additions and 103 deletions

View File

@ -143,6 +143,23 @@ describe('ngInjectableDef Bazel Integration', () => {
expect(TestBed.get(Service).value).toEqual(true);
});
it('does not override existing ngInjectableDef in case of inheritance', () => {
@Injectable({
providedIn: 'root',
useValue: new ParentService(false),
})
class ParentService {
constructor(public value: boolean) {}
}
// ChildServices exteds ParentService but does not have @Injectable
class ChildService extends ParentService {}
TestBed.configureTestingModule({});
// We are asserting that system throws an error, rather than taking the inherited annotation.
expect(() => TestBed.get(ChildService).value).toThrowError(/ChildService/);
});
it('NgModule injector understands requests for INJECTABLE', () => {
TestBed.configureTestingModule({
providers: [{provide: 'foo', useValue: 'bar'}],