Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions toolchain/check/testdata/facet/period_self.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,42 @@ interface I(T:! Core.Destroy) {}
// The `.Self` can see the LHS of the `where` to know `U` impls Core.Destroy.
fn F(U:! Core.Destroy where .Self impls I(.Self)) {}

// --- fail_todo_period_self_parameter_constraint_satisfied_with_type_and.carbon
library "[[@TEST_NAME]]";

interface I(T:! Core.Destroy) {}

// TODO: Implied constraints that `.Self` impls `Core.Destroy` are satisfied by
// the `&` expression.
//
// CHECK:STDERR: fail_todo_period_self_parameter_constraint_satisfied_with_type_and.carbon:[[@LINE+7]]:25: error: cannot convert type `.Self` that implements `type` into type implementing `Core.Destroy` [ConversionFailureFacetToFacet]
// CHECK:STDERR: fn F(U:! Core.Destroy & I(.Self)) {}
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_todo_period_self_parameter_constraint_satisfied_with_type_and.carbon:[[@LINE-8]]:13: note: initializing generic parameter `T` declared here [InitializingGenericParam]
// CHECK:STDERR: interface I(T:! Core.Destroy) {}
// CHECK:STDERR: ^
// CHECK:STDERR:
fn F(U:! Core.Destroy & I(.Self)) {}

// --- fail_todo_compound_lookup_on_returned_period_self_parameter.carbon
library "[[@TEST_NAME]]";

interface I(T:! Core.Destroy) {
fn G[self: Self]() -> T;
}

fn F[U:! Core.Destroy where .Self impls I(.Self)](u: U) {
// This tests that both `I.G` is accessible and that `Destroy` is preserved;
// we'd get an error for missing Destroy otherwise since G() returns an
// initializing expression.

// CHECK:STDERR: fail_todo_compound_lookup_on_returned_period_self_parameter.carbon:[[@LINE+4]]:3: error: cannot access member of interface `I(U as Core.Destroy)` in type `U` that does not implement that interface [MissingImplInMemberAccess]
// CHECK:STDERR: u.(I(U).G)().(I(U).G)().(I(U).G)();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR:
u.(I(U).G)().(I(U).G)().(I(U).G)();
}

// CHECK:STDOUT: --- period_self_param.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
Expand Down
Loading