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:
@ -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'}],
|
||||
|
Reference in New Issue
Block a user