mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
This disallows building a facet type that contains another facet type with non-extend constraints in it. Which in turn prevents the possibility of introducing a different `.Self` into a facet type. Eval can still insert a facet type with non-extend constraints, as we only prevent it for `where` being written into the facet type. There is a TODO in handle_where.cpp for this and some tests in toolchain/check/testdata/facet/nested_facet_types_from_eval.carbon
85 lines
3.4 KiB
Plaintext
85 lines
3.4 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/impl_where_redecl.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/impl_where_redecl.carbon
|
|
|
|
// `impl` declarations only match when they are the same syntactically.
|
|
|
|
// --- fail_match_with_associated_type.carbon
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface I { let T:! type; }
|
|
constraint N(U:! type) {}
|
|
|
|
// CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl () as I where .T = {};
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl () as I where .T = {};
|
|
impl () as I where .T = {} and .T impls N(.Self) {}
|
|
|
|
// CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl {} as I;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl {} as I;
|
|
impl {} as I where .T = {} and .T impls N(.Self) {}
|
|
|
|
// CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl ({},) as I where .T = {} and .T impls N(.Self);
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl ({},) as I where .T = {} and .T impls N(.Self);
|
|
impl ({},) as I where .T = {} {}
|
|
|
|
// --- fail_match_with_empty_interface.carbon
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface J {}
|
|
constraint N {}
|
|
|
|
// CHECK:STDERR: fail_match_with_empty_interface.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl () as J;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl () as J;
|
|
impl () as J where .Self impls type and .Self impls N {}
|
|
|
|
// CHECK:STDERR: fail_match_with_empty_interface.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl {} as J where .Self impls type and .Self impls N;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl {} as J where .Self impls type and .Self impls N;
|
|
impl {} as J {}
|
|
|
|
// --- fail_parens_other_nesting.carbon
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface K {}
|
|
|
|
// CHECK:STDERR: fail_parens_other_nesting.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl {} as (K where .Self impls type) where .Self impls type;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl {} as (K where .Self impls type) where .Self impls type;
|
|
impl {} as (K where .Self impls type) {}
|
|
|
|
// --- fail_other_nesting.carbon
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface L {}
|
|
|
|
// CHECK:STDERR: fail_other_nesting.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
|
|
// CHECK:STDERR: impl () as (L where .Self impls type) where .Self impls type;
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
impl () as (L where .Self impls type) where .Self impls type;
|
|
impl () as L {}
|