|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import * as assert from 'assert'; |
7 | | -import { createDecorator, optional, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; |
| 7 | +import { createDecorator, IInstantiationService, optional, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; |
8 | 8 | import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; |
9 | 9 | import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; |
10 | 10 | import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; |
@@ -392,4 +392,36 @@ suite('Instantiation Service', () => { |
392 | 392 |
|
393 | 393 | assert.equal(serviceInstanceCount, 1); |
394 | 394 | }); |
| 395 | + |
| 396 | + test('Remote window / integration tests is broken #105562', function () { |
| 397 | + |
| 398 | + const Service1 = createDecorator<any>('service1'); |
| 399 | + class Service1Impl { |
| 400 | + constructor(@IInstantiationService insta: IInstantiationService) { |
| 401 | + const c = insta.invokeFunction(accessor => accessor.get(Service2)); // THIS is the recursive call |
| 402 | + assert.ok(c); |
| 403 | + } |
| 404 | + } |
| 405 | + const Service2 = createDecorator<any>('service2'); |
| 406 | + class Service2Impl { |
| 407 | + constructor() { } |
| 408 | + } |
| 409 | + |
| 410 | + // This service depends on Service1 and Service2 BUT creating Service1 creates Service2 (via recursive invocation) |
| 411 | + // and then Servce2 should not be created a second time |
| 412 | + const Service21 = createDecorator<any>('service21'); |
| 413 | + class Service21Impl { |
| 414 | + constructor(@Service2 readonly service2: Service2Impl, @Service1 readonly service1: Service1Impl) { } |
| 415 | + } |
| 416 | + |
| 417 | + const insta = new InstantiationService(new ServiceCollection( |
| 418 | + [Service1, new SyncDescriptor(Service1Impl)], |
| 419 | + [Service2, new SyncDescriptor(Service2Impl)], |
| 420 | + [Service21, new SyncDescriptor(Service21Impl)], |
| 421 | + )); |
| 422 | + |
| 423 | + const obj = insta.invokeFunction(accessor => accessor.get(Service21)); |
| 424 | + assert.ok(obj); |
| 425 | + }); |
| 426 | + |
395 | 427 | }); |
0 commit comments