mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 23:38:10 +00:00
When building an impl witness thunk for a generic associated function, trailing self-specific arguments could still mention outer interface parameters (or `Self`) in their types. That left a SymbolicBinding that did not belong to the thunk's generic, and evaluation aborted instead of succeeding. Substitute the outer specific arguments into those trailing arguments with `SubstConstant` before adjusting bind indices. Fixes #7919.
70 lines
1.5 KiB
Plaintext
70 lines
1.5 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/generic_method_constraint.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/generic_method_constraint.carbon
|
|
|
|
// Regression tests for https://github.com/carbon-language/carbon-lang/issues/7919:
|
|
// building an impl witness thunk must not crash when an associated function's
|
|
// generic parameter constraint depends on an enclosing interface parameter.
|
|
|
|
// --- dependent_on_interface_param.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface A(T: type) {
|
|
fn F(self);
|
|
}
|
|
|
|
interface B(T: type) {
|
|
fn G[U: A(T)](u: U);
|
|
}
|
|
|
|
class C {}
|
|
|
|
impl C as B(()) {
|
|
fn G[U: A(())](unused u: U) {}
|
|
}
|
|
|
|
// --- dependent_on_self.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface A(T: type) {
|
|
fn F(self);
|
|
}
|
|
|
|
interface B(T: type) {
|
|
fn G[U: A(Self)](u: U);
|
|
}
|
|
|
|
class C {}
|
|
|
|
impl C as B(()) {
|
|
fn G[U: A(C)](unused u: U) {}
|
|
}
|
|
|
|
// --- independent_constraint_still_ok.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
interface A {
|
|
fn F(self);
|
|
}
|
|
|
|
interface B(T: type) {
|
|
fn G[U: A](u: U, t: T);
|
|
}
|
|
|
|
class C {}
|
|
|
|
impl C as B(()) {
|
|
fn G[U: A](unused u: U, unused t: ()) {}
|
|
}
|