fail_incomplete.carbon 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/facet/fail_incomplete.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/fail_incomplete.carbon
  12. interface A;
  13. interface B {}
  14. class C {}
  15. fn G[T:! A](t: T) {}
  16. fn H[T:! A & B](t: T) {}
  17. fn F() {
  18. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+4]]:17: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
  19. // CHECK:STDERR: ({} as C) as (C as A);
  20. // CHECK:STDERR: ^~~~~~
  21. // CHECK:STDERR:
  22. ({} as C) as (C as A);
  23. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+4]]:17: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
  24. // CHECK:STDERR: ({} as C) as (C as (A & B));
  25. // CHECK:STDERR: ^~~~~~~~~~~~
  26. // CHECK:STDERR:
  27. ({} as C) as (C as (A & B));
  28. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A` [ConversionFailureTypeToFacet]
  29. // CHECK:STDERR: G({} as C);
  30. // CHECK:STDERR: ^~~~~~~~~~
  31. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE-19]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
  32. // CHECK:STDERR: fn G[T:! A](t: T) {}
  33. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  34. // CHECK:STDERR:
  35. G({} as C);
  36. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `A & B` [ConversionFailureTypeToFacet]
  37. // CHECK:STDERR: H({} as C);
  38. // CHECK:STDERR: ^~~~~~~~~~
  39. // CHECK:STDERR: fail_incomplete.carbon:[[@LINE-27]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
  40. // CHECK:STDERR: fn H[T:! A & B](t: T) {}
  41. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  42. // CHECK:STDERR:
  43. H({} as C);
  44. }