|
16 | 16 |
|
17 | 17 | package dagger.internal.codegen; |
18 | 18 |
|
19 | | -import androidx.room.compiler.processing.XProcessingEnv; |
20 | 19 | import androidx.room.compiler.processing.util.Source; |
21 | 20 | import dagger.testing.compile.CompilerTests; |
22 | 21 | import org.junit.Test; |
@@ -300,230 +299,4 @@ public void provideExplicitSetInParent_AndMultibindingContributionInChild() { |
300 | 299 | .onLineContaining("interface Parent"); |
301 | 300 | }); |
302 | 301 | } |
303 | | - |
304 | | - // Regression test for b/352142595. |
305 | | - @Test |
306 | | - public void testMultibindingMapWithKotlinSource() { |
307 | | - Source parent = |
308 | | - CompilerTests.kotlinSource( |
309 | | - "test.Parent.kt", |
310 | | - "package test", |
311 | | - "", |
312 | | - "import dagger.Component", |
313 | | - "", |
314 | | - "@Component(modules = [ParentModule::class])", |
315 | | - "interface Parent {", |
316 | | - " fun usage(): Usage", |
317 | | - "}"); |
318 | | - Source usage = |
319 | | - CompilerTests.kotlinSource( |
320 | | - "test.Usage.kt", |
321 | | - "package test", |
322 | | - "", |
323 | | - "import javax.inject.Inject", |
324 | | - "", |
325 | | - "class Usage @Inject constructor(map: Map<String, MyInterface>)"); |
326 | | - Source parentModule = |
327 | | - CompilerTests.kotlinSource( |
328 | | - "test.ParentModule.kt", |
329 | | - "@file:Suppress(\"INLINE_FROM_HIGHER_PLATFORM\")", // Required to use TODO() |
330 | | - "package test", |
331 | | - "", |
332 | | - "import dagger.Module", |
333 | | - "import dagger.Provides", |
334 | | - "import dagger.multibindings.IntoMap", |
335 | | - "import dagger.multibindings.StringKey", |
336 | | - "", |
337 | | - "@Module", |
338 | | - "class ParentModule {", |
339 | | - " @Provides", |
340 | | - " @IntoMap", |
341 | | - " @StringKey(\"key\")", |
342 | | - " fun provideMyInterface(): MyInterface = TODO()", |
343 | | - "}"); |
344 | | - Source myInterface = |
345 | | - CompilerTests.kotlinSource( |
346 | | - "test.MyInterface.kt", |
347 | | - "package test", |
348 | | - "", |
349 | | - "interface MyInterface"); |
350 | | - |
351 | | - CompilerTests.daggerCompiler(parent, parentModule, myInterface, usage) |
352 | | - .compile( |
353 | | - subject -> { |
354 | | - // TODO(b/284207175): Due to a bug in our KSP implementation, KSP and Javac behave |
355 | | - // differently. Rather than cause a breaking change by fixing this bug directly, we've |
356 | | - // decided to wait until b/284207175 is implemented. |
357 | | - if (CompilerTests.backend(subject) == XProcessingEnv.Backend.KSP) { |
358 | | - subject.hasErrorCount(0); |
359 | | - } else { |
360 | | - subject.hasErrorCount(1); |
361 | | - subject.hasErrorContaining("Map<String,? extends MyInterface> cannot be provided"); |
362 | | - } |
363 | | - }); |
364 | | - } |
365 | | - |
366 | | - // Regression test for b/352142595. |
367 | | - @Test |
368 | | - public void testMultibindingMapProviderWithKotlinSource() { |
369 | | - Source parent = |
370 | | - CompilerTests.kotlinSource( |
371 | | - "test.Parent.kt", |
372 | | - "package test", |
373 | | - "", |
374 | | - "import dagger.Component", |
375 | | - "", |
376 | | - "@Component(modules = [ParentModule::class])", |
377 | | - "interface Parent {", |
378 | | - " fun usage(): Usage", |
379 | | - "}"); |
380 | | - Source usage = |
381 | | - CompilerTests.kotlinSource( |
382 | | - "test.Usage.kt", |
383 | | - "package test", |
384 | | - "", |
385 | | - "import javax.inject.Inject", |
386 | | - "import javax.inject.Provider", |
387 | | - "", |
388 | | - "class Usage @Inject constructor(map: Map<String, Provider<MyInterface>>)"); |
389 | | - Source parentModule = |
390 | | - CompilerTests.kotlinSource( |
391 | | - "test.ParentModule.kt", |
392 | | - "@file:Suppress(\"INLINE_FROM_HIGHER_PLATFORM\")", // Required to use TODO() |
393 | | - "package test", |
394 | | - "", |
395 | | - "import dagger.Module", |
396 | | - "import dagger.Provides", |
397 | | - "import dagger.multibindings.IntoMap", |
398 | | - "import dagger.multibindings.StringKey", |
399 | | - "", |
400 | | - "@Module", |
401 | | - "class ParentModule {", |
402 | | - " @Provides", |
403 | | - " @IntoMap", |
404 | | - " @StringKey(\"key\")", |
405 | | - " fun provideMyInterface(): MyInterface = TODO()", |
406 | | - "}"); |
407 | | - Source myInterface = |
408 | | - CompilerTests.kotlinSource( |
409 | | - "test.MyInterface.kt", |
410 | | - "package test", |
411 | | - "", |
412 | | - "interface MyInterface"); |
413 | | - |
414 | | - CompilerTests.daggerCompiler(parent, parentModule, myInterface, usage) |
415 | | - .compile( |
416 | | - subject -> { |
417 | | - subject.hasErrorCount(1); |
418 | | - subject.hasErrorContaining( |
419 | | - "Map<String,? extends Provider<MyInterface>> cannot be provided"); |
420 | | - }); |
421 | | - } |
422 | | - |
423 | | - // Regression test for b/352142595. |
424 | | - @Test |
425 | | - public void testMultibindingSetWithKotlinSource() { |
426 | | - Source parent = |
427 | | - CompilerTests.kotlinSource( |
428 | | - "test.Parent.kt", |
429 | | - "package test", |
430 | | - "", |
431 | | - "import dagger.Component", |
432 | | - "", |
433 | | - "@Component(modules = [ParentModule::class])", |
434 | | - "interface Parent {", |
435 | | - " fun usage(): Usage", |
436 | | - "}"); |
437 | | - Source usage = |
438 | | - CompilerTests.kotlinSource( |
439 | | - "test.Usage.kt", |
440 | | - "package test", |
441 | | - "", |
442 | | - "import javax.inject.Inject", |
443 | | - "", |
444 | | - "class Usage @Inject constructor(set: Set<MyInterface>)"); |
445 | | - Source parentModule = |
446 | | - CompilerTests.kotlinSource( |
447 | | - "test.ParentModule.kt", |
448 | | - "@file:Suppress(\"INLINE_FROM_HIGHER_PLATFORM\")", // Required to use TODO() |
449 | | - "package test", |
450 | | - "", |
451 | | - "import dagger.Module", |
452 | | - "import dagger.Provides", |
453 | | - "import dagger.multibindings.IntoSet", |
454 | | - "", |
455 | | - "@Module", |
456 | | - "class ParentModule {", |
457 | | - " @Provides", |
458 | | - " @IntoSet", |
459 | | - " fun provideMyInterface(): MyInterface = TODO()", |
460 | | - "}"); |
461 | | - Source myInterface = |
462 | | - CompilerTests.kotlinSource( |
463 | | - "test.MyInterface.kt", |
464 | | - "package test", |
465 | | - "", |
466 | | - "interface MyInterface"); |
467 | | - |
468 | | - CompilerTests.daggerCompiler(parent, parentModule, myInterface, usage) |
469 | | - .compile( |
470 | | - subject -> { |
471 | | - subject.hasErrorCount(1); |
472 | | - subject.hasErrorContaining("Set<? extends MyInterface> cannot be provided"); |
473 | | - }); |
474 | | - } |
475 | | - |
476 | | - // Regression test for b/352142595. |
477 | | - @Test |
478 | | - public void testMultibindingSetProviderWithKotlinSource() { |
479 | | - Source parent = |
480 | | - CompilerTests.kotlinSource( |
481 | | - "test.Parent.kt", |
482 | | - "package test", |
483 | | - "", |
484 | | - "import dagger.Component", |
485 | | - "", |
486 | | - "@Component(modules = [ParentModule::class])", |
487 | | - "interface Parent {", |
488 | | - " fun usage(): Usage", |
489 | | - "}"); |
490 | | - Source usage = |
491 | | - CompilerTests.kotlinSource( |
492 | | - "test.Usage.kt", |
493 | | - "package test", |
494 | | - "", |
495 | | - "import javax.inject.Inject", |
496 | | - "import javax.inject.Provider", |
497 | | - "", |
498 | | - "class Usage @Inject constructor(set: Set<Provider<MyInterface>>)"); |
499 | | - Source parentModule = |
500 | | - CompilerTests.kotlinSource( |
501 | | - "test.ParentModule.kt", |
502 | | - "@file:Suppress(\"INLINE_FROM_HIGHER_PLATFORM\")", // Required to use TODO() |
503 | | - "package test", |
504 | | - "", |
505 | | - "import dagger.Module", |
506 | | - "import dagger.Provides", |
507 | | - "import dagger.multibindings.IntoSet", |
508 | | - "", |
509 | | - "@Module", |
510 | | - "class ParentModule {", |
511 | | - " @Provides", |
512 | | - " @IntoSet", |
513 | | - " fun provideMyInterface(): MyInterface = TODO()", |
514 | | - "}"); |
515 | | - Source myInterface = |
516 | | - CompilerTests.kotlinSource( |
517 | | - "test.MyInterface.kt", |
518 | | - "package test", |
519 | | - "", |
520 | | - "interface MyInterface"); |
521 | | - |
522 | | - CompilerTests.daggerCompiler(parent, parentModule, myInterface, usage) |
523 | | - .compile( |
524 | | - subject -> { |
525 | | - subject.hasErrorCount(1); |
526 | | - subject.hasErrorContaining("Set<? extends Provider<MyInterface>> cannot be provided"); |
527 | | - }); |
528 | | - } |
529 | 302 | } |
0 commit comments