fail_instantiate_abstract_class_constructor.carbon 679 B

123456789101112131415161718192021
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. abstract class C {
  8. // TODO: Returning `Self` for an abstract class should error: `partial Self` should be used instead. This should be updated when `partial` is implemented.
  9. fn Create() -> Self {
  10. return { .a = 1 };
  11. }
  12. var a: i32;
  13. }
  14. fn Main() -> i32 {
  15. // CHECK:STDERR: COMPILATION ERROR: fail_instantiate_abstract_class_constructor.carbon:[[@LINE+1]]: Cannot instantiate abstract class C
  16. var c: C = C.Create();
  17. return 0;
  18. }