Move self to the explicit () parameter list (proposal #7016) (#7272)

Implements proposal #7016: `self` moves from the deduced implicit list
(`fn F[self: Self]()`) to the front of the explicit list. Its type may
be written explicitly (`fn F(self: Self)`) or omitted, in which case it
defaults to `Self` (`fn F(self)`, `fn F(ref self)`); `self` in the
implicit list is rejected.

Throughout checking, `self` is modeled as the first explicit parameter.
Because a method is just a function whose first parameter is `self`, it
can also be called as an ordinary function with the receiver passed
explicitly (`Type.M(obj, ...)`), not only as `obj.M(...)`. A new
`SemIR::CallArgParamPatterns` helper chooses the parameters matched
against the explicit arguments, excluding a leading `self` only when it
is supplied as a method-call receiver; arity checking, conversion, and
generic deduction use it. The resulting SemIR and lowering are
unchanged: `self` is still `call_param0`, and witnesses, thunks, and
vtables are unaffected.

An omitted `self` type is parsed as a `SelfBindingPattern` node with no
type expression; checking synthesizes the `Self` type so it behaves
exactly like `self: Self`. However, the exact spelling used must match
between a forward declaration and a definition, following #3763's rules
around declaration matching.

Generated functions, thunks, and C++ interop import/export build `self`
as the first explicit parameter, and the `self`-type override (e.g.
Derived->Base for a virtual override) applies to the explicit `self`.
Placement is validated by new diagnostics: `SelfInImplicitParamList`,
`SelfNotFirstParam`, and `SelfOutsideParamList`. The benchmark source
generator and the documentation adopt the `(self)` shorthand; the
prelude, the examples, and the test data are migrated in the following
commits.

Assisted-by: Claude Code with Claude Opus 4.7

---------

Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
This commit is contained in:
Chandler Carruth
2026-06-10 15:30:43 +00:00
committed by GitHub
co-authored by josh11b
parent fb05da761f
commit 7871237c15
296 changed files with 6101 additions and 4899 deletions
-1
View File
@@ -1 +0,0 @@
bazel-out/../../_main
+12 -12
View File
@@ -7,7 +7,7 @@ package Core library "prelude/copy";
// Copying an object, which is a conversion from a value representation to an
// initializing representation.
interface Copy {
fn Op[self: Self]() -> Self;
fn Op(self) -> Self;
}
private fn MakeBool() -> type = "bool.make_type";
@@ -20,52 +20,52 @@ private fn MakeIntLiteral() -> type = "int_literal.make_type";
private alias IntLiteral = MakeIntLiteral();
impl forall [T:! Copy] const T as Copy {
fn Op[self: Self]() -> Self { return (self as T).(Copy.Op)() as const T; }
fn Op(self) -> Self { return (self as T).(Copy.Op)() as const T; }
}
impl Bool as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl CharLiteral as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl FloatLiteral as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl IntLiteral as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl type as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl forall [T:! type] T* as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// TODO: Implement tuple copy as a variadic generic impl.
impl () as Copy {
fn Op[self: Self]() -> Self = "no_op";
fn Op(self) -> Self = "no_op";
}
impl forall [T:! Copy] (T,) as Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return (self.0.Op(),);
}
}
impl forall [T:! Copy, U:! Copy] (T, U) as Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return (self.0.Op(), self.1.Op());
}
}
impl forall [T:! Copy, U:! Copy, V:! Copy] (T, U, V) as Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return (self.0.Op(), self.1.Op(), self.2.Op());
}
}
+2 -2
View File
@@ -6,11 +6,11 @@ package Core library "prelude/destroy";
// TODO: Add `Destructor`, as in:
// interface Destructor {
// private fn Op[ref self: Self]();
// private fn Op(ref self);
// }
// Destroys objects. This will invoke `Destructor` impls recursively on members;
// it does not deallocate memory.
interface Destroy {
fn Op[ref self: Self]();
fn Op(ref self);
}
+8 -8
View File
@@ -13,15 +13,15 @@ interface Iterate {
// TODO: Support iterating ranges of non-copyable values.
let ElementType:! Copy & Destroy;
let CursorType:! Destroy;
fn NewCursor[self: Self]() -> CursorType;
fn Next[self: Self](cursor: CursorType*) -> Optional(ElementType);
fn NewCursor(self) -> CursorType;
fn Next(self, cursor: CursorType*) -> Optional(ElementType);
}
impl forall [T:! Copy & Destroy, N:! IntLiteral]
array(T, N) as Iterate
where .ElementType = T and .CursorType = i32 {
fn NewCursor[unused self: Self]() -> i32 { return 0; }
fn Next[self: Self](cursor: i32*) -> Optional(T) {
fn NewCursor(unused self) -> i32 { return 0; }
fn Next(self, cursor: i32*) -> Optional(T) {
if (*cursor < N) {
++*cursor;
return Optional(T).Some(self[*cursor - 1]);
@@ -36,8 +36,8 @@ interface CppRangeForIterate {
let Sentinel:! type;
// TODO: self must be ref-qualified
fn Begin[self: Self]() -> Iterator;
fn End[self: Self]() -> Sentinel;
fn Begin(self) -> Iterator;
fn End(self) -> Sentinel;
}
impl forall [
@@ -53,11 +53,11 @@ impl forall [
{
alias ElementType = R.Iterator.(CppUnsafeDeref.Result);
fn NewCursor[self: Self]() -> (R.Iterator, R.Sentinel) {
fn NewCursor(self) -> (R.Iterator, R.Sentinel) {
return (self.Begin(), self.End());
}
fn Next[unused self: Self](cursor: (R.Iterator, R.Sentinel)*) -> Optional(ElementType) {
fn Next(unused self, cursor: (R.Iterator, R.Sentinel)*) -> Optional(ElementType) {
if (cursor->0 != cursor->1) {
returned var result: Optional(ElementType) =
Optional(ElementType).Some(cursor->0.(CppUnsafeDeref.Op)());
+19 -19
View File
@@ -21,97 +21,97 @@ import library "prelude/types/int_literal";
// Addition: `a + b`.
interface AddWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Addition with assignment: `a += b`.
interface AddAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Increment: `++a`.
interface Inc {
fn Op[ref self: Self]();
fn Op(ref self);
}
// Negation: `-a`.
interface Negate {
let Result:! type;
fn Op[self: Self]() -> Result;
fn Op(self) -> Result;
}
// Subtraction: `a - b`.
interface SubWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Subtraction with assignment: `a -= b`.
interface SubAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Decrement: `--a`.
interface Dec {
fn Op[ref self: Self]();
fn Op(ref self);
}
// Multiplication: `a * b`.
interface MulWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Multiplication with assignment: `a *= b`.
interface MulAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Division: `a / b`.
interface DivWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Division with assignment: `a /= b`.
interface DivAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Modulo: `a % b`.
interface ModWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Modulo with assignment: `a %= b`.
interface ModAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Operations for IntLiteral. These need to be here because IntLiteral has no
// associated library of its own.
impl IntLiteral as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sadd";
fn Op(self, other: Self) -> Self = "int.sadd";
}
impl IntLiteral as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sdiv";
fn Op(self, other: Self) -> Self = "int.sdiv";
}
impl IntLiteral as ModWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smod";
fn Op(self, other: Self) -> Self = "int.smod";
}
impl IntLiteral as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smul";
fn Op(self, other: Self) -> Self = "int.smul";
}
impl IntLiteral as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "int.snegate";
fn Op(self) -> Self = "int.snegate";
}
impl IntLiteral as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.ssub";
fn Op(self, other: Self) -> Self = "int.ssub";
}
+13 -13
View File
@@ -9,68 +9,68 @@ import library "prelude/types/int_literal";
import library "prelude/types/float_literal";
interface UnsafeAs(Dest:! type) {
fn Convert[self: Self]() -> Dest;
fn Convert(self) -> Dest;
}
interface As(Dest:! type) {
// TODO: extend UnsafeAs(Dest);
fn Convert[self: Self]() -> Dest;
fn Convert(self) -> Dest;
}
interface ImplicitAs(Dest:! type) {
// TODO: extend As(Dest);
fn Convert[self: Self]() -> Dest;
fn Convert(self) -> Dest;
}
// Workaround: ImplicitAs extends As.
impl forall [U:! type, T:! ImplicitAs(U)] T as As(U) {
fn Convert[self: Self]() -> U { return self.Convert(); }
fn Convert(self) -> U { return self.Convert(); }
}
// Workaround: As extends UnsafeAs.
impl forall [U:! type, T:! As(U)] T as UnsafeAs(U) {
fn Convert[self: Self]() -> U { return self.Convert(); }
fn Convert(self) -> U { return self.Convert(); }
}
// Copyable types have an identity conversion that performs a copy.
impl forall [T:! Copy] T as ImplicitAs(T) {
fn Convert[self: Self]() -> Self { return self.(Copy.Op)(); }
fn Convert(self) -> Self { return self.(Copy.Op)(); }
}
// `const` can be added and removed when converting a value.
impl forall [T:! type, U:! ImplicitAs(T)] U as ImplicitAs(const T) {
fn Convert[self: U]() -> const T { return self.Convert(); }
fn Convert(self) -> const T { return self.Convert(); }
}
impl forall [T:! type, U:! ImplicitAs(T)] const U as ImplicitAs(T) {
fn Convert[self: const U]() -> T { return (self as U).Convert(); }
fn Convert(self) -> T { return (self as U).Convert(); }
}
// `const` can be added to a pointer.
// TODO: This is also provided as a builtin conversion. We provide it here so
// that Optional(T*) can implicitly convert to Optional(const T*). See #5750.
impl forall [T:! type] T* as ImplicitAs(const T*) {
fn Convert[self: T*]() -> const T* = "pointer.unsafe_convert";
fn Convert(self) -> const T* = "pointer.unsafe_convert";
}
impl forall [T:! type] T* as As(const T*) {
fn Convert[self: T*]() -> const T* = "pointer.unsafe_convert";
fn Convert(self) -> const T* = "pointer.unsafe_convert";
}
// Pointer types can be unsafely cast to other pointer types.
// TODO: Should `unsafe as` be able to remove `const`?
impl forall [T:! type, U:! type] T* as UnsafeAs(U*) {
fn Convert[self: T*]() -> U* = "pointer.unsafe_convert";
fn Convert(self) -> U* = "pointer.unsafe_convert";
}
// Integer literals can be implicitly converted to floating-point literals.
impl IntLiteral as ImplicitAs(FloatLiteral) {
fn Convert[self: Self]() -> FloatLiteral = "int.convert_float_checked";
fn Convert(self) -> FloatLiteral = "int.convert_float_checked";
}
// Floating-point literals can be explicitly cast to integer literals.
impl FloatLiteral as UnsafeAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "float.convert_int";
fn Convert(self) -> IntLiteral = "float.convert_int";
}
interface IntFitsIn(Dest:! type) {}
+18 -18
View File
@@ -21,89 +21,89 @@ import library "prelude/types/int_literal";
// Bit complement: `^a`.
interface BitComplement {
let Result:! type;
fn Op[self: Self]() -> Result;
fn Op(self) -> Result;
}
// Bitwise AND: `a & b`.
interface BitAndWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Bitwise AND with assignment: `a &= b`.
interface BitAndAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Bitwise OR: `a | b`.
interface BitOrWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Bitwise OR with assignment: `a |= b`.
interface BitOrAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Bitwise XOR: `a ^ b`.
interface BitXorWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Bitwise XOR with assignment: `a ^= b`.
interface BitXorAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Left shift: `a << b`.
interface LeftShiftWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Left shift with assignment: `a <<= b`.
interface LeftShiftAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Right shift: `a >> b`.
interface RightShiftWith(Other:! type) {
let Result:! type;
fn Op[self: Self](other: Other) -> Result;
fn Op(self, other: Other) -> Result;
}
// Right shift with assignment: `a >>= b`.
interface RightShiftAssignWith(Other:! type) {
fn Op[ref self: Self](other: Other);
fn Op(ref self, other: Other);
}
// Operations for IntLiteral. These need to be here because IntLiteral has no
// associated library of its own.
impl IntLiteral as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.and";
fn Op(self, other: Self) -> Self = "int.and";
}
impl IntLiteral as BitComplement where .Result = Self {
fn Op[self: Self]() -> Self = "int.complement";
fn Op(self) -> Self = "int.complement";
}
impl IntLiteral as BitOrWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.or";
fn Op(self, other: Self) -> Self = "int.or";
}
impl IntLiteral as BitXorWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.xor";
fn Op(self, other: Self) -> Self = "int.xor";
}
impl IntLiteral as LeftShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.left_shift";
fn Op(self, other: Self) -> Self = "int.left_shift";
}
impl IntLiteral as RightShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.right_shift";
fn Op(self, other: Self) -> Self = "int.right_shift";
}
// Operations for `type`. These need to be here because `type` has no
@@ -111,5 +111,5 @@ impl IntLiteral as RightShiftWith(Self) where .Result = Self {
// Facet type combination.
impl type as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "type.and";
fn Op(self, other: Self) -> Self = "type.and";
}
+14 -14
View File
@@ -16,39 +16,39 @@ import library "prelude/types/int_literal";
// Equality comparison: `a == b` and `a != b`.
interface EqWith(Other:! type) {
fn Equal[self: Self](other: Other) -> bool;
fn NotEqual[self: Self](other: Other) -> bool;
fn Equal(self, other: Other) -> bool;
fn NotEqual(self, other: Other) -> bool;
}
// Relational comparison: `a < b`, `a <= b`, `a > b`, `a >= b`.
interface OrderedWith(Other:! type) {
// TODO: fn Compare
fn Less[self: Self](other: Other) -> bool;
fn LessOrEquivalent[self: Self](other: Other) -> bool;
fn Greater[self: Self](other: Other) -> bool;
fn GreaterOrEquivalent[self: Self](other: Other) -> bool;
fn Less(self, other: Other) -> bool;
fn LessOrEquivalent(self, other: Other) -> bool;
fn Greater(self, other: Other) -> bool;
fn GreaterOrEquivalent(self, other: Other) -> bool;
}
// Equality comparison for `bool`.
// Note that this must be provided in this library as `bool` doesn't have any
// associated libraries of its own.
impl bool as EqWith(Self) {
fn Equal[self: Self](other: Self) -> bool = "bool.eq";
fn NotEqual[self: Self](other: Self) -> bool = "bool.neq";
fn Equal(self, other: Self) -> bool = "bool.eq";
fn NotEqual(self, other: Self) -> bool = "bool.neq";
}
// Operations for IntLiteral. These need to be here because IntLiteral has no
// associated library of its own.
impl IntLiteral as EqWith(Self) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
impl IntLiteral as OrderedWith(Self) {
// TODO: fn Compare
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
+1 -1
View File
@@ -7,5 +7,5 @@ package Core library "prelude/operators/deref";
// TODO: Align with https://docs.carbon-lang.dev/docs/design/values.html#dereferencing-customization.
interface CppUnsafeDeref {
let Result:! type;
fn Op[self: Self]() -> Result;
fn Op(self) -> Result;
}
+1 -1
View File
@@ -6,5 +6,5 @@ package Core library "prelude/operators/index";
interface IndexWith(SubscriptType:! type) {
let ElementType:! type;
fn At[self: Self](subscript: SubscriptType) -> ElementType;
fn At(self, subscript: SubscriptType) -> ElementType;
}
+29 -29
View File
@@ -24,27 +24,27 @@ class Char {
impl Char as UnformedInit {}
impl Char as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// Conversions.
impl CharLiteral as ImplicitAs(Char) {
fn Convert[self: Self]() -> Char = "char.convert_checked";
fn Convert(self) -> Char = "char.convert_checked";
}
// TODO: Remove these once ImplicitAs extends As.
impl CharLiteral as As(Char) {
fn Convert[self: Self]() -> Char = "char.convert_checked";
fn Convert(self) -> Char = "char.convert_checked";
}
impl forall [From:! IntLiteral] UInt(From) as As(Char) {
fn Convert[self: Self]() -> Char = "int.convert_char";
fn Convert(self) -> Char = "int.convert_char";
}
// `char` explicitly converts to any type that `u8` implicitly converts to.
impl forall [T:! type where u8 impls ImplicitAs(.Self)] Char as As(T) {
fn Convert[self: Self]() -> T {
fn Convert(self) -> T {
return self as u8;
}
}
@@ -52,39 +52,39 @@ impl forall [T:! type where u8 impls ImplicitAs(.Self)] Char as As(T) {
// Comparisons.
impl Char as EqWith(Char) {
fn Equal[self: Self](other: Char) -> bool = "int.eq";
fn NotEqual[self: Self](other: Char) -> bool = "int.neq";
fn Equal(self, other: Char) -> bool = "int.eq";
fn NotEqual(self, other: Char) -> bool = "int.neq";
}
impl Char as OrderedWith(Char) {
fn Less[self: Self](other: Char) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Char) -> bool = "int.less_eq";
fn Greater[self: Self](other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Char) -> bool = "int.greater_eq";
fn Less(self, other: Char) -> bool = "int.less";
fn LessOrEquivalent(self, other: Char) -> bool = "int.less_eq";
fn Greater(self, other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Char) -> bool = "int.greater_eq";
}
impl forall [T:! ImplicitAs(Char)] Char as EqWith(T) {
fn Equal[self: Self](other: Char) -> bool = "int.eq";
fn NotEqual[self: Self](other: Char) -> bool = "int.neq";
fn Equal(self, other: Char) -> bool = "int.eq";
fn NotEqual(self, other: Char) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(Char)] Char as OrderedWith(T) {
fn Less[self: Self](other: Char) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Char) -> bool = "int.less_eq";
fn Greater[self: Self](other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Char) -> bool = "int.greater_eq";
fn Less(self, other: Char) -> bool = "int.less";
fn LessOrEquivalent(self, other: Char) -> bool = "int.less_eq";
fn Greater(self, other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Char) -> bool = "int.greater_eq";
}
impl forall [T:! ImplicitAs(Char)] T as EqWith(Char) {
fn Equal[self: Char](other: Char) -> bool = "int.eq";
fn NotEqual[self: Char](other: Char) -> bool = "int.neq";
fn Equal(self: Char, other: Char) -> bool = "int.eq";
fn NotEqual(self: Char, other: Char) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(Char)] T as OrderedWith(Char) {
fn Less[self: Char](other: Char) -> bool = "int.less";
fn LessOrEquivalent[self: Char](other: Char) -> bool = "int.less_eq";
fn Greater[self: Char](other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Char](other: Char) -> bool = "int.greater_eq";
fn Less(self: Char, other: Char) -> bool = "int.less";
fn LessOrEquivalent(self: Char, other: Char) -> bool = "int.less_eq";
fn Greater(self: Char, other: Char) -> bool = "int.greater";
fn GreaterOrEquivalent(self: Char, other: Char) -> bool = "int.greater_eq";
}
// Arithmetic.
@@ -96,7 +96,7 @@ impl forall [N:! IntLiteral] UInt(N) as AnyInt {}
impl forall [T:! AnyInt & As(u8)]
Char as AddWith(T) where .Result = Char {
fn Op[self: Self](other: T) -> Self {
fn Op(self, other: T) -> Self {
// TODO: This should be erroneous if the addition overflows.
return ((self as u8) + (other as u8)) as char;
}
@@ -104,7 +104,7 @@ impl forall [T:! AnyInt & As(u8)]
impl forall [T:! AnyInt & As(u8)]
T as AddWith(Char) where .Result = Char {
fn Op[self: Self](other: Char) -> Char {
fn Op(self, other: Char) -> Char {
// TODO: This should be erroneous if the addition overflows.
return ((self as u8) + (other as u8)) as char;
}
@@ -112,26 +112,26 @@ impl forall [T:! AnyInt & As(u8)]
final impl forall [T:! AnyInt & As(u8)]
Char as SubWith(T) where .Result = Char {
fn Op[self: Self](other: T) -> Self {
fn Op(self, other: T) -> Self {
// TODO: This should be erroneous if the addition overflows.
return ((self as u8) - (other as u8)) as char;
}
}
impl Char as SubWith(Char) where .Result = i32 {
fn Op[self: Self](other: Char) -> i32 {
fn Op(self, other: Char) -> i32 {
return (self as i32) - (other as i32);
}
}
impl forall [T:! ImplicitAs(Char)] T as SubWith(Char) where .Result = i32 {
fn Op[self: Char](other: Char) -> i32 {
fn Op(self: Char, other: Char) -> i32 {
return (self as i32) - (other as i32);
}
}
impl forall [T:! ImplicitAs(Char)] Char as SubWith(T) where .Result = i32 {
fn Op[self: Char](other: Char) -> i32 {
fn Op(self, other: Char) -> i32 {
return (self as i32) - (other as i32);
}
}
+148 -148
View File
@@ -37,39 +37,39 @@ impl CppCompat.ULongLong64 as UnformedInit {}
// Copy
impl CppCompat.Long32 as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl CppCompat.ULong32 as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl CppCompat.LongLong64 as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
impl CppCompat.ULongLong64 as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// Conversions.
impl IntLiteral as ImplicitAs(CppCompat.Long32) {
fn Convert[self: Self]() -> CppCompat.Long32 = "int.convert_checked";
fn Convert(self) -> CppCompat.Long32 = "int.convert_checked";
}
// TODO: Remove this once `ImplicitAs` extends `As`.
impl IntLiteral as As(CppCompat.Long32) {
fn Convert[self: Self]() -> CppCompat.Long32 = "int.convert_checked";
fn Convert(self) -> CppCompat.Long32 = "int.convert_checked";
}
final impl CppCompat.Long32 as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: ImplicitAs from Int(N) to Long32 if N < 32.
impl i32 as ImplicitAs(CppCompat.Long32) {
fn Convert[self: Self]() -> CppCompat.Long32 = "int.convert";
fn Convert(self) -> CppCompat.Long32 = "int.convert";
}
// TODO: Generalize ImplicitAs from Long32 to Int(N) for all N > 32.
@@ -81,48 +81,48 @@ impl i32 as ImplicitAs(CppCompat.Long32) {
// Cpp.long, which differs from the result for Cpp.long + i32 -> Cpp.long, as
// the best match for the left operand is being selected.
final impl CppCompat.Long32 as ImplicitAs(i64) {
fn Convert[self: Self]() -> i64 = "int.convert";
fn Convert(self) -> i64 = "int.convert";
}
impl IntLiteral as ImplicitAs(CppCompat.ULong32) {
fn Convert[self: Self]() -> CppCompat.ULong32 = "int.convert_checked";
fn Convert(self) -> CppCompat.ULong32 = "int.convert_checked";
}
// TODO: Remove this once `ImplicitAs` extends `As`.
impl IntLiteral as As(CppCompat.ULong32) {
fn Convert[self: Self]() -> CppCompat.ULong32 = "int.convert_checked";
fn Convert(self) -> CppCompat.ULong32 = "int.convert_checked";
}
final impl CppCompat.ULong32 as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: ImplicitAs from UInt(N) to ULong32 if N < 32.
impl u32 as ImplicitAs(CppCompat.ULong32) {
fn Convert[self: Self]() -> CppCompat.ULong32 = "int.convert";
fn Convert(self) -> CppCompat.ULong32 = "int.convert";
}
// TODO: ImplicitAs from ULong32 to UInt(N) if N > 32.
final impl CppCompat.ULong32 as ImplicitAs(u64) {
fn Convert[self: Self]() -> u64 = "int.convert";
fn Convert(self) -> u64 = "int.convert";
}
impl IntLiteral as ImplicitAs(CppCompat.LongLong64) {
fn Convert[self: Self]() -> CppCompat.LongLong64 = "int.convert_checked";
fn Convert(self) -> CppCompat.LongLong64 = "int.convert_checked";
}
// TODO: Remove this once `ImplicitAs` extends `As`.
impl IntLiteral as As(CppCompat.LongLong64) {
fn Convert[self: Self]() -> CppCompat.LongLong64 = "int.convert_checked";
fn Convert(self) -> CppCompat.LongLong64 = "int.convert_checked";
}
final impl CppCompat.LongLong64 as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: ImplicitAs from Int(N) to LongLong64 if N < 64.
impl i64 as ImplicitAs(CppCompat.LongLong64) {
fn Convert[self: Self]() -> CppCompat.LongLong64 = "int.convert";
fn Convert(self) -> CppCompat.LongLong64 = "int.convert";
}
// TODO: ImplicitAs from LongLong64 to Int(N) if N > 64.
@@ -130,30 +130,30 @@ impl i64 as ImplicitAs(CppCompat.LongLong64) {
// be between i64 and i65 (details:
// https://github.com/carbon-language/carbon-lang/issues/6275#issuecomment-3488010485).
final impl CppCompat.LongLong64 as ImplicitAs(i128) {
fn Convert[self: Self]() -> i128 = "int.convert";
fn Convert(self) -> i128 = "int.convert";
}
impl IntLiteral as ImplicitAs(CppCompat.ULongLong64) {
fn Convert[self: Self]() -> CppCompat.ULongLong64 = "int.convert_checked";
fn Convert(self) -> CppCompat.ULongLong64 = "int.convert_checked";
}
// TODO: Remove this once `ImplicitAs` extends `As`.
impl IntLiteral as As(CppCompat.ULongLong64) {
fn Convert[self: Self]() -> CppCompat.ULongLong64 = "int.convert_checked";
fn Convert(self) -> CppCompat.ULongLong64 = "int.convert_checked";
}
final impl CppCompat.ULongLong64 as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: ImplicitAs from UInt(N) to ULongLong64 if N < 64.
impl u64 as ImplicitAs(CppCompat.ULongLong64) {
fn Convert[self: Self]() -> CppCompat.ULongLong64 = "int.convert";
fn Convert(self) -> CppCompat.ULongLong64 = "int.convert";
}
// TODO: ImplicitAs from ULongLong64 to UInt(N) if N > 64.
final impl CppCompat.ULongLong64 as ImplicitAs(u128) {
fn Convert[self: Self]() -> u128 = "int.convert";
fn Convert(self) -> u128 = "int.convert";
}
// TODO: As from Long32 to Int(N) if N < 32.
@@ -172,27 +172,27 @@ final impl CppCompat.ULongLong64 as ImplicitAs(u128) {
// - CppCompat.T vs CppCompat.T
final impl CppCompat.Long32 as EqWith(CppCompat.Long32) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
final impl CppCompat.Long32 as OrderedWith(CppCompat.Long32) {
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
final impl CppCompat.LongLong64 as EqWith(CppCompat.LongLong64) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
final impl CppCompat.LongLong64 as OrderedWith(CppCompat.LongLong64) {
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
// - Heterogeneous.
@@ -200,62 +200,62 @@ final impl CppCompat.LongLong64 as OrderedWith(CppCompat.LongLong64) {
// - CppCompat.T on left-hand side.
impl forall [T:! ImplicitAs(CppCompat.Long32)] CppCompat.Long32 as EqWith(T) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)] CppCompat.Long32 as OrderedWith(T) {
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as EqWith(T) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as OrderedWith(T) {
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
// - CppCompat.T on right-hand side.
impl forall [T:! ImplicitAs(CppCompat.Long32)] T as EqWith(CppCompat.Long32) {
fn Equal[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.eq";
fn NotEqual[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.neq";
fn Equal(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.eq";
fn NotEqual(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)] T as OrderedWith(CppCompat.Long32) {
fn Less[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.less";
fn LessOrEquivalent[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.less_eq";
fn Greater[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.greater";
fn GreaterOrEquivalent[self: CppCompat.Long32](other: CppCompat.Long32) -> bool = "int.greater_eq";
fn Less(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.less";
fn LessOrEquivalent(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.less_eq";
fn Greater(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.greater";
fn GreaterOrEquivalent(self: CppCompat.Long32, other: CppCompat.Long32) -> bool = "int.greater_eq";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as EqWith(CppCompat.LongLong64) {
fn Equal[self: CppCompat.LongLong64](
fn Equal(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.eq";
fn NotEqual[self: CppCompat.LongLong64](
fn NotEqual(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.neq";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as OrderedWith(CppCompat.LongLong64) {
fn Less[self: CppCompat.LongLong64](
fn Less(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.less";
fn LessOrEquivalent[self: CppCompat.LongLong64](
fn LessOrEquivalent(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.less_eq";
fn Greater[self: CppCompat.LongLong64](
fn Greater(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.greater";
fn GreaterOrEquivalent[self: CppCompat.LongLong64](
fn GreaterOrEquivalent(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> bool = "int.greater_eq";
}
@@ -268,53 +268,53 @@ impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
// - CppCompat.Long32
final impl CppCompat.Long32 as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "int.snegate";
fn Op(self) -> Self = "int.snegate";
}
final impl CppCompat.Long32 as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sadd";
fn Op(self, other: Self) -> Self = "int.sadd";
}
final impl CppCompat.Long32 as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.ssub";
fn Op(self, other: Self) -> Self = "int.ssub";
}
final impl CppCompat.Long32 as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smul";
fn Op(self, other: Self) -> Self = "int.smul";
}
final impl CppCompat.Long32 as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sdiv";
fn Op(self, other: Self) -> Self = "int.sdiv";
}
final impl CppCompat.Long32 as ModWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smod";
fn Op(self, other: Self) -> Self = "int.smod";
}
// - CppCompat.LongLong64
final impl CppCompat.LongLong64 as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "int.snegate";
fn Op(self) -> Self = "int.snegate";
}
final impl CppCompat.LongLong64 as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sadd";
fn Op(self, other: Self) -> Self = "int.sadd";
}
final impl CppCompat.LongLong64 as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.ssub";
fn Op(self, other: Self) -> Self = "int.ssub";
}
final impl CppCompat.LongLong64 as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smul";
fn Op(self, other: Self) -> Self = "int.smul";
}
final impl CppCompat.LongLong64 as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sdiv";
fn Op(self, other: Self) -> Self = "int.sdiv";
}
final impl CppCompat.LongLong64 as ModWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smod";
fn Op(self, other: Self) -> Self = "int.smod";
}
// - Heterogeneous.
@@ -323,58 +323,58 @@ final impl CppCompat.LongLong64 as ModWith(Self) where .Result = Self {
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as AddWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.sadd";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.sadd";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as SubWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.ssub";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.ssub";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as MulWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.smul";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.smul";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as DivWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.sdiv";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.sdiv";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as ModWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.smod";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.smod";
}
// - CppCompat.LongLong64 on left-hand side.
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as AddWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.sadd";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as SubWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.ssub";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as MulWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.smul";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as DivWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.sdiv";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as ModWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.smod";
}
@@ -382,58 +382,58 @@ impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as AddWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.sadd";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.sadd";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as SubWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.ssub";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.ssub";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as MulWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.smul";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.smul";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as DivWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.sdiv";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.sdiv";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as ModWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](other: CppCompat.Long32) -> CppCompat.Long32 = "int.smod";
fn Op(self: CppCompat.Long32, other: CppCompat.Long32) -> CppCompat.Long32 = "int.smod";
}
// - CppCompat.LongLong64 on right-hand side.
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as AddWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.sadd";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as SubWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.ssub";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as MulWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.smul";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as DivWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.sdiv";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as ModWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.smod";
}
@@ -446,53 +446,53 @@ impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
// - CppCompat.Long32
final impl CppCompat.Long32 as BitComplement where .Result = Self {
fn Op[self: Self]() -> Self = "int.complement";
fn Op(self) -> Self = "int.complement";
}
final impl CppCompat.Long32 as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.and";
fn Op(self, other: Self) -> Self = "int.and";
}
final impl CppCompat.Long32 as BitOrWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.or";
fn Op(self, other: Self) -> Self = "int.or";
}
final impl CppCompat.Long32 as BitXorWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.xor";
fn Op(self, other: Self) -> Self = "int.xor";
}
final impl CppCompat.Long32 as LeftShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.left_shift";
fn Op(self, other: Self) -> Self = "int.left_shift";
}
final impl CppCompat.Long32 as RightShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.right_shift";
fn Op(self, other: Self) -> Self = "int.right_shift";
}
// - CppCompat.LongLong64
final impl CppCompat.LongLong64 as BitComplement where .Result = Self {
fn Op[self: Self]() -> Self = "int.complement";
fn Op(self) -> Self = "int.complement";
}
final impl CppCompat.LongLong64 as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.and";
fn Op(self, other: Self) -> Self = "int.and";
}
final impl CppCompat.LongLong64 as BitOrWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.or";
fn Op(self, other: Self) -> Self = "int.or";
}
final impl CppCompat.LongLong64 as BitXorWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.xor";
fn Op(self, other: Self) -> Self = "int.xor";
}
final impl CppCompat.LongLong64 as LeftShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.left_shift";
fn Op(self, other: Self) -> Self = "int.left_shift";
}
final impl CppCompat.LongLong64 as RightShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.right_shift";
fn Op(self, other: Self) -> Self = "int.right_shift";
}
// - Heterogeneous.
@@ -501,31 +501,31 @@ final impl CppCompat.LongLong64 as RightShiftWith(Self) where .Result = Self {
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitAndWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other:CppCompat.Long32) -> CppCompat.Long32 = "int.and";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitOrWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.or";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitXorWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.xor";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as LeftShiftWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.left_shift";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as RightShiftWith(T) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.right_shift";
}
@@ -533,31 +533,31 @@ impl forall [T:! ImplicitAs(CppCompat.Long32)]
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitAndWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other:CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.and";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitOrWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.or";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitXorWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.xor";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as LeftShiftWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.left_shift";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as RightShiftWith(T) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.right_shift";
}
@@ -565,31 +565,31 @@ impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as BitAndWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.and";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as BitOrWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.or";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as BitXorWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.xor";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as LeftShiftWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.left_shift";
}
impl forall [T:! ImplicitAs(CppCompat.Long32)]
T as RightShiftWith(CppCompat.Long32) where .Result = CppCompat.Long32 {
fn Op[self: CppCompat.Long32](
fn Op(self: CppCompat.Long32,
other: CppCompat.Long32) -> CppCompat.Long32 = "int.right_shift";
}
@@ -597,31 +597,31 @@ impl forall [T:! ImplicitAs(CppCompat.Long32)]
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as BitAndWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.and";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as BitOrWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.or";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as BitXorWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.xor";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as LeftShiftWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.left_shift";
}
impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
T as RightShiftWith(CppCompat.LongLong64) where .Result = CppCompat.LongLong64 {
fn Op[self: CppCompat.LongLong64](
fn Op(self: CppCompat.LongLong64,
other: CppCompat.LongLong64) -> CppCompat.LongLong64 = "int.right_shift";
}
@@ -635,54 +635,54 @@ impl forall [T:! ImplicitAs(CppCompat.LongLong64)]
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as AddAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sadd_assign";
fn Op(ref self, other: Self) = "int.sadd_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as SubAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.ssub_assign";
fn Op(ref self, other: Self) = "int.ssub_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as MulAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smul_assign";
fn Op(ref self, other: Self) = "int.smul_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as DivAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sdiv_assign";
fn Op(ref self, other: Self) = "int.sdiv_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as ModAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smod_assign";
fn Op(ref self, other: Self) = "int.smod_assign";
}
// - CppCompat.LongLong64
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as AddAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sadd_assign";
fn Op(ref self, other: Self) = "int.sadd_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as SubAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.ssub_assign";
fn Op(ref self, other: Self) = "int.ssub_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as MulAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smul_assign";
fn Op(ref self, other: Self) = "int.smul_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as DivAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sdiv_assign";
fn Op(ref self, other: Self) = "int.sdiv_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as ModAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smod_assign";
fn Op(ref self, other: Self) = "int.smod_assign";
}
// Compound bitwise assignments.
@@ -691,54 +691,54 @@ impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitAndAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.and_assign";
fn Op(ref self, other: Self) = "int.and_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitOrAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.or_assign";
fn Op(ref self, other: Self) = "int.or_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as BitXorAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.xor_assign";
fn Op(ref self, other: Self) = "int.xor_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as LeftShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.left_shift_assign";
fn Op(ref self, other: Self) = "int.left_shift_assign";
}
impl forall [U:! ImplicitAs(CppCompat.Long32)]
CppCompat.Long32 as RightShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.right_shift_assign";
fn Op(ref self, other: Self) = "int.right_shift_assign";
}
// - CppCompat.LongLong64
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitAndAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.and_assign";
fn Op(ref self, other: Self) = "int.and_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitOrAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.or_assign";
fn Op(ref self, other: Self) = "int.or_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as BitXorAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.xor_assign";
fn Op(ref self, other: Self) = "int.xor_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as LeftShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.left_shift_assign";
fn Op(ref self, other: Self) = "int.left_shift_assign";
}
impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
CppCompat.LongLong64 as RightShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.right_shift_assign";
fn Op(ref self, other: Self) = "int.right_shift_assign";
}
// TODO: ULong32, ULongLong64: compound assignments.
@@ -748,13 +748,13 @@ impl forall [U:! ImplicitAs(CppCompat.LongLong64)]
// - CppCompat.Long32
impl CppCompat.Long32 as Dec {
fn Op[ref self: Self]() {
fn Op(ref self) {
self -= (1 as CppCompat.Long32);
}
}
impl CppCompat.Long32 as Inc {
fn Op[ref self: Self]() {
fn Op(ref self) {
self += (1 as CppCompat.Long32);
}
}
@@ -762,13 +762,13 @@ impl CppCompat.Long32 as Inc {
// - CppCompat.LongLong64
impl CppCompat.LongLong64 as Dec {
fn Op[ref self: Self]() {
fn Op(ref self) {
self -= (1 as CppCompat.LongLong64);
}
}
impl CppCompat.LongLong64 as Inc {
fn Op[ref self: Self]() {
fn Op(ref self) {
self += (1 as CppCompat.LongLong64);
}
}
+2 -2
View File
@@ -40,7 +40,7 @@ class CppCompat.NullptrT {
}
impl as Copy {
fn Op[unused self: Self]() -> Self {
fn Op(unused self) -> Self {
return Make();
}
}
@@ -48,7 +48,7 @@ class CppCompat.NullptrT {
// TODO: impl as EqWith(Self)
impl forall [T:! type] as ImplicitAs(Optional(T*)) {
fn Convert[unused self: Self]() -> Optional(T*) {
fn Convert(unused self) -> Optional(T*) {
return Optional(T*).None();
}
}
+2 -2
View File
@@ -33,9 +33,9 @@ abstract class CppCompat.VoidBase {
// #6357 allows it, and we don't have a good way to express "non-const" as a
// constraint on this impl, but this conversion is not const-correct.
impl forall [T:! type] T* as ImplicitAs(CppCompat.VoidBase*) {
fn Convert[self: T*]() -> CppCompat.VoidBase* = "pointer.unsafe_convert";
fn Convert(self: T*) -> CppCompat.VoidBase* = "pointer.unsafe_convert";
}
impl forall [T:! type] T* as ImplicitAs(const CppCompat.VoidBase*) {
fn Convert[self: T*]() -> CppCompat.VoidBase* = "pointer.unsafe_convert";
fn Convert(self: T*) -> CppCompat.VoidBase* = "pointer.unsafe_convert";
}
+37 -37
View File
@@ -24,23 +24,23 @@ impl forall [N:! IntLiteral] Float(N) as UnformedInit {}
// Copy.
impl forall [N:! IntLiteral] Float(N) as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// Conversions between floating-point types. Implicit if all the source values
// can be represented exactly in the target type, otherwise explicit.
impl forall [N:! IntLiteral] FloatLiteral as ImplicitAs(Float(N)) {
fn Convert[self: Self]() -> Float(N) = "float.convert_checked";
fn Convert(self) -> Float(N) = "float.convert_checked";
}
// TODO: Remove this once ImplicitAs extends As.
impl forall [N:! IntLiteral] FloatLiteral as As(Float(N)) {
fn Convert[self: Self]() -> Float(N) = "float.convert_checked";
fn Convert(self) -> Float(N) = "float.convert_checked";
}
final impl forall [From:! IntLiteral, To:! IntLiteral]
Float(From) as As(Float(To)) {
fn Convert[self: Self]() -> Float(To) = "float.convert";
fn Convert(self) -> Float(To) = "float.convert";
}
// AnyFloat exists to work around the inability to apply constraints to an impl
@@ -48,12 +48,12 @@ final impl forall [From:! IntLiteral, To:! IntLiteral]
// TODO: Remove these once possible.
private interface AnyFloat {
let Width:! IntLiteral;
fn AsFloat[self: Self]() -> Float(Width);
fn AsFloat(self) -> Float(Width);
fn Make(src: Float(Width)) -> Self;
}
impl forall [N:! IntLiteral] Float(N) as AnyFloat where .Width = N {
fn AsFloat[self: Self]() -> Self { return self; }
fn AsFloat(self) -> Self { return self; }
fn Make(src: Self) -> Self { return src; }
}
@@ -62,7 +62,7 @@ impl forall [N:! IntLiteral] Float(N) as AnyFloat where .Width = N {
// TODO: Use `match_first` to resolve this instead once it is available.
impl forall [From:! IntLiteral, To:! AnyFloat where Float(From) impls FloatFitsIn(.Self)]
Float(From) as ImplicitAs(To) {
fn Convert[self: Self]() -> To {
fn Convert(self) -> To {
fn Impl(src: Float(From)) -> Float(To.Width) = "float.convert";
return To.Make(Impl(self));
}
@@ -79,34 +79,34 @@ impl forall [From:! IntLiteral, To:! AnyFloat where Float(From) impls FloatFitsI
// source values fit in the target type.
final impl forall [From:! IntLiteral, To:! IntLiteral]
Float(From) as UnsafeAs(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "float.convert_int";
fn Convert(self) -> Int(To) = "float.convert_int";
}
final impl forall [From:! IntLiteral, To:! IntLiteral]
Float(From) as UnsafeAs(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "float.convert_int";
fn Convert(self) -> UInt(To) = "float.convert_int";
}
final impl forall [From:! IntLiteral]
Float(From) as UnsafeAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "float.convert_int";
fn Convert(self) -> IntLiteral = "float.convert_int";
}
// Conversions from integer to floating-point type. Implicit if all source
// values can be represented exactly in the target type, otherwise explicit.
impl forall [From:! IntLiteral, To:! IntLiteral]
Int(From) as As(Float(To)) {
fn Convert[self: Self]() -> Float(To) = "int.convert_float";
fn Convert(self) -> Float(To) = "int.convert_float";
}
impl forall [From:! IntLiteral, To:! IntLiteral]
UInt(From) as As(Float(To)) {
fn Convert[self: Self]() -> Float(To) = "int.convert_float";
fn Convert(self) -> Float(To) = "int.convert_float";
}
impl forall [To:! IntLiteral]
IntLiteral as As(Float(To)) {
fn Convert[self: Self]() -> Float(To) = "int.convert_float";
fn Convert(self) -> Float(To) = "int.convert_float";
}
// AnyInt, AnyUInt, and IntImplicitAsFloat exist to work around the inability to
@@ -115,29 +115,29 @@ impl forall [To:! IntLiteral]
// TODO: Remove these once possible.
private interface AnyInt {
let Width:! IntLiteral;
fn AsInt[self: Self]() -> Int(Width);
fn AsInt(self) -> Int(Width);
}
impl forall [N:! IntLiteral] Int(N) as AnyInt where .Width = N {
fn AsInt[self: Self]() -> Self { return self; }
fn AsInt(self) -> Self { return self; }
}
private interface AnyUInt {
let Width:! IntLiteral;
fn AsUInt[self: Self]() -> UInt(Width);
fn AsUInt(self) -> UInt(Width);
}
impl forall [N:! IntLiteral] UInt(N) as AnyUInt where .Width = N {
fn AsUInt[self: Self]() -> Self { return self; }
fn AsUInt(self) -> Self { return self; }
}
private interface IntImplicitAsFloat(To:! IntLiteral) {
fn Convert[self: Self]() -> Float(To);
fn Convert(self) -> Float(To);
}
final impl forall [To:! IntLiteral, From:! AnyInt & IntFitsIn(Float(To))]
From as IntImplicitAsFloat(To) {
fn Convert[self: Self]() -> Float(To) {
fn Convert(self) -> Float(To) {
fn Impl(src: Int(From.Width)) -> Float(To) = "int.convert_float";
return Impl(self.AsInt());
}
@@ -145,7 +145,7 @@ final impl forall [To:! IntLiteral, From:! AnyInt & IntFitsIn(Float(To))]
impl forall [To:! IntLiteral, From:! AnyUInt & IntFitsIn(Float(To))]
From as IntImplicitAsFloat(To) {
fn Convert[self: Self]() -> Float(To) {
fn Convert(self) -> Float(To) {
fn Impl(src: UInt(From.Width)) -> Float(To) = "int.convert_float";
return Impl(self.AsUInt());
}
@@ -153,7 +153,7 @@ impl forall [To:! IntLiteral, From:! AnyUInt & IntFitsIn(Float(To))]
impl forall [To:! IntLiteral, From:! IntImplicitAsFloat(To)]
From as ImplicitAs(Float(To)) {
fn Convert[self: Self]() -> Float(To) {
fn Convert(self) -> Float(To) {
return self.Convert();
}
}
@@ -174,66 +174,66 @@ impl forall [To:! IntLiteral, From:! IntImplicitAsFloat(To)]
impl forall [To:! IntLiteral]
IntLiteral as ImplicitAs(Float(To)) {
fn Convert[self: Self]() -> Float(To) = "int.convert_float_checked";
fn Convert(self) -> Float(To) = "int.convert_float_checked";
}
// Comparisons.
// TODO: Support mixed-type comparisons.
final impl forall [N:! IntLiteral] Float(N) as EqWith(Float(N)) {
fn Equal[self: Self](other: Float(N)) -> bool = "float.eq";
fn NotEqual[self: Self](other: Float(N)) -> bool = "float.neq";
fn Equal(self, other: Float(N)) -> bool = "float.eq";
fn NotEqual(self, other: Float(N)) -> bool = "float.neq";
}
final impl forall [N:! IntLiteral] Float(N) as OrderedWith(Float(N)) {
fn Less[self: Self](other: Float(N)) -> bool = "float.less";
fn LessOrEquivalent[self: Self](other: Float(N)) -> bool = "float.less_eq";
fn Greater[self: Self](other: Float(N)) -> bool = "float.greater";
fn GreaterOrEquivalent[self: Self](other: Float(N)) -> bool = "float.greater_eq";
fn Less(self, other: Float(N)) -> bool = "float.less";
fn LessOrEquivalent(self, other: Float(N)) -> bool = "float.less_eq";
fn Greater(self, other: Float(N)) -> bool = "float.greater";
fn GreaterOrEquivalent(self, other: Float(N)) -> bool = "float.greater_eq";
}
// Arithmetic.
final impl forall [N:! IntLiteral]
Float(N) as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "float.add";
fn Op(self, other: Self) -> Self = "float.add";
}
final impl forall [N:! IntLiteral]
Float(N) as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "float.div";
fn Op(self, other: Self) -> Self = "float.div";
}
final impl forall [N:! IntLiteral]
Float(N) as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "float.mul";
fn Op(self, other: Self) -> Self = "float.mul";
}
final impl forall [N:! IntLiteral]
Float(N) as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "float.negate";
fn Op(self) -> Self = "float.negate";
}
final impl forall [N:! IntLiteral]
Float(N) as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "float.sub";
fn Op(self, other: Self) -> Self = "float.sub";
}
// Compound assignments.
final impl forall [N:! IntLiteral]
Float(N) as AddAssignWith(Self) {
fn Op[ref self: Self](other: Self) = "float.add_assign";
fn Op(ref self, other: Self) = "float.add_assign";
}
final impl forall [N:! IntLiteral]
Float(N) as DivAssignWith(Self) {
fn Op[ref self: Self](other: Self) = "float.div_assign";
fn Op(ref self, other: Self) = "float.div_assign";
}
final impl forall [N:! IntLiteral]
Float(N) as MulAssignWith(Self) {
fn Op[ref self: Self](other: Self) = "float.mul_assign";
fn Op(ref self, other: Self) = "float.mul_assign";
}
final impl forall [N:! IntLiteral]
Float(N) as SubAssignWith(Self) {
fn Op[ref self: Self](other: Self) = "float.sub_assign";
fn Op(ref self, other: Self) = "float.sub_assign";
}
+72 -72
View File
@@ -22,28 +22,28 @@ impl forall [N:! IntLiteral] Int(N) as UnformedInit {}
// Copy.
impl forall [N:! IntLiteral] Int(N) as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// Conversions.
impl forall [To:! IntLiteral] IntLiteral as ImplicitAs(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "int.convert_checked";
fn Convert(self) -> Int(To) = "int.convert_checked";
}
final impl forall [From:! IntLiteral] Int(From) as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: Remove these once ImplicitAs extends As. For now we need them because
// the forwarding impl of As in terms of ImplicitAs is not usable at compile
// time.
impl forall [To:! IntLiteral] IntLiteral as As(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "int.convert_checked";
fn Convert(self) -> Int(To) = "int.convert_checked";
}
final impl forall [From:! IntLiteral] Int(From) as As(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// Work around the inability to put a `where` clause on a generic parameter of
@@ -51,29 +51,29 @@ final impl forall [From:! IntLiteral] Int(From) as As(IntLiteral) {
// TODO: Remove this once possible.
private interface AnyInt {
let Width:! IntLiteral;
fn AsInt[self: Self]() -> Int(Width);
fn AsInt(self) -> Int(Width);
}
impl forall [N:! IntLiteral] Int(N) as AnyInt where .Width = N {
fn AsInt[self: Self]() -> Self { return self; }
fn AsInt(self) -> Self { return self; }
}
impl forall [To:! IntLiteral, From:! AnyInt & IntFitsIn(Int(To))]
From as ImplicitAs(Int(To)) {
fn Convert[self: Self]() -> Int(To) {
fn Convert(self) -> Int(To) {
fn Impl(src: Int(From.Width)) -> Int(To) = "int.convert";
return Impl(self.AsInt());
}
}
final impl forall [From:! IntLiteral, To:! IntLiteral] Int(From) as As(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "int.convert";
fn Convert(self) -> Int(To) = "int.convert";
}
// Explicit conversion from floating-point literals.
impl forall [To:! IntLiteral]
FloatLiteral as UnsafeAs(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "float.convert_int";
fn Convert(self) -> Int(To) = "float.convert_int";
}
// Comparisons.
@@ -81,46 +81,46 @@ impl forall [To:! IntLiteral]
// - Int(N) vs Int(M).
final impl forall [N:! IntLiteral, M:! IntLiteral] Int(N) as EqWith(Int(M)) {
fn Equal[self: Self](other: Int(M)) -> bool = "int.eq";
fn NotEqual[self: Self](other: Int(M)) -> bool = "int.neq";
fn Equal(self, other: Int(M)) -> bool = "int.eq";
fn NotEqual(self, other: Int(M)) -> bool = "int.neq";
}
final impl forall [N:! IntLiteral, M:! IntLiteral] Int(N) as OrderedWith(Int(M)) {
// TODO: fn Compare
fn Less[self: Self](other: Int(M)) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Int(M)) -> bool = "int.less_eq";
fn Greater[self: Self](other: Int(M)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Int(M)) -> bool = "int.greater_eq";
fn Less(self, other: Int(M)) -> bool = "int.less";
fn LessOrEquivalent(self, other: Int(M)) -> bool = "int.less_eq";
fn Greater(self, other: Int(M)) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Int(M)) -> bool = "int.greater_eq";
}
// - Int(N) on left-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] Int(N) as EqWith(T) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] Int(N) as OrderedWith(T) {
// TODO: fn Compare
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
// - Int(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] T as EqWith(Int(N)) {
fn Equal[self: Int(N)](other: Int(N)) -> bool = "int.eq";
fn NotEqual[self: Int(N)](other: Int(N)) -> bool = "int.neq";
fn Equal(self: Int(N), other: Int(N)) -> bool = "int.eq";
fn NotEqual(self: Int(N), other: Int(N)) -> bool = "int.neq";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] T as OrderedWith(Int(N)) {
// TODO: fn Compare
fn Less[self: Int(N)](other: Int(N)) -> bool = "int.less";
fn LessOrEquivalent[self: Int(N)](other: Int(N)) -> bool = "int.less_eq";
fn Greater[self: Int(N)](other: Int(N)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Int(N)](other: Int(N)) -> bool = "int.greater_eq";
fn Less(self: Int(N), other: Int(N)) -> bool = "int.less";
fn LessOrEquivalent(self: Int(N), other: Int(N)) -> bool = "int.less_eq";
fn Greater(self: Int(N), other: Int(N)) -> bool = "int.greater";
fn GreaterOrEquivalent(self: Int(N), other: Int(N)) -> bool = "int.greater_eq";
}
// Arithmetic.
@@ -129,86 +129,86 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))] T as OrderedWith(Int(N)) {
final impl forall [N:! IntLiteral]
Int(N) as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sadd";
fn Op(self, other: Self) -> Self = "int.sadd";
}
final impl forall [N:! IntLiteral]
Int(N) as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.sdiv";
fn Op(self, other: Self) -> Self = "int.sdiv";
}
final impl forall [N:! IntLiteral]
Int(N) as ModWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smod";
fn Op(self, other: Self) -> Self = "int.smod";
}
final impl forall [N:! IntLiteral]
Int(N) as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.smul";
fn Op(self, other: Self) -> Self = "int.smul";
}
final impl forall [N:! IntLiteral]
Int(N) as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "int.snegate";
fn Op(self) -> Self = "int.snegate";
}
final impl forall [N:! IntLiteral]
Int(N) as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.ssub";
fn Op(self, other: Self) -> Self = "int.ssub";
}
// - Int(N) on left-hand side.
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as AddWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.sadd";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.sadd";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as DivWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.sdiv";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.sdiv";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as ModWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.smod";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.smod";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as MulWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.smul";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.smul";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as SubWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.ssub";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.ssub";
}
// - Int(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as AddWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.sadd";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.sadd";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as DivWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.sdiv";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.sdiv";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as ModWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.smod";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.smod";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as MulWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.smul";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.smul";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as SubWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.ssub";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.ssub";
}
// Bitwise operators.
@@ -217,138 +217,138 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
final impl forall [N:! IntLiteral]
Int(N) as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.and";
fn Op(self, other: Self) -> Self = "int.and";
}
final impl forall [N:! IntLiteral]
Int(N) as BitComplement where .Result = Self {
fn Op[self: Self]() -> Self = "int.complement";
fn Op(self) -> Self = "int.complement";
}
final impl forall [N:! IntLiteral]
Int(N) as BitOrWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.or";
fn Op(self, other: Self) -> Self = "int.or";
}
final impl forall [N:! IntLiteral]
Int(N) as BitXorWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.xor";
fn Op(self, other: Self) -> Self = "int.xor";
}
final impl forall [N:! IntLiteral]
Int(N) as LeftShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.left_shift";
fn Op(self, other: Self) -> Self = "int.left_shift";
}
final impl forall [N:! IntLiteral]
Int(N) as RightShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.right_shift";
fn Op(self, other: Self) -> Self = "int.right_shift";
}
// - Int(N) on left-hand side.
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitAndWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.and";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.and";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitOrWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.or";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.or";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitXorWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.xor";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.xor";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as LeftShiftWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.left_shift";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.left_shift";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as RightShiftWith(U) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.right_shift";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.right_shift";
}
// - Int(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as BitAndWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.and";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.and";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as BitOrWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.or";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.or";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as BitXorWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.xor";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.xor";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as LeftShiftWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.left_shift";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.left_shift";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(Int(N))]
T as RightShiftWith(Int(N)) where .Result = Int(N) {
fn Op[self: Int(N)](other: Int(N)) -> Int(N) = "int.right_shift";
fn Op(self: Int(N), other: Int(N)) -> Int(N) = "int.right_shift";
}
// Compound assignments.
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as AddAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sadd_assign";
fn Op(ref self, other: Self) = "int.sadd_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitAndAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.and_assign";
fn Op(ref self, other: Self) = "int.and_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitOrAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.or_assign";
fn Op(ref self, other: Self) = "int.or_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as BitXorAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.xor_assign";
fn Op(ref self, other: Self) = "int.xor_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as DivAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.sdiv_assign";
fn Op(ref self, other: Self) = "int.sdiv_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as LeftShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.left_shift_assign";
fn Op(ref self, other: Self) = "int.left_shift_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as ModAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smod_assign";
fn Op(ref self, other: Self) = "int.smod_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as MulAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.smul_assign";
fn Op(ref self, other: Self) = "int.smul_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as RightShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.right_shift_assign";
fn Op(ref self, other: Self) = "int.right_shift_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
Int(N) as SubAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.ssub_assign";
fn Op(ref self, other: Self) = "int.ssub_assign";
}
// Increment and decrement.
@@ -356,7 +356,7 @@ impl forall [N:! IntLiteral, U:! ImplicitAs(Int(N))]
// TODO: Add builtins for these to avoid emitting a call.
impl forall [N:! IntLiteral] Int(N) as Dec {
fn Op[ref self: Self]() {
fn Op(ref self) {
// TODO: `self -= 1;` should work, but fails because the `impl IntLiteral
// as ImplicitAs(Int(N))` is not final, which causes us to not attempt the
// conversion from `1` to `Int(N)` until runtime, when we've lost the
@@ -367,7 +367,7 @@ impl forall [N:! IntLiteral] Int(N) as Dec {
}
impl forall [N:! IntLiteral] Int(N) as Inc {
fn Op[ref self: Self]() {
fn Op(ref self) {
fn AsInt(n: IntLiteral) -> Int(N) = "int.convert_checked";
self += AsInt(1);
}
+13 -13
View File
@@ -16,7 +16,7 @@ import library "prelude/types/maybe_unformed";
private interface OptionalStorage {
let Type:! type;
fn None() -> Type;
fn Some[self: Self]() -> Type;
fn Some(self) -> Type;
fn Has(value: Type) -> bool;
fn Get(value: Type) -> Self;
// Copying can also be performed by Get(value).Some(), but Get returns by
@@ -33,10 +33,10 @@ class Optional(T:! OptionalStorage) {
fn Some(value: T) -> Self {
return value.Some() as Self;
}
fn HasValue[self: Self]() -> bool {
fn HasValue(self) -> bool {
return T.Has(self as T.Type);
}
fn Get[self: Self]() -> T {
fn Get(self) -> T {
return T.Get(self as T.Type);
}
@@ -47,7 +47,7 @@ class Optional(T:! OptionalStorage) {
impl forall [T:! OptionalStorage & UnformedInit] Optional(T) as UnformedInit {}
impl forall [T:! OptionalStorage] Optional(T) as Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return T.Copy(self as T.Type) as Optional(T);
}
}
@@ -58,33 +58,33 @@ impl forall [T:! OptionalStorage] Optional(T) as Copy {
// match_first {
// impl forall [T:! OptionalStorage]
// T as ImplicitAs(Optional(T)) {
// fn Convert[self: T]() -> Optional(T) {
// fn Convert(self: T) -> Optional(T) {
// return Optional(T).Some(self);
// }
// }
//
// impl forall [T:! Destroy & OptionalStorage, U:! ImplicitAs(T)]
// U as ImplicitAs(Optional(T)) {
// fn Convert[self: U]() -> Optional(T) {
// fn Convert(self: U) -> Optional(T) {
// return Optional(T).Some(self.Convert());
// }
// }
// }
private interface OptionalAs(T:! OptionalStorage) {
fn Convert[self: Self]() -> Optional(T);
fn Convert(self) -> Optional(T);
}
final impl forall [T:! OptionalStorage]
T as OptionalAs(T) {
fn Convert[self: Self]() -> Optional(T) {
fn Convert(self) -> Optional(T) {
return Optional(T).Some(self);
}
}
impl forall [T:! Destroy & OptionalStorage, U:! ImplicitAs(T)]
U as OptionalAs(T) {
fn Convert[self: Self]() -> Optional(T) {
fn Convert(self) -> Optional(T) {
return Optional(T).Some(self.Convert());
}
}
@@ -92,7 +92,7 @@ impl forall [T:! Destroy & OptionalStorage, U:! ImplicitAs(T)]
impl forall [T:! Destroy & OptionalStorage,
U:! Destroy & OptionalStorage & ImplicitAs(T)]
Optional(U) as OptionalAs(T) {
fn Convert[self: Self]() -> Optional(T) {
fn Convert(self) -> Optional(T) {
if (self.HasValue()) {
return Optional(T).Some(self.Get().Convert());
}
@@ -102,7 +102,7 @@ impl forall [T:! Destroy & OptionalStorage,
impl forall [T:! OptionalStorage, U:! OptionalAs(T)]
U as ImplicitAs(Optional(T)) {
fn Convert[self: Self]() -> Optional(T) {
fn Convert(self) -> Optional(T) {
return self.Convert();
}
}
@@ -128,7 +128,7 @@ impl forall [T:! Copy & Destroy] T as OptionalStorage
me.has_value = false;
return var;
}
fn Some[self: Self]() -> DefaultOptionalStorage(T) {
fn Some(self) -> DefaultOptionalStorage(T) {
// TODO: This whole function should be just
// return {.value = self, .has_value = true};
// but that requires that `T` implements `ImplicitAs(MaybeUnformed(T))`.
@@ -163,7 +163,7 @@ private fn MakeUninitializedOptionalPointer(T:! type)
final impl forall [T:! type] T* as OptionalStorage
where .Type = MaybeUnformed(T*) {
fn None() -> MaybeUnformed(T*) = "pointer.make_null";
fn Some[self: Self]() -> MaybeUnformed(T*) {
fn Some(self) -> MaybeUnformed(T*) {
returned var result: MaybeUnformed(T*) =
MakeUninitializedOptionalPointer(T);
result unsafe as T* = self;
+3 -3
View File
@@ -14,10 +14,10 @@ import library "prelude/types/int";
import library "prelude/operators/as";
class String {
fn Size[self: Self]() -> u64 { return self.size; }
fn Size(self) -> u64 { return self.size; }
impl as Copy {
fn Op[self: Self]() -> Self { return {.ptr = self.ptr, .size = self.size}; }
fn Op(self) -> Self { return {.ptr = self.ptr, .size = self.size}; }
}
// TODO: This should be an array iterator.
private var ptr: Char*;
@@ -28,5 +28,5 @@ class String {
impl String as UnformedInit {}
impl forall [T:! ImplicitAs(i64)] String as IndexWith(T) where .ElementType = Char {
fn At[self: Self](subscript: T) -> Char = "string.at";
fn At(self, subscript: T) -> Char = "string.at";
}
+86 -86
View File
@@ -23,28 +23,28 @@ impl forall [N:! IntLiteral] UInt(N) as UnformedInit {}
// Copy.
impl forall [N:! IntLiteral] UInt(N) as Copy {
fn Op[self: Self]() -> Self = "primitive_copy";
fn Op(self) -> Self = "primitive_copy";
}
// Conversions.
impl forall [To:! IntLiteral] IntLiteral as ImplicitAs(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "int.convert_checked";
fn Convert(self) -> UInt(To) = "int.convert_checked";
}
final impl forall [From:! IntLiteral] UInt(From) as ImplicitAs(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// TODO: Remove these once ImplicitAs extends As. For now we need them because
// the forwarding impl of As in terms of ImplicitAs is not usable at compile
// time.
impl forall [To:! IntLiteral] IntLiteral as As(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "int.convert_checked";
fn Convert(self) -> UInt(To) = "int.convert_checked";
}
final impl forall [From:! IntLiteral] UInt(From) as As(IntLiteral) {
fn Convert[self: Self]() -> IntLiteral = "int.convert_checked";
fn Convert(self) -> IntLiteral = "int.convert_checked";
}
// Work around the inability to put a `where` clause on a generic parameter of
@@ -52,11 +52,11 @@ final impl forall [From:! IntLiteral] UInt(From) as As(IntLiteral) {
// TODO: Remove this once possible.
private interface AnyUInt {
let Width:! IntLiteral;
fn AsUInt[self: Self]() -> UInt(Width);
fn AsUInt(self) -> UInt(Width);
}
impl forall [N:! IntLiteral] UInt(N) as AnyUInt where .Width = N {
fn AsUInt[self: Self]() -> Self { return self; }
fn AsUInt(self) -> Self { return self; }
}
// Work around the inability to apply constraints to an impl that is only
@@ -84,28 +84,28 @@ impl forall [To:! IntLiteral, From:! AnyUInt & IntFitsIn(Int(To))]
impl forall [From:! IntLiteral, To:! FromUInt(UInt(From))]
UInt(From) as ImplicitAs(To) {
fn Convert[self: Self]() -> To {
fn Convert(self) -> To {
return To.Convert(self);
}
}
final impl forall [From:! IntLiteral, To:! IntLiteral] UInt(From) as As(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "int.convert";
fn Convert(self) -> UInt(To) = "int.convert";
}
final impl forall [From:! IntLiteral, To:! IntLiteral] UInt(From) as As(Int(To)) {
fn Convert[self: Self]() -> Int(To) = "int.convert";
fn Convert(self) -> Int(To) = "int.convert";
}
// Never implicit.
impl forall [From:! IntLiteral, To:! IntLiteral] Int(From) as As(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "int.convert";
fn Convert(self) -> UInt(To) = "int.convert";
}
// Explicit conversion from floating-point literals.
impl forall [To:! IntLiteral]
FloatLiteral as UnsafeAs(UInt(To)) {
fn Convert[self: Self]() -> UInt(To) = "float.convert_int";
fn Convert(self) -> UInt(To) = "float.convert_int";
}
// Comparisons.
@@ -113,76 +113,76 @@ impl forall [To:! IntLiteral]
// - UInt(N) vs UInt(M).
final impl forall [N:! IntLiteral, M:! IntLiteral] UInt(N) as EqWith(UInt(M)) {
fn Equal[self: Self](other: UInt(M)) -> bool = "int.eq";
fn NotEqual[self: Self](other: UInt(M)) -> bool = "int.neq";
fn Equal(self, other: UInt(M)) -> bool = "int.eq";
fn NotEqual(self, other: UInt(M)) -> bool = "int.neq";
}
final impl forall [N:! IntLiteral, M:! IntLiteral] UInt(N) as OrderedWith(UInt(M)) {
// TODO: fn Compare
fn Less[self: Self](other: UInt(M)) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: UInt(M)) -> bool = "int.less_eq";
fn Greater[self: Self](other: UInt(M)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: UInt(M)) -> bool = "int.greater_eq";
fn Less(self, other: UInt(M)) -> bool = "int.less";
fn LessOrEquivalent(self, other: UInt(M)) -> bool = "int.less_eq";
fn Greater(self, other: UInt(M)) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: UInt(M)) -> bool = "int.greater_eq";
}
// - UInt(N) vs Int(M).
final impl forall [N:! IntLiteral, M:! IntLiteral] UInt(N) as EqWith(Int(M)) {
fn Equal[self: Self](other: Int(M)) -> bool = "int.eq";
fn NotEqual[self: Self](other: Int(M)) -> bool = "int.neq";
fn Equal(self, other: Int(M)) -> bool = "int.eq";
fn NotEqual(self, other: Int(M)) -> bool = "int.neq";
}
final impl forall [N:! IntLiteral, M:! IntLiteral] UInt(N) as OrderedWith(Int(M)) {
// TODO: fn Compare
fn Less[self: Self](other: Int(M)) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Int(M)) -> bool = "int.less_eq";
fn Greater[self: Self](other: Int(M)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Int(M)) -> bool = "int.greater_eq";
fn Less(self, other: Int(M)) -> bool = "int.less";
fn LessOrEquivalent(self, other: Int(M)) -> bool = "int.less_eq";
fn Greater(self, other: Int(M)) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Int(M)) -> bool = "int.greater_eq";
}
// - Int(N) vs UInt(M).
impl forall [N:! IntLiteral, M:! IntLiteral] Int(N) as EqWith(UInt(M)) {
fn Equal[self: Self](other: UInt(M)) -> bool = "int.eq";
fn NotEqual[self: Self](other: UInt(M)) -> bool = "int.neq";
fn Equal(self, other: UInt(M)) -> bool = "int.eq";
fn NotEqual(self, other: UInt(M)) -> bool = "int.neq";
}
impl forall [N:! IntLiteral, M:! IntLiteral] Int(N) as OrderedWith(UInt(M)) {
// TODO: fn Compare
fn Less[self: Self](other: UInt(M)) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: UInt(M)) -> bool = "int.less_eq";
fn Greater[self: Self](other: UInt(M)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: UInt(M)) -> bool = "int.greater_eq";
fn Less(self, other: UInt(M)) -> bool = "int.less";
fn LessOrEquivalent(self, other: UInt(M)) -> bool = "int.less_eq";
fn Greater(self, other: UInt(M)) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: UInt(M)) -> bool = "int.greater_eq";
}
// - UInt(N) on left-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] UInt(N) as EqWith(T) {
fn Equal[self: Self](other: Self) -> bool = "int.eq";
fn NotEqual[self: Self](other: Self) -> bool = "int.neq";
fn Equal(self, other: Self) -> bool = "int.eq";
fn NotEqual(self, other: Self) -> bool = "int.neq";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] UInt(N) as OrderedWith(T) {
// TODO: fn Compare
fn Less[self: Self](other: Self) -> bool = "int.less";
fn LessOrEquivalent[self: Self](other: Self) -> bool = "int.less_eq";
fn Greater[self: Self](other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent[self: Self](other: Self) -> bool = "int.greater_eq";
fn Less(self, other: Self) -> bool = "int.less";
fn LessOrEquivalent(self, other: Self) -> bool = "int.less_eq";
fn Greater(self, other: Self) -> bool = "int.greater";
fn GreaterOrEquivalent(self, other: Self) -> bool = "int.greater_eq";
}
// - UInt(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] T as EqWith(UInt(N)) {
fn Equal[self: UInt(N)](other: UInt(N)) -> bool = "int.eq";
fn NotEqual[self: UInt(N)](other: UInt(N)) -> bool = "int.neq";
fn Equal(self: UInt(N), other: UInt(N)) -> bool = "int.eq";
fn NotEqual(self: UInt(N), other: UInt(N)) -> bool = "int.neq";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] T as OrderedWith(UInt(N)) {
// TODO: fn Compare
fn Less[self: UInt(N)](other: UInt(N)) -> bool = "int.less";
fn LessOrEquivalent[self: UInt(N)](other: UInt(N)) -> bool = "int.less_eq";
fn Greater[self: UInt(N)](other: UInt(N)) -> bool = "int.greater";
fn GreaterOrEquivalent[self: UInt(N)](other: UInt(N)) -> bool = "int.greater_eq";
fn Less(self: UInt(N), other: UInt(N)) -> bool = "int.less";
fn LessOrEquivalent(self: UInt(N), other: UInt(N)) -> bool = "int.less_eq";
fn Greater(self: UInt(N), other: UInt(N)) -> bool = "int.greater";
fn GreaterOrEquivalent(self: UInt(N), other: UInt(N)) -> bool = "int.greater_eq";
}
// Arithmetic.
@@ -191,86 +191,86 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))] T as OrderedWith(UInt(N))
final impl forall [N:! IntLiteral]
UInt(N) as AddWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.uadd";
fn Op(self, other: Self) -> Self = "int.uadd";
}
final impl forall [N:! IntLiteral]
UInt(N) as DivWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.udiv";
fn Op(self, other: Self) -> Self = "int.udiv";
}
final impl forall [N:! IntLiteral]
UInt(N) as ModWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.umod";
fn Op(self, other: Self) -> Self = "int.umod";
}
final impl forall [N:! IntLiteral]
UInt(N) as MulWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.umul";
fn Op(self, other: Self) -> Self = "int.umul";
}
final impl forall [N:! IntLiteral]
UInt(N) as Negate where .Result = Self {
fn Op[self: Self]() -> Self = "int.unegate";
fn Op(self) -> Self = "int.unegate";
}
final impl forall [N:! IntLiteral]
UInt(N) as SubWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.usub";
fn Op(self, other: Self) -> Self = "int.usub";
}
// - UInt(N) on left-hand side.
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as AddWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.uadd";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.uadd";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as DivWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.udiv";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.udiv";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as ModWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.umod";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.umod";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as MulWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.umul";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.umul";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as SubWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.usub";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.usub";
}
// - UInt(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as AddWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.uadd";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.uadd";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as DivWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.udiv";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.udiv";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as ModWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.umod";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.umod";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as MulWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.umul";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.umul";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as SubWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.usub";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.usub";
}
// Bitwise operators.
@@ -279,138 +279,138 @@ impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
final impl forall [N:! IntLiteral]
UInt(N) as BitAndWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.and";
fn Op(self, other: Self) -> Self = "int.and";
}
final impl forall [N:! IntLiteral]
UInt(N) as BitComplement where .Result = Self {
fn Op[self: Self]() -> Self = "int.complement";
fn Op(self) -> Self = "int.complement";
}
final impl forall [N:! IntLiteral]
UInt(N) as BitOrWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.or";
fn Op(self, other: Self) -> Self = "int.or";
}
final impl forall [N:! IntLiteral]
UInt(N) as BitXorWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.xor";
fn Op(self, other: Self) -> Self = "int.xor";
}
final impl forall [N:! IntLiteral]
UInt(N) as LeftShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.left_shift";
fn Op(self, other: Self) -> Self = "int.left_shift";
}
final impl forall [N:! IntLiteral]
UInt(N) as RightShiftWith(Self) where .Result = Self {
fn Op[self: Self](other: Self) -> Self = "int.right_shift";
fn Op(self, other: Self) -> Self = "int.right_shift";
}
// - UInt(N) on left-hand side.
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitAndWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.and";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.and";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitOrWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.or";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.or";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitXorWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.xor";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.xor";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as LeftShiftWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.left_shift";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.left_shift";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as RightShiftWith(U) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.right_shift";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.right_shift";
}
// - UInt(N) on right-hand side.
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as BitAndWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.and";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.and";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as BitOrWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.or";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.or";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as BitXorWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.xor";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.xor";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as LeftShiftWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.left_shift";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.left_shift";
}
impl forall [N:! IntLiteral, T:! ImplicitAs(UInt(N))]
T as RightShiftWith(UInt(N)) where .Result = UInt(N) {
fn Op[self: UInt(N)](other: UInt(N)) -> UInt(N) = "int.right_shift";
fn Op(self: UInt(N), other: UInt(N)) -> UInt(N) = "int.right_shift";
}
// Compound assignments.
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as AddAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.uadd_assign";
fn Op(ref self, other: Self) = "int.uadd_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitAndAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.and_assign";
fn Op(ref self, other: Self) = "int.and_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitOrAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.or_assign";
fn Op(ref self, other: Self) = "int.or_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as BitXorAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.xor_assign";
fn Op(ref self, other: Self) = "int.xor_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as DivAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.udiv_assign";
fn Op(ref self, other: Self) = "int.udiv_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as LeftShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.left_shift_assign";
fn Op(ref self, other: Self) = "int.left_shift_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as ModAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.umod_assign";
fn Op(ref self, other: Self) = "int.umod_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as MulAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.umul_assign";
fn Op(ref self, other: Self) = "int.umul_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as RightShiftAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.right_shift_assign";
fn Op(ref self, other: Self) = "int.right_shift_assign";
}
impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
UInt(N) as SubAssignWith(U) {
fn Op[ref self: Self](other: Self) = "int.usub_assign";
fn Op(ref self, other: Self) = "int.usub_assign";
}
// Increment and decrement.
@@ -418,7 +418,7 @@ impl forall [N:! IntLiteral, U:! ImplicitAs(UInt(N))]
// TODO: Add builtins for these to avoid emitting a call.
impl forall [N:! IntLiteral] UInt(N) as Dec {
fn Op[ref self: Self]() {
fn Op(ref self) {
// TODO: `self -= 1;` should work, but fails because the `impl IntLiteral
// as ImplicitAs(Int(N))` is not final, which causes us to not attempt the
// conversion from `1` to `Int(N)` until runtime, when we've lost the
@@ -429,7 +429,7 @@ impl forall [N:! IntLiteral] UInt(N) as Dec {
}
impl forall [N:! IntLiteral] UInt(N) as Inc {
fn Op[ref self: Self]() {
fn Op(ref self) {
fn AsUInt(n: IntLiteral) -> UInt(N) = "int.convert_checked";
self += AsUInt(1);
}
+2 -2
View File
@@ -22,8 +22,8 @@ class IntRange(N:! IntLiteral) {
}
impl as Iterate where .CursorType = Int(N) and .ElementType = Int(N) {
fn NewCursor[self: Self]() -> Int(N) { return self.start; }
fn Next[self: Self](cursor: Int(N)*) -> Optional(Int(N)) {
fn NewCursor(self) -> Int(N) { return self.start; }
fn Next(self, cursor: Int(N)*) -> Optional(Int(N)) {
var value: Int(N) = *cursor;
if (value < self.end) {
++*cursor;
+1 -1
View File
@@ -74,7 +74,7 @@ standard library.
The operands of these operators can be any [expression](expressions/README.md).
However, the first operand must be modifiable because it is passed to a
`[ref self: Self]` parameter, which disallows most expression forms other than:
`(ref self: Self)` parameter, which disallows most expression forms other than:
- The name of a `var` binding.
- A dereference of a pointer.
+2 -2
View File
@@ -6630,7 +6630,7 @@ example, this `Set(T)` type may be compared to anything implementing the
```carbon
class Set(T:! Ordered) {
fn Less[U:! Container with .ElementType = T, self: Self](u: U) -> bool;
fn Less[U:! Container with .ElementType = T](self, u: U) -> bool;
// ...
}
```
@@ -6648,7 +6648,7 @@ its elements implement the `Ordered` interface:
```carbon
class DynArray(T:! type) {
// `DynArray(T)` has a `Sort()` method if `T impls Ordered`.
fn Sort[C:! Ordered, ref self: DynArray(C)]();
fn Sort[C:! Ordered](ref self: DynArray(C));
}
```
+2 -2
View File
@@ -40,7 +40,7 @@ class Reachable {
return var;
}
fn AddLevel[ref self: Self](terrain: Terrain, level: i32) {
fn AddLevel(ref self, terrain: Terrain, level: i32) {
let adj: array((i32, i32), 4) = ((-1, 0), (0, -1), (1, 0), (0, 1));
for (y: i32 in Core.Range(43)) {
for (x: i32 in Core.Range(43)) {
@@ -63,7 +63,7 @@ class Reachable {
}
}
fn Count[self: Self](terrain: Terrain, level: i32) -> i32 {
fn Count(self, terrain: Terrain, level: i32) -> i32 {
var total: i32 = 0;
for (y: i32 in Core.Range(43)) {
for (x: i32 in Core.Range(43)) {
+1 -1
View File
@@ -25,7 +25,7 @@ class PathsToTop {
return var;
}
fn AddLevel[ref self: Self](terrain: Terrain, level: i32) -> i64 {
fn AddLevel(ref self, terrain: Terrain, level: i32) -> i64 {
var total: i64 = 0;
let adj: array((i32, i32), 4) = ((-1, 0), (0, -1), (1, 0), (0, 1));
for (y: i32 in Core.Range(43)) {
+1 -1
View File
@@ -23,7 +23,7 @@ class Digits {
return var;
}
fn Print[self: Self](max_depth: i32) {
fn Print(self, max_depth: i32) {
for (digit: i32 in Core.Range(10)) {
Core.PrintChar(((digit + 0x30) as u8) as char);
Core.PrintChar(':');
+6 -6
View File
@@ -24,7 +24,7 @@ class Map {
return var;
}
fn At[self: Self](x: i32, y: i32) -> i32 {
fn At(self, x: i32, y: i32) -> i32 {
return if x < 0 or x >= 140 or y < 0 or y >= 140
then -1
else self.kind[x][y];
@@ -46,7 +46,7 @@ class DisjointSetForest {
return var;
}
fn Lookup[ref self: Self](a: i32) -> i32 {
fn Lookup(ref self, a: i32) -> i32 {
let next: i32 = self.nodes[a].next;
if (next == a) {
return next;
@@ -56,21 +56,21 @@ class DisjointSetForest {
return resolved;
}
fn Unions[self: Self](canon_a: i32) -> i32 {
fn Unions(self, canon_a: i32) -> i32 {
return self.nodes[canon_a].unions;
}
fn Weight[self: Self](canon_a: i32) -> i32 {
fn Weight(self, canon_a: i32) -> i32 {
return self.nodes[canon_a].weight;
}
fn Union[ref self: Self](a: i32, b: i32) {
fn Union(ref self, a: i32, b: i32) {
let canon_b: i32 = self.Lookup(b);
self.Set(a, canon_b);
++self.nodes[canon_b].unions;
}
private fn Set[ref self: Self](a: i32, canon_b: i32) {
private fn Set(ref self, a: i32, canon_b: i32) {
let next: i32 = self.nodes[a].next;
self.nodes[a].next = canon_b;
if (next == a) {
+2 -2
View File
@@ -85,11 +85,11 @@ class BezoutSolutionSet {
.m_step = b_over_gcd, .n_step = -a_over_gcd};
}
fn Valid[self: Self]() -> bool {
fn Valid(self) -> bool {
return self.m_step >= 0;
}
fn Solution[self: Self](k: i64) -> (i64, i64) {
fn Solution(self, k: i64) -> (i64, i64) {
return (self.m0 + k * self.m_step, self.n0 + k * self.n_step);
}
+2 -2
View File
@@ -35,13 +35,13 @@ class Robot {
return var;
}
fn Pos[self: Self](t: i32) -> (i32, i32) {
fn Pos(self, t: i32) -> (i32, i32) {
return (Mod((self.p.0 + self.v.0 * Mod(t, 101)), 101),
Mod((self.p.1 + self.v.1 * Mod(t, 103)), 103));
}
impl as Core.Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return {.p = self.p, .v = self.v};
}
}
+6 -6
View File
@@ -14,16 +14,16 @@ class Square {
adapt char;
impl as Core.Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return (self as char).(Core.Copy.Op)() as Self;
}
}
impl as Core.EqWith(Square) {
fn Equal[self: Self](other: Self) -> bool {
fn Equal(self, other: Self) -> bool {
// TODO: Use a `char` comparison when it's supported.
return (self as u8) == (other as u8);
}
fn NotEqual[self: Self](other: Self) -> bool {
fn NotEqual(self, other: Self) -> bool {
// TODO: Use a `char` comparison when it's supported.
return (self as u8) != (other as u8);
}
@@ -65,7 +65,7 @@ class Grid {
return var;
}
fn Move[ref self: Self](d: (i32, i32)) {
fn Move(ref self, d: (i32, i32)) {
var distance: i32 = 1;
while (self.data[self.robot.0 + distance * d.0][self.robot.1 + distance * d.1] == Box) {
++distance;
@@ -79,7 +79,7 @@ class Grid {
}
}
fn Print[self: Self]() {
fn Print(self) {
var y: i32 = 0;
while (y < 50) {
var x: i32 = 0;
@@ -93,7 +93,7 @@ class Grid {
Core.PrintChar('\n');
}
fn Signature[self: Self]() -> i32 {
fn Signature(self) -> i32 {
var s: i32 = 0;
var y: i32 = 0;
while (y < 50) {
+1 -1
View File
@@ -15,7 +15,7 @@ class ReportState {
.increasing = false, .safe_so_far = true};
}
fn Add[ref self: Self](level: i32) {
fn Add(ref self, level: i32) {
++self.levels_so_far;
if (self.levels_so_far >= 2) {
if (not IsSafeDelta(self.previous, level)) {
+4 -4
View File
@@ -12,7 +12,7 @@ import library "io_utils";
// A three-element sliding window of recent levels.
class Window {
fn Make() -> Window { return {.data = (0,0,0), .size = 0}; }
fn Add[ref self: Self](n: i32) {
fn Add(ref self, n: i32) {
self.data[2] = self.data[1];
self.data[1] = self.data[0];
self.data[0] = n;
@@ -36,7 +36,7 @@ class ReportState {
.removable_double_bad_edge = false};
}
fn OnAdd[ref self: Self](window: Window) {
fn OnAdd(ref self, window: Window) {
if (window.size < 2) {
return;
}
@@ -75,7 +75,7 @@ class ReportState {
}
}
fn OnFinish[ref self: Self](window: Window) {
fn OnFinish(ref self, window: Window) {
if (window.size >= 2 and
not IsSafe(window.data[1], window.data[0], self.increasing)) {
// We have a removable single bad edge if the last edge is unsafe.
@@ -83,7 +83,7 @@ class ReportState {
}
}
fn IsSafeWithRemoval[self: Self]() -> bool {
fn IsSafeWithRemoval(self) -> bool {
return self.bad_edges == 0 or
(self.bad_edges == 1 and self.removable_single_bad_edge) or
(self.bad_edges == 2 and self.removable_double_bad_edge);
+3 -3
View File
@@ -29,12 +29,12 @@ class Wordsearch {
return var;
}
fn At[self: Self](x: i32, y: i32) -> i32 {
fn At(self, x: i32, y: i32) -> i32 {
return if x < 0 or x >= 140 or y < 0 or y >= 140 then -1 else self.grid[x][y];
}
// TODO: Make this generic in the length of the search query.
fn Check4[self: Self](xmas: array(i32, 4), x: i32, y: i32, dx: i32, dy: i32) -> bool {
fn Check4(self, xmas: array(i32, 4), x: i32, y: i32, dx: i32, dy: i32) -> bool {
var i: i32 = 0;
while (i < 4) {
if (self.At(x + i * dx, y + i * dy) != xmas[i]) {
@@ -45,7 +45,7 @@ class Wordsearch {
return true;
}
fn Check3[self: Self](mas: array(i32, 3), x: i32, y: i32, dx: i32, dy: i32) -> bool {
fn Check3(self, mas: array(i32, 3), x: i32, y: i32, dx: i32, dy: i32) -> bool {
var i: i32 = 0;
while (i < 3) {
if (self.At(x + i * dx, y + i * dy) != mas[i]) {
+6 -6
View File
@@ -33,7 +33,7 @@ class Rules {
return var;
}
fn IsValidOrder[self: Self](a: i32, b: i32) -> bool {
fn IsValidOrder(self, a: i32, b: i32) -> bool {
return self.disallowed_before[b] & PageMask(a) == 0;
}
@@ -65,12 +65,12 @@ class PageList {
return var;
}
fn Add[ref self: Self](page: i32) {
fn Add(ref self, page: i32) {
self.pages[self.num_pages] = page;
++self.num_pages;
}
fn FollowsRules[self: Self](rules: Rules) -> bool {
fn FollowsRules(self, rules: Rules) -> bool {
var seen: Core.UInt(100) = 0;
for (i: i32 in Core.Range(self.num_pages)) {
let page: i32 = self.pages[i];
@@ -82,7 +82,7 @@ class PageList {
return true;
}
fn IsPossibleFirstPage[self: Self](rules: Rules, page: i32) -> bool {
fn IsPossibleFirstPage(self, rules: Rules, page: i32) -> bool {
for (i: i32 in Core.Range(self.num_pages)) {
if (not rules.IsValidOrder(page, self.pages[i])) {
return false;
@@ -91,7 +91,7 @@ class PageList {
return true;
}
fn ExtractPossibleFirstPage[ref self: Self](rules: Rules) -> i32 {
fn ExtractPossibleFirstPage(ref self, rules: Rules) -> i32 {
for (i: i32 in Core.Range(self.num_pages)) {
var page: i32 = self.pages[i];
if (self.IsPossibleFirstPage(rules, page)) {
@@ -104,7 +104,7 @@ class PageList {
return 0;
}
fn MiddlePage[self: Self]() -> i32 {
fn MiddlePage(self) -> i32 {
return self.pages[self.num_pages / 2];
}
+4 -4
View File
@@ -43,7 +43,7 @@ class Maze {
return var;
}
fn Copy[self: Self]() -> Maze {
fn Copy(self) -> Maze {
returned var copy: Maze;
var y: i32 = 0;
while (y < 130) {
@@ -59,7 +59,7 @@ class Maze {
return var;
}
fn Step[ref self: Self]() -> bool {
fn Step(ref self) -> bool {
let x: i32 = self.loc.0 + self.dir.0;
let y: i32 = self.loc.1 + self.dir.1;
if (x < 0 or x >= 130 or y < 0 or y >= 130) {
@@ -77,7 +77,7 @@ class Maze {
return true;
}
fn AddObstacle[ref self: Self]() -> bool {
fn AddObstacle(ref self) -> bool {
let x: i32 = self.loc.0 + self.dir.0;
let y: i32 = self.loc.1 + self.dir.1;
if (x < 0 or x >= 130 or y < 0 or y >= 130) {
@@ -90,7 +90,7 @@ class Maze {
return true;
}
fn CountVisited[self: Self]() -> i32 {
fn CountVisited(self) -> i32 {
var total: i32 = 0;
var y: i32 = 0;
while (y < 130) {
+1 -1
View File
@@ -13,7 +13,7 @@ class LoopDetector {
return {.last = ((-1, -1), (-1, -1)), .steps = 1, .next_steps = 1};
}
fn Check[ref self: Self](next: ((i32, i32), (i32, i32))) -> bool {
fn Check(ref self, next: ((i32, i32), (i32, i32))) -> bool {
// TODO: if (next == self.last) {
if (next.0.0 == self.last.0.0 and next.0.1 == self.last.0.1 and
next.1.0 == self.last.1.0 and next.1.1 == self.last.1.1) {
+2 -2
View File
@@ -38,7 +38,7 @@ class Equation {
return var;
}
fn SolveFrom[self: Self](start: i32, value: i64, concat: bool) -> bool {
fn SolveFrom(self, start: i32, value: i64, concat: bool) -> bool {
if (value > self.result) {
return false;
}
@@ -50,7 +50,7 @@ class Equation {
(concat and self.SolveFrom(start + 1, Concat(value, self.operands[start]), true));
}
fn Solve[self: Self](concat: bool) -> bool {
fn Solve(self, concat: bool) -> bool {
return self.SolveFrom(1, self.operands[0], concat);
}
+5 -5
View File
@@ -35,7 +35,7 @@ class SectorList {
return var;
}
fn DefragBlocks[ref self: Self]() {
fn DefragBlocks(ref self) {
var i: i32 = 0;
var j: i32 = self.size - 1;
while (j > i) {
@@ -52,7 +52,7 @@ class SectorList {
self.size = j;
}
fn HasSpace[ref self: Self](start: i32, size: i32) -> bool {
fn HasSpace(ref self, start: i32, size: i32) -> bool {
for (i: i32 in Core.InclusiveRange(start, start + size - 1)) {
if (self.data[i] != -1) {
return false;
@@ -61,13 +61,13 @@ class SectorList {
return true;
}
fn Fill[ref self: Self](start: i32, size: i32, sector: i32) {
fn Fill(ref self, start: i32, size: i32, sector: i32) {
for (i: i32 in Core.InclusiveRange(start, start + size - 1)) {
self.data[i] = sector;
}
}
fn DefragFiles[ref self: Self]() {
fn DefragFiles(ref self) {
var j: i32 = self.size - 1;
while (j >= 0) {
// Skip empty sectors.
@@ -101,7 +101,7 @@ class SectorList {
}
}
fn Checksum[self: Self]() -> i64 {
fn Checksum(self) -> i64 {
var total: i64 = 0;
for (i: i32 in Core.Range(self.size)) {
if (self.data[i] != -1) {
+9 -9
View File
@@ -16,7 +16,7 @@ class CharOrEOF {
}
impl CharOrEOF as Core.Copy {
fn Op[self: Self]() -> Self {
fn Op(self) -> Self {
return (self as i32).(Core.Copy.Op)() as Self;
}
}
@@ -28,40 +28,40 @@ fn CharOrEOF.EOF() -> Self {
}
impl forall [U:! Core.ImplicitAs(char)] U as Core.ImplicitAs(CharOrEOF) {
fn Convert[self: char]() -> CharOrEOF {
fn Convert(self: char) -> CharOrEOF {
return ((self as u8) as i32) as CharOrEOF;
}
}
impl forall [U:! Core.ImplicitAs(CharOrEOF)]
CharOrEOF as Core.EqWith(U) {
fn Equal[self: Self](other: CharOrEOF) -> bool {
fn Equal(self, other: CharOrEOF) -> bool {
return (self as i32) == (other as i32);
}
fn NotEqual[self: Self](other: CharOrEOF) -> bool {
fn NotEqual(self, other: CharOrEOF) -> bool {
return (self as i32) != (other as i32);
}
}
impl forall [U:! Core.ImplicitAs(CharOrEOF)]
CharOrEOF as Core.OrderedWith(U) {
fn Less[self: Self](other: CharOrEOF) -> bool {
fn Less(self, other: CharOrEOF) -> bool {
return (self as i32) < (other as i32);
}
fn LessOrEquivalent[self: Self](other: CharOrEOF) -> bool {
fn LessOrEquivalent(self, other: CharOrEOF) -> bool {
return (self as i32) <= (other as i32);
}
fn Greater[self: Self](other: CharOrEOF) -> bool {
fn Greater(self, other: CharOrEOF) -> bool {
return (self as i32) > (other as i32);
}
fn GreaterOrEquivalent[self: Self](other: CharOrEOF) -> bool {
fn GreaterOrEquivalent(self, other: CharOrEOF) -> bool {
return (self as i32) >= (other as i32);
}
}
impl forall [U:! Core.ImplicitAs(char)]
CharOrEOF as Core.SubWith(U) where .Result = i32 {
fn Op[self: Self](other: char) -> i32 {
fn Op(self, other: char) -> i32 {
return (self as i32) - ((other as u8) as i32);
}
}
+8 -8
View File
@@ -6,17 +6,17 @@ library "sort";
interface Ordered {
// extend require impls Core.OrderedWith(Self);
fn Less[self: Self](other: Self) -> bool;
fn LessOrEquivalent[self: Self](other: Self) -> bool;
fn Greater[self: Self](other: Self) -> bool;
fn GreaterOrEquivalent[self: Self](other: Self) -> bool;
fn Less(self, other: Self) -> bool;
fn LessOrEquivalent(self, other: Self) -> bool;
fn Greater(self, other: Self) -> bool;
fn GreaterOrEquivalent(self, other: Self) -> bool;
}
impl i32 as Ordered {
fn Less[self: Self](other: Self) -> bool { return self < other; }
fn LessOrEquivalent[self: Self](other: Self) -> bool { return self <= other; }
fn Greater[self: Self](other: Self) -> bool { return self > other; }
fn GreaterOrEquivalent[self: Self](other: Self) -> bool { return self >= other; }
fn Less(self, other: Self) -> bool { return self < other; }
fn LessOrEquivalent(self, other: Self) -> bool { return self <= other; }
fn Greater(self, other: Self) -> bool { return self > other; }
fn GreaterOrEquivalent(self, other: Self) -> bool { return self >= other; }
}
fn Swap[T:! Core.Copy & Core.Destroy](ref from: T, ref to: T) {
@@ -16,13 +16,13 @@ class RE2 {
fn Make(re: str) -> Self {
return RE2(re) as Self;
}
fn Match[self: Self](text: str) -> bool {
fn Match(self, text: str) -> bool {
return FullMatch(text, self as Cpp.re2.RE2);
}
}
impl str as Core.ImplicitAs(Cpp.llvm.StringRef) {
fn Convert[self: Self]() -> Cpp.llvm.StringRef {
fn Convert(self) -> Cpp.llvm.StringRef {
return Cpp.llvm.StringRef.StringRef(self);
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ class Sieve {
return var;
}
fn MarkMultiplesNotPrime[ref self: Self](p: i32) {
fn MarkMultiplesNotPrime(ref self, p: i32) {
var n: i32 = p * 2;
while (n < 1000) {
self.is_prime[n] = false;
+61 -61
View File
@@ -290,52 +290,52 @@ class RE2 {
// TODO: Should a Carbonic RE2 support these?
impl StringView as ImplicitAs(RE2) {
fn Convert[self: Self]() -> RE2 { return Make(self); }
fn Convert(self) -> RE2 { return Make(self); }
}
impl String as ImplicitAs(RE2) {
fn Convert[self: Self]() -> RE2 { return Make(self); }
fn Convert(self) -> RE2 { return Make(self); }
}
impl StringPiece as ImplicitAs(RE2) {
fn Convert[self: Self]() -> RE2 { return Make(self); }
fn Convert(self) -> RE2 { return Make(self); }
}
impl as Destroyable;
// Returns whether RE2 was created properly.
fn ok[self: Self]() -> bool { return self.error_code() == ErrorCode.NoError; }
fn ok(self) -> bool { return self.error_code() == ErrorCode.NoError; }
// The string specification for this RE2. E.g.
// RE2 re("ab*c?d+");
// re.pattern(); // "ab*c?d+"
fn pattern[self: Self]() -> String { return self.pattern_; }
fn pattern(self) -> String { return self.pattern_; }
// If RE2 could not be created properly, returns an error string.
// Else returns the empty string.
fn error[self: Self]() -> String { return *self.error_; }
fn error(self) -> String { return *self.error_; }
// If RE2 could not be created properly, returns an error code.
// Else returns RE2::NoError (== 0).
fn error_code[self: Self]() -> ErrorCode { return self.error_code_; }
fn error_code(self) -> ErrorCode { return self.error_code_; }
// If RE2 could not be created properly, returns the offending
// portion of the regexp.
fn error_arg[self: Self]() -> String { return self.error_arg_; }
fn error_arg(self) -> String { return self.error_arg_; }
// Returns the program size, a very approximate measure of a regexp's "cost".
// Larger numbers are more expensive than smaller numbers.
fn ProgramSize[self: Self]() -> i32;
fn ReverseProgramSize[self: Self]() -> i32;
fn ProgramSize(self) -> i32;
fn ReverseProgramSize(self) -> i32;
// If histogram is not null, outputs the program fanout
// as a histogram bucketed by powers of 2.
// Returns the number of the largest non-empty bucket.
fn ProgramFanout[self: Self](histogram: Cpp.std.vector(i32)*) -> i32;
fn ReverseProgramFanout[self: Self](histogram: Cpp.std.vector(i32)*) -> i32;
fn ProgramFanout(self, histogram: Cpp.std.vector(i32)*) -> i32;
fn ReverseProgramFanout(self, histogram: Cpp.std.vector(i32)*) -> i32;
// Returns the underlying Regexp; not for general use.
// Returns entire_regexp_ so that callers don't need
// to know about prefix_ and prefix_foldcase_.
fn Regexp[self: Self]() -> package.Regexp* { return self.entire_regexp_; }
fn Regexp(self) -> package.Regexp* { return self.entire_regexp_; }
/***** The array-based matching interface ******/
@@ -535,7 +535,7 @@ class RE2 {
// do not compile down to infinite repetitions.
//
// Returns true on success, false on error.
fn PossibleMatchRange[self: Self](min: String*, max: String*, maxlen: i32);
fn PossibleMatchRange(self, min: String*, max: String*, maxlen: i32);
// Generic matching interface
@@ -552,18 +552,18 @@ class RE2 {
// Return the number of capturing subpatterns, or -1 if the
// regexp wasn't valid on construction. The overall match ($0)
// does not count: if the regexp is "(a)(b)", returns 2.
fn NumberOfCapturingGroups[self: Self]() -> i32 { return self.num_captures_; }
fn NumberOfCapturingGroups(self) -> i32 { return self.num_captures_; }
// Return a map from names to capturing indices.
// The map records the index of the leftmost group
// with the given name.
// NOTE: Originally returned by reference with comment "valid until re is deleted".
fn NamedCapturingGroups[self: Self]() -> Map(String, i32);
fn NamedCapturingGroups(self) -> Map(String, i32);
// Return a map from capturing indices to names.
// The map has no entries for unnamed groups.
// NOTE: Originally returned by reference with comment "valid until re is deleted".
fn CapturingGroupNames[self: Self]() -> Map(i32, String);
fn CapturingGroupNames(self) -> Map(i32, String);
// General matching routine.
// Match against text starting at offset startpos
@@ -586,7 +586,7 @@ class RE2 {
// empty string, but note that on return, it will not be possible to tell
// whether submatch i matched the empty string or did not match:
// either way, submatch[i].data() == NULL.
fn Match[self: Self](text: StringPiece,
fn Match(self, text: StringPiece,
startpos: i64,
endpos: i64,
re_anchor: Anchor,
@@ -602,7 +602,7 @@ class RE2 {
// '\' followed by anything other than a digit or '\'.
// A true return value guarantees that Replace() and Extract() won't
// fail because of a bad rewrite string.
fn CheckRewriteString[self: Self](rewrite: StringPiece, error: String*) -> bool;
fn CheckRewriteString(self, rewrite: StringPiece, error: String*) -> bool;
// Returns the maximum submatch needed for the rewrite to be done by
// Replace(). E.g. if rewrite == "foo \\2,\\1", returns 2.
@@ -613,7 +613,7 @@ class RE2 {
// Returns true on success. This method can fail because of a malformed
// rewrite string. CheckRewriteString guarantees that the rewrite will
// be successful.
fn Rewrite[self: Self](out: String*, rewrite: StringPiece,
fn Rewrite(self, out: String*, rewrite: StringPiece,
vec: ArrayIterator(StringPiece), veclen: i32)
-> bool;
@@ -696,50 +696,50 @@ class RE2 {
impl CannedOptions as ImplicitAs(Self);
fn encoding[self: Self]() -> Encoding { return self.encoding_; }
fn set_encoding[ref self: Self](encoding: Encoding) { self.encoding_ = encoding; }
fn encoding(self) -> Encoding { return self.encoding_; }
fn set_encoding(ref self, encoding: Encoding) { self.encoding_ = encoding; }
fn posix_syntax[self: Self]() -> bool { return self.posix_syntax_; }
fn set_posix_syntax[ref self: Self](b: bool) { self.posix_syntax_ = b; }
fn posix_syntax(self) -> bool { return self.posix_syntax_; }
fn set_posix_syntax(ref self, b: bool) { self.posix_syntax_ = b; }
fn longest_match[self: Self]() -> bool { return self.longest_match_; }
fn set_longest_match[ref self: Self](b: bool) { self.longest_match_ = b; }
fn longest_match(self) -> bool { return self.longest_match_; }
fn set_longest_match(ref self, b: bool) { self.longest_match_ = b; }
fn log_errors[self: Self]() -> bool { return self.log_errors_; }
fn set_log_errors[ref self: Self](b: bool) { self.log_errors_ = b; }
fn log_errors(self) -> bool { return self.log_errors_; }
fn set_log_errors(ref self, b: bool) { self.log_errors_ = b; }
fn max_mem[self: Self]() -> i64 { return self.max_mem_; }
fn set_max_mem[ref self: Self](m: i64) { self.max_mem_ = m; }
fn max_mem(self) -> i64 { return self.max_mem_; }
fn set_max_mem(ref self, m: i64) { self.max_mem_ = m; }
fn literal[self: Self]() -> bool { return self.literal_; }
fn set_literal[ref self: Self](b: bool) { self.literal_ = b; }
fn literal(self) -> bool { return self.literal_; }
fn set_literal(ref self, b: bool) { self.literal_ = b; }
fn never_nl[self: Self]() -> bool { return self.never_nl_; }
fn set_never_nl[ref self: Self](b: bool) { self.never_nl_ = b; }
fn never_nl(self) -> bool { return self.never_nl_; }
fn set_never_nl(ref self, b: bool) { self.never_nl_ = b; }
fn dot_nl[self: Self]() -> bool { return self.dot_nl_; }
fn set_dot_nl[ref self: Self](b: bool) { self.dot_nl_ = b; }
fn dot_nl(self) -> bool { return self.dot_nl_; }
fn set_dot_nl(ref self, b: bool) { self.dot_nl_ = b; }
fn never_capture[self: Self]() -> bool { return self.never_capture_; }
fn set_never_capture[ref self: Self](b: bool) { self.never_capture_ = b; }
fn never_capture(self) -> bool { return self.never_capture_; }
fn set_never_capture(ref self, b: bool) { self.never_capture_ = b; }
fn case_sensitive[self: Self]() -> bool { return self.case_sensitive_; }
fn set_case_sensitive[ref self: Self](b: bool) { self.case_sensitive_ = b; }
fn case_sensitive(self) -> bool { return self.case_sensitive_; }
fn set_case_sensitive(ref self, b: bool) { self.case_sensitive_ = b; }
fn perl_classes[self: Self]() -> bool { return self.perl_classes_; }
fn set_perl_classes[ref self: Self](b: bool) { self.perl_classes_ = b; }
fn perl_classes(self) -> bool { return self.perl_classes_; }
fn set_perl_classes(ref self, b: bool) { self.perl_classes_ = b; }
fn word_boundary[self: Self]() -> bool { return self.word_boundary_; }
fn set_word_boundary[ref self: Self](b: bool) { self.word_boundary_ = b; }
fn word_boundary(self) -> bool { return self.word_boundary_; }
fn set_word_boundary(ref self, b: bool) { self.word_boundary_ = b; }
fn one_line[self: Self]() -> bool { return self.one_line_; }
fn set_one_line[ref self: Self](b: bool) { self.one_line_ = b; }
fn one_line(self) -> bool { return self.one_line_; }
fn set_one_line(ref self, b: bool) { self.one_line_ = b; }
fn Copy[ref self: Self](src: Options) {
fn Copy(ref self, src: Options) {
self = src;
}
fn ParseFlags[self: Self]() -> i32;
fn ParseFlags(self) -> i32;
private var encoding_: Encoding;
private var posix_syntax_: bool;
@@ -757,7 +757,7 @@ class RE2 {
};
// Returns the options set in the constructor.
fn options[self: Self]() -> Options { return self.options_; }
fn options(self) -> Options { return self.options_; }
// Argument converters; see below.
// TODO: Should these be package members not class members in Carbon
@@ -766,9 +766,9 @@ class RE2 {
fn Hex[T:! Parse4ary](ptr: T*) -> Self.Arg;
fn Octal[T:! Parse4ary](ptr: T*) -> Self.Arg;
private fn Init[addr self: Self](pattern: StringPiece, options: Options);
private fn Init(addr self: Self, pattern: StringPiece, options: Options);
private fn DoMatch[self: Self](text: StringPiece,
private fn DoMatch(self, text: StringPiece,
re_anchor: Anchor,
consumed: i64*,
// TODO: Pointer to `const Arg`.
@@ -776,7 +776,7 @@ class RE2 {
n: i32)
-> bool;
fn ReverseProg[self: Self]() -> package.Prog*;
fn ReverseProg(self) -> package.Prog*;
// string regular expression
private var pattern_: String;
@@ -853,21 +853,21 @@ class RE2.Arg {
fn Make(nullptr) -> Self { return Make(nullptr as NullArg*); }
interface Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool;
fn Parse(ref self, str: StringView, n: i64) -> bool;
}
match_first {
impl [T:! Parse3ary] T as Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool {
fn Parse(ref self, str: StringView, n: i64) -> bool {
return T.Parse(str, n, self);
}
}
impl [T:! Parse4ary] T as Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool {
fn Parse(ref self, str: StringView, n: i64) -> bool {
return T.Parse(str, n, self, 10);
}
}
impl [T:! ParseFrom] T as Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool {
fn Parse(ref self, str: StringView, n: i64) -> bool {
if (self == nullptr) { return true; }
return T.Parse(str, n, self);
}
@@ -876,7 +876,7 @@ class RE2.Arg {
private class NullArg {}
impl NullArg as Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool {
fn Parse(ref self, str: StringView, n: i64) -> bool {
return true;
}
}
@@ -885,7 +885,7 @@ class RE2.Arg {
return {.type_ = T, .arg_ = ptr};
}
fn Parse[self: Self](str: StringView, n: i64) -> bool {
fn Parse(self, str: StringView, n: i64) -> bool {
return self.arg_->Parse(str, n);
}
@@ -896,7 +896,7 @@ class RE2.Arg {
private adapter ParseAsBase(T:! Parse4ary, base: i32) for T {
impl as Self.Arg.Parseable {
fn Parse[ref self: Self](str: StringView, n: i64) -> bool {
fn Parse(ref self, str: StringView, n: i64) -> bool {
return T.Parse(str, n, self, base);
}
}
@@ -938,11 +938,11 @@ class LazyRE2 {
// Pretend to be a pointer to Type (never NULL due to on-demand creation):
impl as Pointer where .Pointee = RE2 {
fn Resolve[self: Self]() -> Pointee* { return self.get(); }
fn Resolve(self) -> Pointee* { return self.get(); }
}
// Named accessor/initializer:
fn get[ref self: Self]() -> RE* {
fn get(ref self) -> RE* {
Cpp.std.call_once(once_, Self.Init, self);
return ptr_;
}
+15 -7
View File
@@ -275,7 +275,10 @@ static auto EstimateAvgFunctionDeclLines(SourceGen::FunctionDeclParams params)
static auto EstimateAvgMethodDeclLines(SourceGen::MethodDeclParams params)
-> double {
// Currently model a uniform distribution [0, max] parameters. Assume a line
// break before the first parameter for >2 and after every 4th.
// break before the first parameter for >2 and after every 4th. A Carbon
// method also emits a leading `self`, but `self` only rarely tips a method
// onto an additional wrapped line, so the estimate ignores it; this stays
// calibrated against the emitter (see `source_gen_test`).
int param_lines = 0;
for (int num_params : llvm::seq_inclusive(0, params.max_params)) {
if (num_params > NumSingleLineMethodParams) {
@@ -797,10 +800,6 @@ auto SourceGen::GenerateFunctionDecl(
os << indent << "// TODO: make better comment text\n";
if (!IsCpp()) {
os << indent << (is_private ? "private " : "") << "fn " << name;
if (is_method) {
os << "[self: Self]";
}
} else {
os << indent;
if (!is_method) {
@@ -815,10 +814,19 @@ auto SourceGen::GenerateFunctionDecl(
(is_method ? NumSingleLineMethodParams : NumSingleLineFunctionParams)) {
os << "\n" << indent << " ";
}
// For Carbon methods, `self` is the first explicit parameter. Its type is
// omitted, which defaults it to `Self`.
bool is_carbon_method = is_method && !IsCpp();
if (is_carbon_method) {
os << "self";
}
UniqueIdentifierPopper unique_param_names(*this, param_names);
for (int i : llvm::seq(param_count)) {
if (i > 0) {
if ((i % MaxParamsPerLine) == 0) {
// `self` occupies the first slot for Carbon methods, so shift the index
// used for separators and line wrapping.
int slot = i + (is_carbon_method ? 1 : 0);
if (slot > 0) {
if ((slot % MaxParamsPerLine) == 0) {
os << ",\n" << indent << " ";
} else {
os << ", ";
+10 -6
View File
@@ -26,6 +26,7 @@
#include "toolchain/sem_ir/function.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst.h"
#include "toolchain/sem_ir/pattern.h"
#include "toolchain/sem_ir/typed_insts.h"
namespace Carbon::Check {
@@ -57,9 +58,12 @@ static auto ResolveCalleeInCall(Context& context, SemIR::LocId loc_id,
SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_ids)
-> std::optional<SemIR::SpecificId> {
// Check that the arity matches.
auto params = context.inst_blocks().GetOrEmpty(entity.param_patterns_id);
if (arg_ids.size() != params.size()) {
// Check that the arity matches the explicit arguments.
auto param_patterns =
context.inst_blocks().GetOrEmpty(entity.param_patterns_id);
size_t expected_args_size =
param_patterns.size() - (self_id.has_value() ? 1 : 0);
if (arg_ids.size() != expected_args_size) {
CARBON_DIAGNOSTIC(CallArgCountMismatch, Error,
"{0} argument{0:s} passed to "
"{1:=0:function|=1:generic class|=2:generic "
@@ -74,7 +78,7 @@ static auto ResolveCalleeInCall(Context& context, SemIR::LocId loc_id,
Diagnostics::IntAsSelect);
context.emitter()
.Build(loc_id, CallArgCountMismatch, arg_ids.size(),
static_cast<int>(entity_kind_for_diagnostic), params.size())
static_cast<int>(entity_kind_for_diagnostic), expected_args_size)
.Note(entity.latest_decl_id(), InCallToEntity,
static_cast<int>(entity_kind_for_diagnostic))
.Emit();
@@ -258,8 +262,8 @@ auto PerformCallToFunction(Context& context, SemIR::LocId loc_id,
}
// Convert the arguments to match the parameters.
auto converted_args_id =
ConvertCallArgs(context, loc_id, callee_function.self_id, arg_ids,
return_arg_id, callee, *callee_specific_id, is_desugared);
ConvertCallArgs(context, callee_function.self_id, arg_ids, return_arg_id,
callee, *callee_specific_id, is_desugared);
switch (callee.special_function_kind) {
case SemIR::Function::SpecialFunctionKind::Thunk: {
// If we're about to form a direct call to a thunk, inline it.
+6 -19
View File
@@ -36,6 +36,7 @@
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst.h"
#include "toolchain/sem_ir/inst_kind.h"
#include "toolchain/sem_ir/pattern.h"
#include "toolchain/sem_ir/type.h"
#include "toolchain/sem_ir/type_info.h"
#include "toolchain/sem_ir/typed_insts.h"
@@ -2221,32 +2222,18 @@ auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node,
}
// TODO: Consider moving this to pattern_match.h.
auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
SemIR::InstId self_id,
auto ConvertCallArgs(Context& context, SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_refs,
SemIR::InstId return_arg_id, const SemIR::Function& callee,
SemIR::SpecificId callee_specific_id, bool is_desugared)
-> SemIR::InstBlockId {
auto param_patterns =
context.inst_blocks().GetOrEmpty(callee.param_patterns_id);
auto return_pattern_id = callee.return_pattern_id;
// The caller should have ensured this callee has the right arity.
CARBON_CHECK(arg_refs.size() == param_patterns.size());
if (callee.self_param_id.has_value() && !self_id.has_value()) {
CARBON_DIAGNOSTIC(MissingObjectInMethodCall, Error,
"missing object argument in method call");
CARBON_DIAGNOSTIC(InCallToFunction, Note, "calling function declared here");
context.emitter()
.Build(call_loc_id, MissingObjectInMethodCall)
.Note(callee.latest_decl_id(), InCallToFunction)
.Emit();
self_id = SemIR::ErrorInst::InstId;
}
CARBON_CHECK(
(self_id.has_value() ? 1 : 0) + arg_refs.size() ==
context.inst_blocks().GetOrEmpty(callee.param_patterns_id).size());
return CallerPatternMatch(context, callee_specific_id, callee.self_param_id,
callee.param_patterns_id, return_pattern_id,
callee.param_patterns_id, callee.return_pattern_id,
self_id, arg_refs, return_arg_id, is_desugared);
}
+1 -2
View File
@@ -209,8 +209,7 @@ auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node,
// argument values for runtime parameters. `is_desugared` indicates that this
// call was produced by desugaring, not written as a function call in user code,
// so arguments to `ref` parameters aren't required to have `ref` tags.
auto ConvertCallArgs(Context& context, SemIR::LocId call_loc_id,
SemIR::InstId self_id,
auto ConvertCallArgs(Context& context, SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_refs,
SemIR::InstId return_arg_id, const SemIR::Function& callee,
SemIR::SpecificId callee_specific_id, bool is_desugared)
+13 -14
View File
@@ -373,23 +373,22 @@ struct FunctionInfo {
decl_context(decl_context) {
auto function_params =
context.inst_blocks().Get(function.call_param_patterns_id);
const auto& ranges = function.call_param_ranges;
auto explicit_begin = ranges.explicit_begin().index;
// Get the function's `self` parameter, if present.
if (function.call_param_ranges.implicit_size() > 0) {
CARBON_CHECK(function.call_param_ranges.implicit_size() == 1);
auto param_inst_id =
function_params[function.call_param_ranges.implicit_begin().index];
self_param = Param(context, param_inst_id);
// Get the function's `self` parameter, if present. `self` is the first
// explicit call parameter. (The lowered call parameters are leaf patterns
// without binding names, so we rely on `self_param_id` and the positional
// convention rather than inspecting the pattern.)
if (function.self_param_id.has_value()) {
CARBON_CHECK(explicit_begin != ranges.explicit_end().index);
self_param = Param(context, function_params[explicit_begin]);
++explicit_begin;
}
// Get the function's explicit parameters.
function_params =
function_params.drop_front(function.call_param_ranges.implicit_size());
function_params =
function_params.drop_back(function.call_param_ranges.return_size());
for (auto param_inst_id : function_params) {
explicit_params.push_back(Param(context, param_inst_id));
// The remaining explicit parameters are the caller-provided arguments.
for (auto i = explicit_begin; i != ranges.explicit_end().index; ++i) {
explicit_params.push_back(Param(context, function_params[i]));
}
}
+31 -15
View File
@@ -1452,11 +1452,10 @@ static auto MapParameterType(
.kind = GetParamPatternKindForPassingMode(passing_mode)};
}
// Returns a block for the implicit parameters of the given function
// declaration. Because function templates are not yet supported, this currently
// only contains the `self` parameter. On error, produces a diagnostic and
// returns None.
static auto MakeImplicitParamPatternsBlockId(
// Returns a block containing the `self` parameter pattern for the given
// function declaration, or `Empty` if it is not a method.
// Returns `None` on error.
static auto MakeSelfParamPatternBlockId(
Context& context, SemIR::LocId loc_id,
SemIR::ImportIRInstId import_ir_inst_id,
const clang::FunctionDecl& clang_decl,
@@ -1741,30 +1740,46 @@ static auto CreateFunctionSignatureInsts(
SemIR::ImportIRInstId import_ir_inst_id, clang::FunctionDecl* clang_decl,
SemIR::ClangDeclSignatureId signature_id)
-> std::optional<FunctionSignatureInsts> {
context.full_pattern_stack().StartImplicitParamList();
auto implicit_param_patterns_id = MakeImplicitParamPatternsBlockId(
// The `self` parameter of a method (proposal #7016) is the
// first entry in the explicit parameter list. Build it (if any) first, then
// the remaining explicit parameters, and concatenate them into a single
// explicit parameter list.
context.full_pattern_stack().StartExplicitParamList();
auto self_param_patterns_id = MakeSelfParamPatternBlockId(
context, loc_id, import_ir_inst_id, *clang_decl, signature_id);
if (!implicit_param_patterns_id.has_value()) {
if (!self_param_patterns_id.has_value()) {
return std::nullopt;
}
context.full_pattern_stack().EndImplicitParamList();
context.full_pattern_stack().StartExplicitParamList();
auto param_patterns_id = MakeParamPatternsBlockId(
auto explicit_param_patterns_id = MakeParamPatternsBlockId(
context, loc_id, import_ir_inst_id, *clang_decl, signature_id);
if (!param_patterns_id.has_value()) {
if (!explicit_param_patterns_id.has_value()) {
return std::nullopt;
}
context.full_pattern_stack().EndExplicitParamList();
auto self_param_patterns =
context.inst_blocks().GetOrEmpty(self_param_patterns_id);
auto param_patterns_id = explicit_param_patterns_id;
if (!self_param_patterns.empty()) {
llvm::SmallVector<SemIR::InstId> combined(self_param_patterns);
llvm::append_range(
combined, context.inst_blocks().GetOrEmpty(explicit_param_patterns_id));
param_patterns_id = context.inst_blocks().Add(combined);
}
auto [return_type_inst_id, return_form_inst_id, return_pattern_id] =
GetReturnInfo(context, loc_id, clang_decl);
if (return_type_inst_id == SemIR::ErrorInst::TypeInstId) {
return std::nullopt;
}
auto match_results = CalleePatternMatch(context, implicit_param_patterns_id,
// C++ functions have no implicit parameters. Use `None` rather than an empty
// block so that the signature matches a Carbon function with no implicit
// parameter list.
auto match_results = CalleePatternMatch(context, SemIR::InstBlockId::None,
param_patterns_id, return_pattern_id);
return {{.implicit_param_patterns_id = implicit_param_patterns_id,
return {{.implicit_param_patterns_id = SemIR::InstBlockId::None,
.param_patterns_id = param_patterns_id,
.return_type_inst_id = return_type_inst_id,
.return_form_inst_id = return_form_inst_id,
@@ -1892,7 +1907,8 @@ static auto ImportFunction(Context& context, SemIR::LocId loc_id,
.virtual_index = virtual_index,
.evaluation_mode = evaluation_mode,
.self_param_id = FindSelfPattern(
context, function_params_insts->implicit_param_patterns_id),
context, function_params_insts->implicit_param_patterns_id,
function_params_insts->param_patterns_id),
}});
context.imports().push_back(decl_id);
+1 -1
View File
@@ -329,7 +329,7 @@ static auto GetConversionSignatureToImport(
// Otherwise, the initialization is calling a conversion function
// `Source::operator Dest`:
//
// fn Source.<conversion function>[self: Source]() -> Dest;
// fn Source.<conversion function>(self: Source) -> Dest;
auto* conversion_decl = cast<clang::CXXConversionDecl>(function_decl);
self_expr = arg_expr;
arg_exprs = {};
+20 -6
View File
@@ -14,6 +14,7 @@
#include "toolchain/diagnostics/diagnostic.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/impl.h"
#include "toolchain/sem_ir/pattern.h"
#include "toolchain/sem_ir/type.h"
#include "toolchain/sem_ir/typed_insts.h"
@@ -180,6 +181,12 @@ class DeductionContext {
worklist_.AddAll(param, arg, want_value);
}
template <typename ElementId>
auto AddAll(llvm::ArrayRef<ElementId> params, llvm::ArrayRef<ElementId> args,
bool want_value) -> void {
worklist_.AddAll(params, args, want_value);
}
template <typename ParamT, typename ArgT>
auto AddAll(ParamT param, ArgT arg) -> void {
worklist_.AddAll(param, arg);
@@ -581,17 +588,24 @@ auto DeduceGenericCallArguments(
Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_id,
SemIR::SpecificId enclosing_specific_id,
[[maybe_unused]] SemIR::InstBlockId implicit_param_patterns_id,
SemIR::InstBlockId param_patterns_id,
[[maybe_unused]] SemIR::InstId self_id,
SemIR::InstBlockId param_patterns_id, SemIR::InstId self_id,
llvm::ArrayRef<SemIR::InstId> arg_ids) -> SemIR::SpecificId {
DeductionContext deduction(&context, loc_id, generic_id,
enclosing_specific_id,
/*diagnose=*/true);
// Prepare to perform deduction of the explicit parameters against their
// arguments.
// TODO: Also perform deduction for type of self.
deduction.AddAll(param_patterns_id, arg_ids, /*want_value=*/false);
// Prepare to perform deduction of the parameters against the explicit
// arguments. When `self` is provided as the method-call receiver it is
// prepended to the explicit argument list to match the leading `self`
// parameter pattern.
llvm::ArrayRef<SemIR::InstId> self_refs = {};
if (self_id.has_value()) {
self_refs = self_id;
}
deduction.AddAll(context.inst_blocks().GetOrEmpty(param_patterns_id),
llvm::ArrayRef<SemIR::InstId>(llvm::to_vector<8>(
llvm::concat<const SemIR::InstId>(self_refs, arg_ids))),
/*want_value=*/false);
if (!deduction.Deduce() || !deduction.CheckDeductionIsComplete()) {
return SemIR::SpecificId::None;
+32 -26
View File
@@ -24,13 +24,22 @@
namespace Carbon::Check {
auto FindSelfPattern(Context& context,
SemIR::InstBlockId implicit_param_patterns_id)
-> SemIR::InstId {
SemIR::InstBlockId implicit_param_patterns_id,
SemIR::InstBlockId param_patterns_id) -> SemIR::InstId {
auto is_self_pattern = [&](auto param_id) {
return SemIR::IsSelfPattern(context.sem_ir(), param_id);
};
// `self` is the first explicit parameter. We also look in the implicit
// parameter list for error recovery: declaring `self` there is diagnosed (see
// `SelfInImplicitParamList`), but we still treat it as `self` afterwards.
auto param_patterns = context.inst_blocks().GetOrEmpty(param_patterns_id);
if (auto self_id = FindIfOrNone(param_patterns, is_self_pattern);
self_id.has_value()) {
return self_id;
}
auto implicit_param_patterns =
context.inst_blocks().GetOrEmpty(implicit_param_patterns_id);
return FindIfOrNone(implicit_param_patterns, [&](auto implicit_param_id) {
return SemIR::IsSelfPattern(context.sem_ir(), implicit_param_id);
});
return FindIfOrNone(implicit_param_patterns, is_self_pattern);
}
auto AddReturnPattern(Context& context, SemIR::LocId loc_id,
@@ -97,31 +106,28 @@ static auto MakeFunctionSignature(Context& context, SemIR::LocId loc_id,
StartFunctionSignature(context);
// Build and add a `self: Self` or `ref self: Self` parameter if needed.
if (args.self_type_id.has_value()) {
context.full_pattern_stack().StartImplicitParamList();
BeginSubpattern(context);
auto self_type_region_id = ConsumeSubpatternExpr(
context, context.types().GetTypeInstId(args.self_type_id));
EndEmptySubpattern(context);
insts.self_param_id =
AddParamPattern(context, loc_id, SemIR::NameId::SelfValue,
self_type_region_id, args.self_type_id, args.self_kind);
insts.implicit_param_patterns_id =
context.inst_blocks().Add({insts.self_param_id});
context.full_pattern_stack().EndImplicitParamList();
}
// Build and add any explicit parameters. Whether these are references
// or not is controlled by `args.params_are_refs`.
// Build and add the explicit parameters, with a leading `self` parameter if
// one is needed. `self` is the first explicit parameter (proposal #7016),
// matching the convention used by user-written and prelude signatures.
// Keeping the placement consistent matters in particular for the
// `Destroy.Op` / `Copy.Op` functions backing custom witnesses: a mismatch
// would force a signature-adapting thunk for every witness.
context.full_pattern_stack().StartExplicitParamList();
if (args.param_type_ids.empty()) {
if (!args.self_type_id.has_value() && args.param_type_ids.empty()) {
insts.param_patterns_id = SemIR::InstBlockId::Empty;
} else {
context.inst_block_stack().Push();
if (args.self_type_id.has_value()) {
BeginSubpattern(context);
auto self_type_region_id = ConsumeSubpatternExpr(
context, context.types().GetTypeInstId(args.self_type_id));
EndEmptySubpattern(context);
insts.self_param_id = AddParamPattern(
context, loc_id, SemIR::NameId::SelfValue, self_type_region_id,
args.self_type_id, args.self_kind);
context.inst_block_stack().AddInstId(insts.self_param_id);
}
for (auto param_type_id : args.param_type_ids) {
BeginSubpattern(context);
auto param_type_region_id = ConsumeSubpatternExpr(
+8 -6
View File
@@ -15,11 +15,14 @@
namespace Carbon::Check {
// Returns the ID of the self parameter pattern, or None.
// TODO: Do this during initial traversal of implicit params.
// Returns the ID of the self parameter pattern, or None. `self` is declared as
// the first explicit parameter. The implicit parameter list is also searched
// for error recovery: declaring `self` there is diagnosed, but we still
// recognize it as `self` afterwards.
// TODO: Do this during initial traversal of the parameters.
auto FindSelfPattern(Context& context,
SemIR::InstBlockId implicit_param_patterns_id)
-> SemIR::InstId;
SemIR::InstBlockId implicit_param_patterns_id,
SemIR::InstBlockId param_patterns_id) -> SemIR::InstId;
// Creates suitable return patterns for the given return form, and adds them to
// the current pattern block.
@@ -35,8 +38,7 @@ auto IsValidBuiltinDeclaration(Context& context,
struct FunctionDeclArgs {
SemIR::NameScopeId parent_scope_id;
SemIR::NameId name_id;
// The type of the implicit `[self: Self]` parameter, or `None` if there is
// none.
// The type of the leading `self` parameter, or `None` if there is none.
SemIR::TypeId self_type_id = SemIR::TypeId::None;
// The kind of the `self` parameter.
ParamPatternKind self_kind = ParamPatternKind::Ref;
+67 -18
View File
@@ -13,6 +13,7 @@
#include "toolchain/check/inst.h"
#include "toolchain/check/interface.h"
#include "toolchain/check/name_lookup.h"
#include "toolchain/check/name_ref.h"
#include "toolchain/check/pattern.h"
#include "toolchain/check/period_self.h"
#include "toolchain/check/return.h"
@@ -57,12 +58,14 @@ static auto IsValidParamForIntroducer(Context& context, Parse::NodeId node_id,
bool is_generic) -> bool {
switch (introducer_kind) {
case Lex::TokenKind::Fn: {
// `self` in the implicit parameter list is diagnosed separately (see
// `SelfInImplicitParamList`), so skip it here to avoid a redundant
// diagnostic.
if (context.full_pattern_stack().CurrentKind() ==
FullPatternStack::Kind::ImplicitParamList &&
!(is_generic || name_id == SemIR::NameId::SelfValue)) {
CARBON_DIAGNOSTIC(
ImplictParamMustBeConstant, Error,
"implicit parameters of functions must be constant or `self`");
CARBON_DIAGNOSTIC(ImplictParamMustBeConstant, Error,
"implicit parameters of functions must be constant");
context.emitter().Emit(node_id, ImplictParamMustBeConstant);
return false;
}
@@ -112,8 +115,10 @@ namespace {
// expression may be interpreted as a type or a form, depending on the binding
// kind.
struct BindingPatternTypeInfo {
// The parse node representing the expression.
Parse::AnyExprId node_id;
// The parse node representing the expression. For a `self` binding with an
// omitted type this is the binding pattern node itself, since there is no
// separate type expression.
Parse::NodeId node_id;
// The inst representing the converted value of that expression. For a `:?`
// binding the expression is converted to type `Core.Form`; otherwise it is
// converted to type `type`.
@@ -124,10 +129,21 @@ struct BindingPatternTypeInfo {
};
} // namespace
// Handle the type position of a binding pattern.
// Handle the type position of a binding pattern. For a `self` binding with an
// omitted type, `self_type_inst_id` is the synthesized `Self` type expression
// and there is no type expression on the node stack to pop.
static auto HandleAnyBindingPatternType(Context& context,
Parse::NodeKind node_kind)
Parse::NodeId binding_node_id,
Parse::NodeKind node_kind,
SemIR::InstId self_type_inst_id)
-> BindingPatternTypeInfo {
if (self_type_inst_id.has_value()) {
auto as_type = ExprAsType(context, binding_node_id, self_type_inst_id);
return {.node_id = binding_node_id,
.inst_id = as_type.inst_id,
.type_component_id = as_type.type_id};
}
auto [node_id, original_inst_id] = context.node_stack().PopExprWithNodeId();
if (node_kind == Parse::FormBindingPattern::Kind) {
@@ -144,10 +160,12 @@ static auto HandleAnyBindingPatternType(Context& context,
}
// TODO: make this function shorter by factoring pieces out.
static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
Parse::NodeKind node_kind,
bool is_unused = false) -> bool {
auto type_expr = HandleAnyBindingPatternType(context, node_kind);
static auto HandleAnyBindingPattern(
Context& context, Parse::NodeId node_id, Parse::NodeKind node_kind,
bool is_unused = false,
SemIR::InstId self_type_inst_id = SemIR::InstId::None) -> bool {
auto type_expr = HandleAnyBindingPatternType(context, node_id, node_kind,
self_type_inst_id);
if (context.types()
.GetAsInst(type_expr.type_component_id)
.Is<SemIR::TypeComponentOf>()) {
@@ -228,13 +246,29 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
type_expr.type_component_id);
};
// A `self` binding can only appear in an implicit parameter list.
if (name_id == SemIR::NameId::SelfValue &&
!context.node_stack().PeekIs(Parse::NodeKind::ImplicitParamListStart)) {
CARBON_DIAGNOSTIC(
SelfOutsideImplicitParamList, Error,
"`self` can only be declared in an implicit parameter list");
context.emitter().Emit(node_id, SelfOutsideImplicitParamList);
// A `self` binding must be the first parameter in the explicit parameter
// list (see proposal #7016). Here we can reject `self` in the implicit
// parameter list or outside any parameter list; that it must be *first* in
// the explicit list is checked once the full list is known (see
// `BuildFunctionDecl`).
if (name_id == SemIR::NameId::SelfValue) {
switch (context.full_pattern_stack().CurrentKind()) {
case FullPatternStack::Kind::ExplicitParamList:
break;
case FullPatternStack::Kind::ImplicitParamList: {
CARBON_DIAGNOSTIC(
SelfInImplicitParamList, Error,
"`self` must be declared in the explicit parameter list");
context.emitter().Emit(node_id, SelfInImplicitParamList);
break;
}
default: {
CARBON_DIAGNOSTIC(SelfOutsideParamList, Error,
"`self` can only be declared in a parameter list");
context.emitter().Emit(node_id, SelfOutsideParamList);
break;
}
}
}
if (node_kind == Parse::NodeKind::CompileTimeBindingPattern &&
@@ -399,6 +433,21 @@ auto HandleParseNode(Context& context, Parse::LetBindingPatternId node_id)
Parse::NodeKind::LetBindingPattern);
}
auto HandleParseNode(Context& context, Parse::SelfBindingPatternId node_id)
-> bool {
// A `self` binding with an omitted type behaves like `self: Self`. There is
// no type expression in the parse tree, so synthesize a reference to `Self`
// into the current subpattern region and feed it in as the binding's type.
auto self_type =
LookupUnqualifiedName(context, node_id, SemIR::NameId::SelfType);
auto self_type_inst_id = BuildNameRef(
context, node_id, SemIR::NameId::SelfType,
self_type.scope_result.target_inst_id(), self_type.specific_id);
return HandleAnyBindingPattern(context, node_id,
Parse::NodeKind::LetBindingPattern,
/*is_unused=*/false, self_type_inst_id);
}
auto HandleParseNode(Context& context, Parse::VarBindingPatternId node_id)
-> bool {
return HandleAnyBindingPattern(context, node_id,
+18 -4
View File
@@ -30,6 +30,7 @@
#include "toolchain/sem_ir/function.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst.h"
#include "toolchain/sem_ir/pattern.h"
#include "toolchain/sem_ir/typed_insts.h"
namespace Carbon::Check {
@@ -517,8 +518,21 @@ static auto BuildFunctionDecl(Context& context,
context.node_stack()
.PopAndDiscardSoloNodeId<Parse::NodeKind::FunctionIntroducer>();
auto self_param_id =
FindSelfPattern(context, name.implicit_param_patterns_id);
auto self_param_id = FindSelfPattern(context, name.implicit_param_patterns_id,
name.param_patterns_id);
// `self` must be the first explicit parameter. (Declaring it in the implicit
// parameter list or outside any parameter list is diagnosed earlier.)
if (self_param_id.has_value()) {
auto explicit_params =
context.inst_blocks().GetOrEmpty(name.param_patterns_id);
if (!explicit_params.empty() && explicit_params.front() != self_param_id &&
llvm::is_contained(explicit_params, self_param_id)) {
CARBON_DIAGNOSTIC(SelfNotFirstParam, Error,
"`self` must be the first explicit parameter");
context.emitter().Emit(SemIR::LocId(self_param_id), SelfNotFirstParam);
}
}
// Process modifiers.
auto [parent_scope_inst_id, parent_scope_inst] =
@@ -660,8 +674,8 @@ static auto DiagnoseUnusedMarkersWithoutDefinition(
const auto& function = context.functions().Get(function_id);
// The `unused` modifier requires a definition, so it is not valid on any
// parameter when there is none. This applies to implicit parameters (such as
// `self`) too, so check the implicit parameter list as well as the explicit
// one.
// `T:! type` introduced by `[...]`) too, so check the implicit parameter list
// as well as the explicit one.
for (auto param_patterns_id :
{function.implicit_param_patterns_id, function.param_patterns_id}) {
if (param_patterns_id.has_value()) {
+1 -1
View File
@@ -48,7 +48,7 @@ static auto GetClassElementIndex(Context& context, SemIR::InstId element_id)
}
// Returns whether `function_id` is an instance method: in other words, whether
// it has an implicit `self` parameter.
// it has a `self` parameter (the first explicit parameter).
static auto IsInstanceMethod(const SemIR::File& sem_ir,
SemIR::FunctionId function_id) -> bool {
const auto& function = sem_ir.functions().Get(function_id);
+11 -1
View File
@@ -343,7 +343,10 @@ static auto CheckRedeclParams(Context& context, SemIR::LocId new_decl_loc_id,
return true;
}
// If exactly one of the parameter lists was present, they differ.
// If exactly one of the parameter lists was present, they differ. An absent
// parameter list (`None`) and a present-but-empty one (`Empty`) are
// intentionally treated as different, following the syntactic redeclaration
// matching design.
if (new_param_patterns_id.has_value() != prev_param_patterns_id.has_value()) {
if (!diagnose) {
return false;
@@ -470,6 +473,13 @@ static auto CheckRedeclParamSyntax(Context& context,
prev_node_kind = context.parse_tree().node_kind(prev_node_id);
}
if (!IsNodeSyntaxEqual(context, new_node_id, prev_node_id)) {
// The `self` parameter's type must be spelled the same way (`self` vs.
// `self: Self`) in a redeclaration as in the previous declaration. This
// is not a special case: like any other parameter-type spelling
// difference (e.g. `self: Self` vs. `self: C`), it falls through to the
// generic "syntax differs" diagnostic below, following the token-based
// redeclaration matching rule from proposal #3763.
//
// Skip difference if it is `Self as` vs. `as` in an `impl` declaration.
// https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p003763.md#redeclarations
if (new_node_kind == Parse::NodeKind::ImplDefaultSelfAs &&
+16 -20
View File
@@ -21,6 +21,7 @@
#include "toolchain/check/type.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/sem_ir/expr_info.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst_kind.h"
#include "toolchain/sem_ir/pattern.h"
@@ -978,7 +979,7 @@ auto CalleePatternMatch(Context& context,
.param_ranges = {implicit_end, explicit_end, return_end}};
}
auto ThunkPatternMatch(Context& context, SemIR::InstId self_pattern_id,
auto ThunkPatternMatch(Context& context,
llvm::ArrayRef<SemIR::InstId> param_pattern_ids,
llvm::ArrayRef<SemIR::InstId> outer_call_args)
-> ThunkPatternMatchResults {
@@ -986,15 +987,7 @@ auto ThunkPatternMatch(Context& context, SemIR::InstId self_pattern_id,
MatchContext match(context);
llvm::SmallVector<SemIR::InstId> inner_args;
inner_args.reserve(outer_call_args.size() + 1);
if (self_pattern_id.has_value()) {
inner_args.push_back(match.MatchWithResult(
&state,
{.pattern_id = self_pattern_id,
.work = MatchContext::PreWork{.scrutinee_id = SemIR::InstId::None},
.allow_unmarked_ref = true}));
}
inner_args.reserve(outer_call_args.size());
for (SemIR::InstId inst_id : param_pattern_ids) {
inner_args.push_back(match.MatchWithResult(
@@ -1035,18 +1028,21 @@ auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id,
CallerState state = {.callee_specific_id = specific_id};
MatchContext match(context);
if (self_pattern_id.has_value()) {
match.Match(&state,
{.pattern_id = self_pattern_id,
.work = MatchContext::PreWork{.scrutinee_id = self_arg_id},
.allow_unmarked_ref = true});
// When we have a separate `self_arg_id`, we concatenate that onto the front
// of the arg_refs to match against the first parameter.
llvm::ArrayRef<SemIR::InstId> self_arg_refs = {};
if (self_arg_id.has_value()) {
self_arg_refs = self_arg_id;
CARBON_CHECK(self_pattern_id.has_value());
}
for (auto [arg_id, param_pattern_id] : llvm::zip_equal(
arg_refs, context.inst_blocks().GetOrEmpty(param_patterns_id))) {
match.Match(&state, {.pattern_id = param_pattern_id,
.work = MatchContext::PreWork{.scrutinee_id = arg_id},
.allow_unmarked_ref = is_desugared});
for (const auto& [arg_id, param_pattern_id] : llvm::zip_equal(
llvm::concat<const SemIR::InstId>(self_arg_refs, arg_refs),
context.inst_blocks().GetOrEmpty(param_patterns_id))) {
match.Match(&state,
{.pattern_id = param_pattern_id,
.work = MatchContext::PreWork{.scrutinee_id = arg_id},
.allow_unmarked_ref = arg_id == self_arg_id || is_desugared});
}
// Track the return storage, if present.
+2 -2
View File
@@ -44,7 +44,7 @@ auto CalleePatternMatch(Context& context,
// Return type for ThunkPatternMatch.
struct ThunkPatternMatchResults {
// The syntactic argument list. If `self_pattern_id` is not `None`, the first
// The syntactic argument list. If there is a self parameter, the first
// element will be the corresponding argument.
llvm::SmallVector<SemIR::InstId> syntactic_args;
@@ -57,7 +57,7 @@ struct ThunkPatternMatchResults {
// Given the `Call` arguments for the outer part of a thunked function call,
// computes the corresponding syntactic argument list, suitable for passing to
// the inner part of the thunked function call.
auto ThunkPatternMatch(Context& context, SemIR::InstId self_pattern_id,
auto ThunkPatternMatch(Context& context,
llvm::ArrayRef<SemIR::InstId> param_pattern_ids,
llvm::ArrayRef<SemIR::InstId> outer_call_args)
-> ThunkPatternMatchResults;
+11 -8
View File
@@ -56,6 +56,7 @@ fn G(template N:! i32) {
fn H() { G(3); }
// CHECK:STDOUT: --- generic_empty.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -96,11 +97,11 @@ fn H() { G(3); }
// CHECK:STDOUT: %pattern_type: type = pattern_type %array_type.loc7_29.2 [symbolic = %pattern_type (constants.%pattern_type.bd6)]
// CHECK:STDOUT: %array: @G.%array_type.loc7_29.2 (%array_type.1b3) = tuple_value () [symbolic = %array (constants.%array.ca4)]
// CHECK:STDOUT: %Destroy.lookup_impl_witness: <witness> = lookup_impl_witness %array_type.loc7_29.2, @Destroy [symbolic = %Destroy.lookup_impl_witness (constants.%Destroy.lookup_impl_witness)]
// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %array_type.loc7_29.2, (%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet (constants.%Destroy.facet.a52)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.a67)]
// CHECK:STDOUT: %.loc7_3.2: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet [symbolic = %.loc7_3.2 (constants.%.1e5)]
// CHECK:STDOUT: %impl.elem0.loc7_3.2: @G.%.loc7_3.2 (%.1e5) = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2: <specific function> = specific_impl_function %impl.elem0.loc7_3.2, @Destroy.WithSelf.Op(%Destroy.facet) [symbolic = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Destroy.facet.loc7_3.2: %Destroy.type = facet_value %array_type.loc7_29.2, (%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.a52)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc7_3.2) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.a67)]
// CHECK:STDOUT: %.loc7_3.3: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc7_3.2 [symbolic = %.loc7_3.3 (constants.%.1e5)]
// CHECK:STDOUT: %impl.elem0.loc7_3.2: @G.%.loc7_3.3 (%.1e5) = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2: <specific function> = specific_impl_function %impl.elem0.loc7_3.2, @Destroy.WithSelf.Op(%Destroy.facet.loc7_3.2) [symbolic = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
@@ -119,8 +120,10 @@ fn H() { G(3); }
// CHECK:STDOUT: %array_type.loc7_29.1: type = array_type %int_0, %T.ref [symbolic = %array_type.loc7_29.2 (constants.%array_type.1b3)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr: ref @G.%array_type.loc7_29.2 (%array_type.1b3) = ref_binding arr, %arr.var
// CHECK:STDOUT: %impl.elem0.loc7_3.1: @G.%.loc7_3.2 (%.1e5) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %impl.elem0.loc7_3.1: @G.%.loc7_3.3 (%.1e5) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %arr.var, %impl.elem0.loc7_3.1
// CHECK:STDOUT: %Destroy.facet.loc7_3.1: %Destroy.type = facet_value constants.%array_type.1b3, (constants.%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.a52)]
// CHECK:STDOUT: %.loc7_3.2: %Destroy.type = converted constants.%array_type.1b3, %Destroy.facet.loc7_3.1 [symbolic = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.a52)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.1: <specific function> = specific_impl_function %impl.elem0.loc7_3.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.a52) [symbolic = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %arr.var, %specific_impl_fn.loc7_3.1
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call %bound_method.loc7_3.2(%arr.var)
@@ -143,9 +146,9 @@ fn H() { G(3); }
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.6be
// CHECK:STDOUT: %array => constants.%array.497
// CHECK:STDOUT: %Destroy.lookup_impl_witness => constants.%custom_witness.df9
// CHECK:STDOUT: %Destroy.facet => constants.%Destroy.facet.396
// CHECK:STDOUT: %Destroy.facet.loc7_3.2 => constants.%Destroy.facet.396
// CHECK:STDOUT: %Destroy.WithSelf.Op.type => constants.%Destroy.WithSelf.Op.type.ccc
// CHECK:STDOUT: %.loc7_3.2 => constants.%.a02
// CHECK:STDOUT: %.loc7_3.3 => constants.%.a02
// CHECK:STDOUT: %impl.elem0.loc7_3.2 => constants.%Destroy.Op
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2 => constants.%Destroy.Op
// CHECK:STDOUT: }
+2 -2
View File
@@ -91,11 +91,11 @@ class Y {
}
impl Y as Core.As(X) {
fn Convert[self: Y]() -> X { return {.x = self.y}; }
fn Convert(self: Y) -> X { return {.x = self.y}; }
}
impl X as Core.As(Y) {
fn Convert[self: X]() -> Y { return {.y = self.x}; }
fn Convert(self: X) -> Y { return {.y = self.x}; }
}
//@dump-sem-ir-begin
+1 -1
View File
@@ -16,7 +16,7 @@ library "[[@TEST_NAME]]";
class X {
impl () as Core.ImplicitAs(X) {
fn Convert[unused self: ()]() -> X { return {}; }
fn Convert(unused self: ()) -> X { return {}; }
}
}
+21 -20
View File
@@ -31,13 +31,13 @@ library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
interface I {
fn Op[self: Self]();
fn Op(self);
}
//@dump-sem-ir-end
class C {
impl C as I {
fn Op[unused self: Self]() {}
fn Op(unused self) {}
}
}
@@ -61,13 +61,13 @@ library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
interface I {
fn Op[self: Self]();
fn Op(self);
}
//@dump-sem-ir-end
class C {
impl C as I {
fn Op[unused self: Self]() {}
fn Op(unused self) {}
}
}
@@ -79,6 +79,7 @@ import library "excluded_with_range";
fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT: --- exclude/included.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -147,13 +148,13 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT: %self.param_patt: @I.WithSelf.Op.%pattern_type (%pattern_type.c60) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @I.WithSelf.Op.%pattern_type (%pattern_type.c60) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %self.param: @I.WithSelf.Op.%Self.as_type.loc8_15.1 (%Self.as_type) = value_param call_param0
// CHECK:STDOUT: %.loc8_15.1: type = splice_block %.loc8_15.2 [symbolic = %Self.as_type.loc8_15.1 (constants.%Self.as_type)] {
// CHECK:STDOUT: %self.param: @I.WithSelf.Op.%Self.as_type.loc8_9.1 (%Self.as_type) = value_param call_param0
// CHECK:STDOUT: %.loc8_9.1: type = splice_block %.loc8_9.2 [symbolic = %Self.as_type.loc8_9.1 (constants.%Self.as_type)] {
// CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self)]
// CHECK:STDOUT: %Self.as_type.loc8_15.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc8_15.1 (constants.%Self.as_type)]
// CHECK:STDOUT: %.loc8_15.2: type = converted %Self.ref, %Self.as_type.loc8_15.2 [symbolic = %Self.as_type.loc8_15.1 (constants.%Self.as_type)]
// CHECK:STDOUT: %Self.as_type.loc8_9.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc8_9.1 (constants.%Self.as_type)]
// CHECK:STDOUT: %.loc8_9.2: type = converted %Self.ref, %Self.as_type.loc8_9.2 [symbolic = %Self.as_type.loc8_9.1 (constants.%Self.as_type)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: @I.WithSelf.Op.%Self.as_type.loc8_15.1 (%Self.as_type) = value_binding self, %self.param
// CHECK:STDOUT: %self: @I.WithSelf.Op.%Self.as_type.loc8_9.1 (%Self.as_type) = value_binding self, %self.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.WithSelf.Op.decl [concrete = constants.%assoc0]
// CHECK:STDOUT:
@@ -167,10 +168,10 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @I.WithSelf.Op(@I.%Self: %I.type) {
// CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
// CHECK:STDOUT: %Self.as_type.loc8_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc8_15.1 (constants.%Self.as_type)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc8_15.1 [symbolic = %pattern_type (constants.%pattern_type.c60)]
// CHECK:STDOUT: %Self.as_type.loc8_9.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc8_9.1 (constants.%Self.as_type)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc8_9.1 [symbolic = %pattern_type (constants.%pattern_type.c60)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @I.WithSelf.Op.%Self.as_type.loc8_15.1 (%Self.as_type));
// CHECK:STDOUT: fn(%self.param: @I.WithSelf.Op.%Self.as_type.loc8_9.1 (%Self.as_type));
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @I.WithSelf(constants.%Self) {
@@ -182,7 +183,7 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @I.WithSelf.Op(constants.%Self) {
// CHECK:STDOUT: %Self => constants.%Self
// CHECK:STDOUT: %Self.as_type.loc8_15.1 => constants.%Self.as_type
// CHECK:STDOUT: %Self.as_type.loc8_9.1 => constants.%Self.as_type
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.c60
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -195,7 +196,7 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @I.WithSelf.Op(constants.%I.facet) {
// CHECK:STDOUT: %Self => constants.%I.facet
// CHECK:STDOUT: %Self.as_type.loc8_15.1 => constants.%C
// CHECK:STDOUT: %Self.as_type.loc8_9.1 => constants.%C
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.98b
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -235,15 +236,15 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//included_with_range, loc16_1, loaded [concrete = constants.%complete_type]
// CHECK:STDOUT: %Main.import_ref.e47 = import_ref Main//included_with_range, inst{{[0-9A-F]+}} [no loc], unloaded
// CHECK:STDOUT: %Main.import_ref.ddc: %I.assoc_type = import_ref Main//included_with_range, loc8_22, loaded [concrete = constants.%assoc0]
// CHECK:STDOUT: %Main.import_ref.ddc: %I.assoc_type = import_ref Main//included_with_range, loc8_14, loaded [concrete = constants.%assoc0]
// CHECK:STDOUT: %Main.Op = import_ref Main//included_with_range, Op, unloaded
// CHECK:STDOUT: %Main.import_ref.e59c42.2: %I.type = import_ref Main//included_with_range, loc7_13, loaded [symbolic = constants.%Self]
// CHECK:STDOUT: %Main.import_ref.223 = import_ref Main//included_with_range, loc7_13, unloaded
// CHECK:STDOUT: %Main.import_ref.421: @I.WithSelf.%I.WithSelf.Op.type (%I.WithSelf.Op.type.351) = import_ref Main//included_with_range, loc8_22, loaded [symbolic = @I.WithSelf.%I.WithSelf.Op (constants.%I.WithSelf.Op.fcf)]
// CHECK:STDOUT: %Main.import_ref.421: @I.WithSelf.%I.WithSelf.Op.type (%I.WithSelf.Op.type.351) = import_ref Main//included_with_range, loc8_14, loaded [symbolic = @I.WithSelf.%I.WithSelf.Op (constants.%I.WithSelf.Op.fcf)]
// CHECK:STDOUT: %Main.import_ref.b48: <witness> = import_ref Main//included_with_range, loc13_15, loaded [concrete = constants.%I.impl_witness]
// CHECK:STDOUT: %Main.import_ref.335: type = import_ref Main//included_with_range, loc13_8, loaded [concrete = constants.%C]
// CHECK:STDOUT: %Main.import_ref.c3f: type = import_ref Main//included_with_range, loc13_13, loaded [concrete = constants.%I.type]
// CHECK:STDOUT: %Main.import_ref.341: %C.as.I.impl.Op.type = import_ref Main//included_with_range, loc14_32, loaded [concrete = constants.%C.as.I.impl.Op]
// CHECK:STDOUT: %Main.import_ref.341: %C.as.I.impl.Op.type = import_ref Main//included_with_range, loc14_24, loaded [concrete = constants.%C.as.I.impl.Op]
// CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.341), @C.as.I.impl [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -357,9 +358,9 @@ fn F(c: C) { c.(I.Op)(); }
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.import_ref.ddc: %I.assoc_type = import_ref Main//excluded_with_range, loc6_22, loaded [concrete = constants.%assoc0]
// CHECK:STDOUT: %Main.import_ref.421: @I.WithSelf.%I.WithSelf.Op.type (%I.WithSelf.Op.type.351) = import_ref Main//excluded_with_range, loc6_22, loaded [symbolic = @I.WithSelf.%I.WithSelf.Op (constants.%I.WithSelf.Op.fcf)]
// CHECK:STDOUT: %Main.import_ref.341: %C.as.I.impl.Op.type = import_ref Main//excluded_with_range, loc12_32, loaded [concrete = constants.%C.as.I.impl.Op]
// CHECK:STDOUT: %Main.import_ref.ddc: %I.assoc_type = import_ref Main//excluded_with_range, loc6_14, loaded [concrete = constants.%assoc0]
// CHECK:STDOUT: %Main.import_ref.421: @I.WithSelf.%I.WithSelf.Op.type (%I.WithSelf.Op.type.351) = import_ref Main//excluded_with_range, loc6_14, loaded [symbolic = @I.WithSelf.%I.WithSelf.Op (constants.%I.WithSelf.Op.fcf)]
// CHECK:STDOUT: %Main.import_ref.341: %C.as.I.impl.Op.type = import_ref Main//excluded_with_range, loc12_24, loaded [concrete = constants.%C.as.I.impl.Op]
// CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.341), @C.as.I.impl [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
+2 -2
View File
@@ -17,12 +17,12 @@
// This regression test ensures that reuse of `<error>` in different scopes
// works.
// CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
// CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant [ImplictParamMustBeConstant]
// CHECK:STDERR: fn Foo[a: ()]();
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
fn Foo[a: ()]();
// CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
// CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant [ImplictParamMustBeConstant]
// CHECK:STDERR: fn Boo[a: ()]() {}
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
+204 -194
View File
@@ -17,6 +17,7 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
return (p, ());
}
// CHECK:STDOUT: ---
// CHECK:STDOUT: filename: one_file.carbon
// CHECK:STDOUT: sem_ir:
@@ -84,7 +85,7 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: import_ir_inst2B: {ir_id: import_ir78000004, inst_id: inst700000BB}
// CHECK:STDOUT: import_ir_inst2C: {ir_id: import_ir78000004, inst_id: inst700000BC}
// CHECK:STDOUT: import_ir_inst2D: {ir_id: import_ir78000004, inst_id: inst700000BD}
// CHECK:STDOUT: import_ir_inst2E: {ir_id: import_ir78000004, inst_id: inst700000C3}
// CHECK:STDOUT: import_ir_inst2E: {ir_id: import_ir78000004, inst_id: inst700000C4}
// CHECK:STDOUT: import_ir_inst2F: {ir_id: import_ir78000004, inst_id: inst70000079}
// CHECK:STDOUT: import_ir_inst30: {ir_id: import_ir78000004, inst_id: inst7000007F}
// CHECK:STDOUT: import_ir_inst31: {ir_id: import_ir78000004, inst_id: inst70000082}
@@ -95,165 +96,165 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: import_ir_inst36: {ir_id: import_ir78000004, inst_id: inst70000088}
// CHECK:STDOUT: import_ir_inst37: {ir_id: import_ir78000004, inst_id: inst700000A0}
// CHECK:STDOUT: import_ir_inst38: {ir_id: import_ir78000004, inst_id: inst700000A1}
// CHECK:STDOUT: import_ir_inst39: {ir_id: import_ir78000004, inst_id: inst700000D3}
// CHECK:STDOUT: import_ir_inst3A: {ir_id: import_ir78000004, inst_id: inst700000D1}
// CHECK:STDOUT: import_ir_inst3B: {ir_id: import_ir78000004, inst_id: inst700000CF}
// CHECK:STDOUT: import_ir_inst3C: {ir_id: import_ir78000004, inst_id: inst700000D0}
// CHECK:STDOUT: import_ir_inst3D: {ir_id: import_ir78000004, inst_id: inst700000EC}
// CHECK:STDOUT: import_ir_inst3E: {ir_id: import_ir78000004, inst_id: inst700000EA}
// CHECK:STDOUT: import_ir_inst3F: {ir_id: import_ir78000004, inst_id: inst700000E8}
// CHECK:STDOUT: import_ir_inst40: {ir_id: import_ir78000004, inst_id: inst700000E9}
// CHECK:STDOUT: import_ir_inst41: {ir_id: import_ir78000004, inst_id: inst70000105}
// CHECK:STDOUT: import_ir_inst42: {ir_id: import_ir78000004, inst_id: inst70000103}
// CHECK:STDOUT: import_ir_inst43: {ir_id: import_ir78000004, inst_id: inst70000101}
// CHECK:STDOUT: import_ir_inst44: {ir_id: import_ir78000004, inst_id: inst70000102}
// CHECK:STDOUT: import_ir_inst45: {ir_id: import_ir78000004, inst_id: inst7000011E}
// CHECK:STDOUT: import_ir_inst46: {ir_id: import_ir78000004, inst_id: inst7000011C}
// CHECK:STDOUT: import_ir_inst47: {ir_id: import_ir78000004, inst_id: inst7000011A}
// CHECK:STDOUT: import_ir_inst48: {ir_id: import_ir78000004, inst_id: inst7000011B}
// CHECK:STDOUT: import_ir_inst49: {ir_id: import_ir78000004, inst_id: inst70000141}
// CHECK:STDOUT: import_ir_inst4A: {ir_id: import_ir78000004, inst_id: inst7000013F}
// CHECK:STDOUT: import_ir_inst4B: {ir_id: import_ir78000004, inst_id: inst70000155}
// CHECK:STDOUT: import_ir_inst4C: {ir_id: import_ir78000004, inst_id: inst70000140}
// CHECK:STDOUT: import_ir_inst4D: {ir_id: import_ir78000004, inst_id: inst70000138}
// CHECK:STDOUT: import_ir_inst4E: {ir_id: import_ir78000004, inst_id: inst7000013A}
// CHECK:STDOUT: import_ir_inst4F: {ir_id: import_ir78000004, inst_id: inst7000013D}
// CHECK:STDOUT: import_ir_inst50: {ir_id: import_ir78000004, inst_id: inst70000135}
// CHECK:STDOUT: import_ir_inst51: {ir_id: import_ir78000004, inst_id: inst70000137}
// CHECK:STDOUT: import_ir_inst52: {ir_id: import_ir78000004, inst_id: inst7000013C}
// CHECK:STDOUT: import_ir_inst53: {ir_id: import_ir78000004, inst_id: inst70000143}
// CHECK:STDOUT: import_ir_inst54: {ir_id: import_ir78000004, inst_id: inst70000155}
// CHECK:STDOUT: import_ir_inst55: {ir_id: import_ir78000004, inst_id: inst70000150}
// CHECK:STDOUT: import_ir_inst56: {ir_id: import_ir78000004, inst_id: inst70000151}
// CHECK:STDOUT: import_ir_inst57: {ir_id: import_ir78000004, inst_id: inst70000148}
// CHECK:STDOUT: import_ir_inst58: {ir_id: import_ir78000004, inst_id: inst7000014B}
// CHECK:STDOUT: import_ir_inst59: {ir_id: import_ir78000004, inst_id: inst7000014C}
// CHECK:STDOUT: import_ir_inst5A: {ir_id: import_ir78000004, inst_id: inst7000014D}
// CHECK:STDOUT: import_ir_inst5B: {ir_id: import_ir78000004, inst_id: inst70000135}
// CHECK:STDOUT: import_ir_inst5C: {ir_id: import_ir78000004, inst_id: inst70000145}
// CHECK:STDOUT: import_ir_inst5D: {ir_id: import_ir78000004, inst_id: inst70000146}
// CHECK:STDOUT: import_ir_inst5E: {ir_id: import_ir78000004, inst_id: inst70000149}
// CHECK:STDOUT: import_ir_inst5F: {ir_id: import_ir78000004, inst_id: inst7000014F}
// CHECK:STDOUT: import_ir_inst60: {ir_id: import_ir78000004, inst_id: inst70000158}
// CHECK:STDOUT: import_ir_inst61: {ir_id: import_ir78000004, inst_id: inst70000159}
// CHECK:STDOUT: import_ir_inst62: {ir_id: import_ir78000004, inst_id: inst7000015C}
// CHECK:STDOUT: import_ir_inst63: {ir_id: import_ir78000004, inst_id: inst70000164}
// CHECK:STDOUT: import_ir_inst64: {ir_id: import_ir78000004, inst_id: inst70000162}
// CHECK:STDOUT: import_ir_inst65: {ir_id: import_ir78000004, inst_id: inst70000160}
// CHECK:STDOUT: import_ir_inst66: {ir_id: import_ir78000004, inst_id: inst70000161}
// CHECK:STDOUT: import_ir_inst67: {ir_id: import_ir78000004, inst_id: inst7000017D}
// CHECK:STDOUT: import_ir_inst68: {ir_id: import_ir78000004, inst_id: inst7000017B}
// CHECK:STDOUT: import_ir_inst69: {ir_id: import_ir78000004, inst_id: inst70000179}
// CHECK:STDOUT: import_ir_inst6A: {ir_id: import_ir78000004, inst_id: inst7000017A}
// CHECK:STDOUT: import_ir_inst6B: {ir_id: import_ir78000004, inst_id: inst700001B3}
// CHECK:STDOUT: import_ir_inst6C: {ir_id: import_ir78000004, inst_id: inst700001B1}
// CHECK:STDOUT: import_ir_inst6D: {ir_id: import_ir78000004, inst_id: inst700001CE}
// CHECK:STDOUT: import_ir_inst6E: {ir_id: import_ir78000004, inst_id: inst700001B2}
// CHECK:STDOUT: import_ir_inst6F: {ir_id: import_ir78000004, inst_id: inst700001CE}
// CHECK:STDOUT: import_ir_inst70: {ir_id: import_ir78000004, inst_id: inst700001C9}
// CHECK:STDOUT: import_ir_inst71: {ir_id: import_ir78000004, inst_id: inst700001CA}
// CHECK:STDOUT: import_ir_inst72: {ir_id: import_ir78000004, inst_id: inst700001C1}
// CHECK:STDOUT: import_ir_inst73: {ir_id: import_ir78000004, inst_id: inst700001C4}
// CHECK:STDOUT: import_ir_inst74: {ir_id: import_ir78000004, inst_id: inst700001C5}
// CHECK:STDOUT: import_ir_inst75: {ir_id: import_ir78000004, inst_id: inst700001C6}
// CHECK:STDOUT: import_ir_inst76: {ir_id: import_ir78000004, inst_id: inst70000194}
// CHECK:STDOUT: import_ir_inst77: {ir_id: import_ir78000004, inst_id: inst70000199}
// CHECK:STDOUT: import_ir_inst78: {ir_id: import_ir78000004, inst_id: inst700001BB}
// CHECK:STDOUT: import_ir_inst79: {ir_id: import_ir78000004, inst_id: inst700001BC}
// CHECK:STDOUT: import_ir_inst7A: {ir_id: import_ir78000004, inst_id: inst700001BD}
// CHECK:STDOUT: import_ir_inst7B: {ir_id: import_ir78000004, inst_id: inst700001BE}
// CHECK:STDOUT: import_ir_inst7C: {ir_id: import_ir78000004, inst_id: inst700001BF}
// CHECK:STDOUT: import_ir_inst7D: {ir_id: import_ir78000004, inst_id: inst700001C2}
// CHECK:STDOUT: import_ir_inst7E: {ir_id: import_ir78000004, inst_id: inst700001C8}
// CHECK:STDOUT: import_ir_inst7F: {ir_id: import_ir78000004, inst_id: inst700001D9}
// CHECK:STDOUT: import_ir_inst80: {ir_id: import_ir78000004, inst_id: inst700001DF}
// CHECK:STDOUT: import_ir_inst81: {ir_id: import_ir78000004, inst_id: inst700001E3}
// CHECK:STDOUT: import_ir_inst82: {ir_id: import_ir78000004, inst_id: inst700001E4}
// CHECK:STDOUT: import_ir_inst83: {ir_id: import_ir78000004, inst_id: inst700001E5}
// CHECK:STDOUT: import_ir_inst84: {ir_id: import_ir78000004, inst_id: inst700001E6}
// CHECK:STDOUT: import_ir_inst85: {ir_id: import_ir78000004, inst_id: inst700001E9}
// CHECK:STDOUT: import_ir_inst86: {ir_id: import_ir78000004, inst_id: inst700001F3}
// CHECK:STDOUT: import_ir_inst87: {ir_id: import_ir78000004, inst_id: inst700001FC}
// CHECK:STDOUT: import_ir_inst88: {ir_id: import_ir78000004, inst_id: inst700001FD}
// CHECK:STDOUT: import_ir_inst89: {ir_id: import_ir78000004, inst_id: inst700001FE}
// CHECK:STDOUT: import_ir_inst8A: {ir_id: import_ir78000004, inst_id: inst700001FF}
// CHECK:STDOUT: import_ir_inst8B: {ir_id: import_ir78000004, inst_id: inst70000205}
// CHECK:STDOUT: import_ir_inst8C: {ir_id: import_ir78000004, inst_id: inst7000019C}
// CHECK:STDOUT: import_ir_inst8D: {ir_id: import_ir78000004, inst_id: inst70000196}
// CHECK:STDOUT: import_ir_inst8E: {ir_id: import_ir78000004, inst_id: inst700001AC}
// CHECK:STDOUT: import_ir_inst8F: {ir_id: import_ir78000004, inst_id: inst700001AE}
// CHECK:STDOUT: import_ir_inst90: {ir_id: import_ir78000004, inst_id: inst70000194}
// CHECK:STDOUT: import_ir_inst91: {ir_id: import_ir78000004, inst_id: inst70000199}
// CHECK:STDOUT: import_ir_inst92: {ir_id: import_ir78000004, inst_id: inst70000195}
// CHECK:STDOUT: import_ir_inst93: {ir_id: import_ir78000004, inst_id: inst7000019B}
// CHECK:STDOUT: import_ir_inst94: {ir_id: import_ir78000004, inst_id: inst700001A2}
// CHECK:STDOUT: import_ir_inst95: {ir_id: import_ir78000004, inst_id: inst700001A5}
// CHECK:STDOUT: import_ir_inst96: {ir_id: import_ir78000004, inst_id: inst700001A9}
// CHECK:STDOUT: import_ir_inst97: {ir_id: import_ir78000004, inst_id: inst700001AD}
// CHECK:STDOUT: import_ir_inst98: {ir_id: import_ir78000004, inst_id: inst700001B5}
// CHECK:STDOUT: import_ir_inst99: {ir_id: import_ir78000004, inst_id: inst700001D1}
// CHECK:STDOUT: import_ir_inst9A: {ir_id: import_ir78000004, inst_id: inst700001D2}
// CHECK:STDOUT: import_ir_inst9B: {ir_id: import_ir78000004, inst_id: inst7000023F}
// CHECK:STDOUT: import_ir_inst9C: {ir_id: import_ir78000004, inst_id: inst7000023D}
// CHECK:STDOUT: import_ir_inst9D: {ir_id: import_ir78000004, inst_id: inst7000025E}
// CHECK:STDOUT: import_ir_inst9E: {ir_id: import_ir78000004, inst_id: inst7000023E}
// CHECK:STDOUT: import_ir_inst9F: {ir_id: import_ir78000004, inst_id: inst7000025E}
// CHECK:STDOUT: import_ir_instA0: {ir_id: import_ir78000004, inst_id: inst70000259}
// CHECK:STDOUT: import_ir_instA1: {ir_id: import_ir78000004, inst_id: inst7000025A}
// CHECK:STDOUT: import_ir_instA2: {ir_id: import_ir78000004, inst_id: inst70000251}
// CHECK:STDOUT: import_ir_instA3: {ir_id: import_ir78000004, inst_id: inst70000254}
// CHECK:STDOUT: import_ir_instA4: {ir_id: import_ir78000004, inst_id: inst70000255}
// CHECK:STDOUT: import_ir_instA5: {ir_id: import_ir78000004, inst_id: inst70000256}
// CHECK:STDOUT: import_ir_instA6: {ir_id: import_ir78000004, inst_id: inst70000216}
// CHECK:STDOUT: import_ir_instA7: {ir_id: import_ir78000004, inst_id: inst7000021B}
// CHECK:STDOUT: import_ir_instA8: {ir_id: import_ir78000004, inst_id: inst70000220}
// CHECK:STDOUT: import_ir_instA9: {ir_id: import_ir78000004, inst_id: inst70000249}
// CHECK:STDOUT: import_ir_instAA: {ir_id: import_ir78000004, inst_id: inst7000024A}
// CHECK:STDOUT: import_ir_instAB: {ir_id: import_ir78000004, inst_id: inst7000024B}
// CHECK:STDOUT: import_ir_instAC: {ir_id: import_ir78000004, inst_id: inst7000024C}
// CHECK:STDOUT: import_ir_instAD: {ir_id: import_ir78000004, inst_id: inst7000024D}
// CHECK:STDOUT: import_ir_instAE: {ir_id: import_ir78000004, inst_id: inst7000024E}
// CHECK:STDOUT: import_ir_instAF: {ir_id: import_ir78000004, inst_id: inst7000024F}
// CHECK:STDOUT: import_ir_instB0: {ir_id: import_ir78000004, inst_id: inst70000252}
// CHECK:STDOUT: import_ir_instB1: {ir_id: import_ir78000004, inst_id: inst70000258}
// CHECK:STDOUT: import_ir_instB2: {ir_id: import_ir78000004, inst_id: inst70000269}
// CHECK:STDOUT: import_ir_instB3: {ir_id: import_ir78000004, inst_id: inst7000026E}
// CHECK:STDOUT: import_ir_instB4: {ir_id: import_ir78000004, inst_id: inst70000272}
// CHECK:STDOUT: import_ir_instB5: {ir_id: import_ir78000004, inst_id: inst70000273}
// CHECK:STDOUT: import_ir_instB6: {ir_id: import_ir78000004, inst_id: inst70000274}
// CHECK:STDOUT: import_ir_instB7: {ir_id: import_ir78000004, inst_id: inst70000275}
// CHECK:STDOUT: import_ir_instB8: {ir_id: import_ir78000004, inst_id: inst70000278}
// CHECK:STDOUT: import_ir_instB9: {ir_id: import_ir78000004, inst_id: inst70000280}
// CHECK:STDOUT: import_ir_instBA: {ir_id: import_ir78000004, inst_id: inst70000284}
// CHECK:STDOUT: import_ir_instBB: {ir_id: import_ir78000004, inst_id: inst70000285}
// CHECK:STDOUT: import_ir_instBC: {ir_id: import_ir78000004, inst_id: inst70000286}
// CHECK:STDOUT: import_ir_instBD: {ir_id: import_ir78000004, inst_id: inst70000287}
// CHECK:STDOUT: import_ir_instBE: {ir_id: import_ir78000004, inst_id: inst7000028A}
// CHECK:STDOUT: import_ir_instBF: {ir_id: import_ir78000004, inst_id: inst70000294}
// CHECK:STDOUT: import_ir_instC0: {ir_id: import_ir78000004, inst_id: inst7000029D}
// CHECK:STDOUT: import_ir_instC1: {ir_id: import_ir78000004, inst_id: inst7000029E}
// CHECK:STDOUT: import_ir_instC2: {ir_id: import_ir78000004, inst_id: inst7000029F}
// CHECK:STDOUT: import_ir_instC3: {ir_id: import_ir78000004, inst_id: inst700002A0}
// CHECK:STDOUT: import_ir_instC4: {ir_id: import_ir78000004, inst_id: inst700002A6}
// CHECK:STDOUT: import_ir_instC5: {ir_id: import_ir78000004, inst_id: inst70000223}
// CHECK:STDOUT: import_ir_instC6: {ir_id: import_ir78000004, inst_id: inst7000021D}
// CHECK:STDOUT: import_ir_instC7: {ir_id: import_ir78000004, inst_id: inst70000218}
// CHECK:STDOUT: import_ir_instC8: {ir_id: import_ir78000004, inst_id: inst70000237}
// CHECK:STDOUT: import_ir_instC9: {ir_id: import_ir78000004, inst_id: inst70000239}
// CHECK:STDOUT: import_ir_instCA: {ir_id: import_ir78000004, inst_id: inst70000216}
// CHECK:STDOUT: import_ir_instCB: {ir_id: import_ir78000004, inst_id: inst7000021B}
// CHECK:STDOUT: import_ir_instCC: {ir_id: import_ir78000004, inst_id: inst70000220}
// CHECK:STDOUT: import_ir_instCD: {ir_id: import_ir78000004, inst_id: inst70000217}
// CHECK:STDOUT: import_ir_instCE: {ir_id: import_ir78000004, inst_id: inst7000021C}
// CHECK:STDOUT: import_ir_instCF: {ir_id: import_ir78000004, inst_id: inst70000222}
// CHECK:STDOUT: import_ir_instD0: {ir_id: import_ir78000004, inst_id: inst7000022A}
// CHECK:STDOUT: import_ir_instD1: {ir_id: import_ir78000004, inst_id: inst7000022D}
// CHECK:STDOUT: import_ir_instD2: {ir_id: import_ir78000004, inst_id: inst70000230}
// CHECK:STDOUT: import_ir_instD3: {ir_id: import_ir78000004, inst_id: inst70000234}
// CHECK:STDOUT: import_ir_instD4: {ir_id: import_ir78000004, inst_id: inst70000238}
// CHECK:STDOUT: import_ir_instD5: {ir_id: import_ir78000004, inst_id: inst70000241}
// CHECK:STDOUT: import_ir_instD6: {ir_id: import_ir78000004, inst_id: inst70000261}
// CHECK:STDOUT: import_ir_instD7: {ir_id: import_ir78000004, inst_id: inst70000262}
// CHECK:STDOUT: import_ir_inst39: {ir_id: import_ir78000004, inst_id: inst700000D4}
// CHECK:STDOUT: import_ir_inst3A: {ir_id: import_ir78000004, inst_id: inst700000D2}
// CHECK:STDOUT: import_ir_inst3B: {ir_id: import_ir78000004, inst_id: inst700000D0}
// CHECK:STDOUT: import_ir_inst3C: {ir_id: import_ir78000004, inst_id: inst700000D1}
// CHECK:STDOUT: import_ir_inst3D: {ir_id: import_ir78000004, inst_id: inst700000ED}
// CHECK:STDOUT: import_ir_inst3E: {ir_id: import_ir78000004, inst_id: inst700000EB}
// CHECK:STDOUT: import_ir_inst3F: {ir_id: import_ir78000004, inst_id: inst700000E9}
// CHECK:STDOUT: import_ir_inst40: {ir_id: import_ir78000004, inst_id: inst700000EA}
// CHECK:STDOUT: import_ir_inst41: {ir_id: import_ir78000004, inst_id: inst70000106}
// CHECK:STDOUT: import_ir_inst42: {ir_id: import_ir78000004, inst_id: inst70000104}
// CHECK:STDOUT: import_ir_inst43: {ir_id: import_ir78000004, inst_id: inst70000102}
// CHECK:STDOUT: import_ir_inst44: {ir_id: import_ir78000004, inst_id: inst70000103}
// CHECK:STDOUT: import_ir_inst45: {ir_id: import_ir78000004, inst_id: inst7000011F}
// CHECK:STDOUT: import_ir_inst46: {ir_id: import_ir78000004, inst_id: inst7000011D}
// CHECK:STDOUT: import_ir_inst47: {ir_id: import_ir78000004, inst_id: inst7000011B}
// CHECK:STDOUT: import_ir_inst48: {ir_id: import_ir78000004, inst_id: inst7000011C}
// CHECK:STDOUT: import_ir_inst49: {ir_id: import_ir78000004, inst_id: inst70000142}
// CHECK:STDOUT: import_ir_inst4A: {ir_id: import_ir78000004, inst_id: inst70000140}
// CHECK:STDOUT: import_ir_inst4B: {ir_id: import_ir78000004, inst_id: inst70000156}
// CHECK:STDOUT: import_ir_inst4C: {ir_id: import_ir78000004, inst_id: inst70000141}
// CHECK:STDOUT: import_ir_inst4D: {ir_id: import_ir78000004, inst_id: inst70000139}
// CHECK:STDOUT: import_ir_inst4E: {ir_id: import_ir78000004, inst_id: inst7000013B}
// CHECK:STDOUT: import_ir_inst4F: {ir_id: import_ir78000004, inst_id: inst7000013E}
// CHECK:STDOUT: import_ir_inst50: {ir_id: import_ir78000004, inst_id: inst70000136}
// CHECK:STDOUT: import_ir_inst51: {ir_id: import_ir78000004, inst_id: inst70000138}
// CHECK:STDOUT: import_ir_inst52: {ir_id: import_ir78000004, inst_id: inst7000013D}
// CHECK:STDOUT: import_ir_inst53: {ir_id: import_ir78000004, inst_id: inst70000144}
// CHECK:STDOUT: import_ir_inst54: {ir_id: import_ir78000004, inst_id: inst70000156}
// CHECK:STDOUT: import_ir_inst55: {ir_id: import_ir78000004, inst_id: inst70000151}
// CHECK:STDOUT: import_ir_inst56: {ir_id: import_ir78000004, inst_id: inst70000152}
// CHECK:STDOUT: import_ir_inst57: {ir_id: import_ir78000004, inst_id: inst70000149}
// CHECK:STDOUT: import_ir_inst58: {ir_id: import_ir78000004, inst_id: inst7000014C}
// CHECK:STDOUT: import_ir_inst59: {ir_id: import_ir78000004, inst_id: inst7000014D}
// CHECK:STDOUT: import_ir_inst5A: {ir_id: import_ir78000004, inst_id: inst7000014E}
// CHECK:STDOUT: import_ir_inst5B: {ir_id: import_ir78000004, inst_id: inst70000136}
// CHECK:STDOUT: import_ir_inst5C: {ir_id: import_ir78000004, inst_id: inst70000146}
// CHECK:STDOUT: import_ir_inst5D: {ir_id: import_ir78000004, inst_id: inst70000147}
// CHECK:STDOUT: import_ir_inst5E: {ir_id: import_ir78000004, inst_id: inst7000014A}
// CHECK:STDOUT: import_ir_inst5F: {ir_id: import_ir78000004, inst_id: inst70000150}
// CHECK:STDOUT: import_ir_inst60: {ir_id: import_ir78000004, inst_id: inst70000159}
// CHECK:STDOUT: import_ir_inst61: {ir_id: import_ir78000004, inst_id: inst7000015A}
// CHECK:STDOUT: import_ir_inst62: {ir_id: import_ir78000004, inst_id: inst7000015D}
// CHECK:STDOUT: import_ir_inst63: {ir_id: import_ir78000004, inst_id: inst70000165}
// CHECK:STDOUT: import_ir_inst64: {ir_id: import_ir78000004, inst_id: inst70000163}
// CHECK:STDOUT: import_ir_inst65: {ir_id: import_ir78000004, inst_id: inst70000161}
// CHECK:STDOUT: import_ir_inst66: {ir_id: import_ir78000004, inst_id: inst70000162}
// CHECK:STDOUT: import_ir_inst67: {ir_id: import_ir78000004, inst_id: inst7000017E}
// CHECK:STDOUT: import_ir_inst68: {ir_id: import_ir78000004, inst_id: inst7000017C}
// CHECK:STDOUT: import_ir_inst69: {ir_id: import_ir78000004, inst_id: inst7000017A}
// CHECK:STDOUT: import_ir_inst6A: {ir_id: import_ir78000004, inst_id: inst7000017B}
// CHECK:STDOUT: import_ir_inst6B: {ir_id: import_ir78000004, inst_id: inst700001B4}
// CHECK:STDOUT: import_ir_inst6C: {ir_id: import_ir78000004, inst_id: inst700001B2}
// CHECK:STDOUT: import_ir_inst6D: {ir_id: import_ir78000004, inst_id: inst700001CF}
// CHECK:STDOUT: import_ir_inst6E: {ir_id: import_ir78000004, inst_id: inst700001B3}
// CHECK:STDOUT: import_ir_inst6F: {ir_id: import_ir78000004, inst_id: inst700001CF}
// CHECK:STDOUT: import_ir_inst70: {ir_id: import_ir78000004, inst_id: inst700001CA}
// CHECK:STDOUT: import_ir_inst71: {ir_id: import_ir78000004, inst_id: inst700001CB}
// CHECK:STDOUT: import_ir_inst72: {ir_id: import_ir78000004, inst_id: inst700001C2}
// CHECK:STDOUT: import_ir_inst73: {ir_id: import_ir78000004, inst_id: inst700001C5}
// CHECK:STDOUT: import_ir_inst74: {ir_id: import_ir78000004, inst_id: inst700001C6}
// CHECK:STDOUT: import_ir_inst75: {ir_id: import_ir78000004, inst_id: inst700001C7}
// CHECK:STDOUT: import_ir_inst76: {ir_id: import_ir78000004, inst_id: inst70000195}
// CHECK:STDOUT: import_ir_inst77: {ir_id: import_ir78000004, inst_id: inst7000019A}
// CHECK:STDOUT: import_ir_inst78: {ir_id: import_ir78000004, inst_id: inst700001BC}
// CHECK:STDOUT: import_ir_inst79: {ir_id: import_ir78000004, inst_id: inst700001BD}
// CHECK:STDOUT: import_ir_inst7A: {ir_id: import_ir78000004, inst_id: inst700001BE}
// CHECK:STDOUT: import_ir_inst7B: {ir_id: import_ir78000004, inst_id: inst700001BF}
// CHECK:STDOUT: import_ir_inst7C: {ir_id: import_ir78000004, inst_id: inst700001C0}
// CHECK:STDOUT: import_ir_inst7D: {ir_id: import_ir78000004, inst_id: inst700001C3}
// CHECK:STDOUT: import_ir_inst7E: {ir_id: import_ir78000004, inst_id: inst700001C9}
// CHECK:STDOUT: import_ir_inst7F: {ir_id: import_ir78000004, inst_id: inst700001DA}
// CHECK:STDOUT: import_ir_inst80: {ir_id: import_ir78000004, inst_id: inst700001E0}
// CHECK:STDOUT: import_ir_inst81: {ir_id: import_ir78000004, inst_id: inst700001E4}
// CHECK:STDOUT: import_ir_inst82: {ir_id: import_ir78000004, inst_id: inst700001E5}
// CHECK:STDOUT: import_ir_inst83: {ir_id: import_ir78000004, inst_id: inst700001E6}
// CHECK:STDOUT: import_ir_inst84: {ir_id: import_ir78000004, inst_id: inst700001E7}
// CHECK:STDOUT: import_ir_inst85: {ir_id: import_ir78000004, inst_id: inst700001EB}
// CHECK:STDOUT: import_ir_inst86: {ir_id: import_ir78000004, inst_id: inst700001F5}
// CHECK:STDOUT: import_ir_inst87: {ir_id: import_ir78000004, inst_id: inst700001FE}
// CHECK:STDOUT: import_ir_inst88: {ir_id: import_ir78000004, inst_id: inst700001FF}
// CHECK:STDOUT: import_ir_inst89: {ir_id: import_ir78000004, inst_id: inst70000200}
// CHECK:STDOUT: import_ir_inst8A: {ir_id: import_ir78000004, inst_id: inst70000201}
// CHECK:STDOUT: import_ir_inst8B: {ir_id: import_ir78000004, inst_id: inst70000208}
// CHECK:STDOUT: import_ir_inst8C: {ir_id: import_ir78000004, inst_id: inst7000019D}
// CHECK:STDOUT: import_ir_inst8D: {ir_id: import_ir78000004, inst_id: inst70000197}
// CHECK:STDOUT: import_ir_inst8E: {ir_id: import_ir78000004, inst_id: inst700001AD}
// CHECK:STDOUT: import_ir_inst8F: {ir_id: import_ir78000004, inst_id: inst700001AF}
// CHECK:STDOUT: import_ir_inst90: {ir_id: import_ir78000004, inst_id: inst70000195}
// CHECK:STDOUT: import_ir_inst91: {ir_id: import_ir78000004, inst_id: inst7000019A}
// CHECK:STDOUT: import_ir_inst92: {ir_id: import_ir78000004, inst_id: inst70000196}
// CHECK:STDOUT: import_ir_inst93: {ir_id: import_ir78000004, inst_id: inst7000019C}
// CHECK:STDOUT: import_ir_inst94: {ir_id: import_ir78000004, inst_id: inst700001A3}
// CHECK:STDOUT: import_ir_inst95: {ir_id: import_ir78000004, inst_id: inst700001A6}
// CHECK:STDOUT: import_ir_inst96: {ir_id: import_ir78000004, inst_id: inst700001AA}
// CHECK:STDOUT: import_ir_inst97: {ir_id: import_ir78000004, inst_id: inst700001AE}
// CHECK:STDOUT: import_ir_inst98: {ir_id: import_ir78000004, inst_id: inst700001B6}
// CHECK:STDOUT: import_ir_inst99: {ir_id: import_ir78000004, inst_id: inst700001D2}
// CHECK:STDOUT: import_ir_inst9A: {ir_id: import_ir78000004, inst_id: inst700001D3}
// CHECK:STDOUT: import_ir_inst9B: {ir_id: import_ir78000004, inst_id: inst70000242}
// CHECK:STDOUT: import_ir_inst9C: {ir_id: import_ir78000004, inst_id: inst70000240}
// CHECK:STDOUT: import_ir_inst9D: {ir_id: import_ir78000004, inst_id: inst70000261}
// CHECK:STDOUT: import_ir_inst9E: {ir_id: import_ir78000004, inst_id: inst70000241}
// CHECK:STDOUT: import_ir_inst9F: {ir_id: import_ir78000004, inst_id: inst70000261}
// CHECK:STDOUT: import_ir_instA0: {ir_id: import_ir78000004, inst_id: inst7000025C}
// CHECK:STDOUT: import_ir_instA1: {ir_id: import_ir78000004, inst_id: inst7000025D}
// CHECK:STDOUT: import_ir_instA2: {ir_id: import_ir78000004, inst_id: inst70000254}
// CHECK:STDOUT: import_ir_instA3: {ir_id: import_ir78000004, inst_id: inst70000257}
// CHECK:STDOUT: import_ir_instA4: {ir_id: import_ir78000004, inst_id: inst70000258}
// CHECK:STDOUT: import_ir_instA5: {ir_id: import_ir78000004, inst_id: inst70000259}
// CHECK:STDOUT: import_ir_instA6: {ir_id: import_ir78000004, inst_id: inst70000219}
// CHECK:STDOUT: import_ir_instA7: {ir_id: import_ir78000004, inst_id: inst7000021E}
// CHECK:STDOUT: import_ir_instA8: {ir_id: import_ir78000004, inst_id: inst70000223}
// CHECK:STDOUT: import_ir_instA9: {ir_id: import_ir78000004, inst_id: inst7000024C}
// CHECK:STDOUT: import_ir_instAA: {ir_id: import_ir78000004, inst_id: inst7000024D}
// CHECK:STDOUT: import_ir_instAB: {ir_id: import_ir78000004, inst_id: inst7000024E}
// CHECK:STDOUT: import_ir_instAC: {ir_id: import_ir78000004, inst_id: inst7000024F}
// CHECK:STDOUT: import_ir_instAD: {ir_id: import_ir78000004, inst_id: inst70000250}
// CHECK:STDOUT: import_ir_instAE: {ir_id: import_ir78000004, inst_id: inst70000251}
// CHECK:STDOUT: import_ir_instAF: {ir_id: import_ir78000004, inst_id: inst70000252}
// CHECK:STDOUT: import_ir_instB0: {ir_id: import_ir78000004, inst_id: inst70000255}
// CHECK:STDOUT: import_ir_instB1: {ir_id: import_ir78000004, inst_id: inst7000025B}
// CHECK:STDOUT: import_ir_instB2: {ir_id: import_ir78000004, inst_id: inst7000026C}
// CHECK:STDOUT: import_ir_instB3: {ir_id: import_ir78000004, inst_id: inst70000271}
// CHECK:STDOUT: import_ir_instB4: {ir_id: import_ir78000004, inst_id: inst70000275}
// CHECK:STDOUT: import_ir_instB5: {ir_id: import_ir78000004, inst_id: inst70000276}
// CHECK:STDOUT: import_ir_instB6: {ir_id: import_ir78000004, inst_id: inst70000277}
// CHECK:STDOUT: import_ir_instB7: {ir_id: import_ir78000004, inst_id: inst70000278}
// CHECK:STDOUT: import_ir_instB8: {ir_id: import_ir78000004, inst_id: inst7000027C}
// CHECK:STDOUT: import_ir_instB9: {ir_id: import_ir78000004, inst_id: inst70000284}
// CHECK:STDOUT: import_ir_instBA: {ir_id: import_ir78000004, inst_id: inst70000288}
// CHECK:STDOUT: import_ir_instBB: {ir_id: import_ir78000004, inst_id: inst70000289}
// CHECK:STDOUT: import_ir_instBC: {ir_id: import_ir78000004, inst_id: inst7000028A}
// CHECK:STDOUT: import_ir_instBD: {ir_id: import_ir78000004, inst_id: inst7000028B}
// CHECK:STDOUT: import_ir_instBE: {ir_id: import_ir78000004, inst_id: inst7000028F}
// CHECK:STDOUT: import_ir_instBF: {ir_id: import_ir78000004, inst_id: inst70000299}
// CHECK:STDOUT: import_ir_instC0: {ir_id: import_ir78000004, inst_id: inst700002A2}
// CHECK:STDOUT: import_ir_instC1: {ir_id: import_ir78000004, inst_id: inst700002A3}
// CHECK:STDOUT: import_ir_instC2: {ir_id: import_ir78000004, inst_id: inst700002A4}
// CHECK:STDOUT: import_ir_instC3: {ir_id: import_ir78000004, inst_id: inst700002A5}
// CHECK:STDOUT: import_ir_instC4: {ir_id: import_ir78000004, inst_id: inst700002AC}
// CHECK:STDOUT: import_ir_instC5: {ir_id: import_ir78000004, inst_id: inst70000226}
// CHECK:STDOUT: import_ir_instC6: {ir_id: import_ir78000004, inst_id: inst70000220}
// CHECK:STDOUT: import_ir_instC7: {ir_id: import_ir78000004, inst_id: inst7000021B}
// CHECK:STDOUT: import_ir_instC8: {ir_id: import_ir78000004, inst_id: inst7000023A}
// CHECK:STDOUT: import_ir_instC9: {ir_id: import_ir78000004, inst_id: inst7000023C}
// CHECK:STDOUT: import_ir_instCA: {ir_id: import_ir78000004, inst_id: inst70000219}
// CHECK:STDOUT: import_ir_instCB: {ir_id: import_ir78000004, inst_id: inst7000021E}
// CHECK:STDOUT: import_ir_instCC: {ir_id: import_ir78000004, inst_id: inst70000223}
// CHECK:STDOUT: import_ir_instCD: {ir_id: import_ir78000004, inst_id: inst7000021A}
// CHECK:STDOUT: import_ir_instCE: {ir_id: import_ir78000004, inst_id: inst7000021F}
// CHECK:STDOUT: import_ir_instCF: {ir_id: import_ir78000004, inst_id: inst70000225}
// CHECK:STDOUT: import_ir_instD0: {ir_id: import_ir78000004, inst_id: inst7000022D}
// CHECK:STDOUT: import_ir_instD1: {ir_id: import_ir78000004, inst_id: inst70000230}
// CHECK:STDOUT: import_ir_instD2: {ir_id: import_ir78000004, inst_id: inst70000233}
// CHECK:STDOUT: import_ir_instD3: {ir_id: import_ir78000004, inst_id: inst70000237}
// CHECK:STDOUT: import_ir_instD4: {ir_id: import_ir78000004, inst_id: inst7000023B}
// CHECK:STDOUT: import_ir_instD5: {ir_id: import_ir78000004, inst_id: inst70000244}
// CHECK:STDOUT: import_ir_instD6: {ir_id: import_ir78000004, inst_id: inst70000264}
// CHECK:STDOUT: import_ir_instD7: {ir_id: import_ir78000004, inst_id: inst70000265}
// CHECK:STDOUT: clang_decls: {}
// CHECK:STDOUT: clang_decl_signatures: {}
// CHECK:STDOUT: name_scopes:
@@ -874,19 +875,23 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: inst7800017C: {kind: FunctionTypeWithSelfType, arg0: inst7800017B, arg1: inst7800017A, type: type(TypeType)}
// CHECK:STDOUT: inst7800017D: {kind: ImplWitnessAccess, arg0: inst78000179, arg1: element0, type: type(symbolic_constant7800014A)}
// CHECK:STDOUT: inst7800017E: {kind: BoundMethod, arg0: inst78000048, arg1: inst78000177, type: type(inst(BoundMethodType))}
// CHECK:STDOUT: inst7800017F: {kind: SpecificImplFunction, arg0: inst78000177, arg1: specific78000025, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000180: {kind: SpecificImplFunction, arg0: inst78000178, arg1: specific78000025, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000181: {kind: SpecificImplFunction, arg0: inst7800017D, arg1: specific78000026, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000182: {kind: BoundMethod, arg0: inst78000048, arg1: inst7800017F, type: type(inst(BoundMethodType))}
// CHECK:STDOUT: inst78000183: {kind: Call, arg0: inst78000182, arg1: inst_block78000089, type: type(symbolic_constant78000004)}
// CHECK:STDOUT: inst78000184: {kind: InPlaceInit, arg0: inst78000183, arg1: inst7800004C, type: type(symbolic_constant78000004)}
// CHECK:STDOUT: inst78000185: {kind: TupleAccess, arg0: inst7800003C, arg1: element1, type: type(inst78000026)}
// CHECK:STDOUT: inst78000186: {kind: TupleInit, arg0: inst_block_empty, arg1: inst78000185, type: type(inst78000026)}
// CHECK:STDOUT: inst78000187: {kind: Converted, arg0: inst78000049, arg1: inst78000186, type: type(inst78000026)}
// CHECK:STDOUT: inst78000188: {kind: InPlaceInit, arg0: inst78000187, arg1: inst78000185, type: type(inst78000026)}
// CHECK:STDOUT: inst78000189: {kind: TupleInit, arg0: inst_block7800008A, arg1: inst7800003C, type: type(symbolic_constant7800000A)}
// CHECK:STDOUT: inst7800018A: {kind: Converted, arg0: inst7800004A, arg1: inst78000189, type: type(symbolic_constant7800000A)}
// CHECK:STDOUT: inst7800018B: {kind: ReturnExpr, arg0: inst7800018A, arg1: inst7800003C}
// CHECK:STDOUT: inst7800017F: {kind: LookupImplWitness, arg0: inst7800001D, arg1: specific_interface78000000, type: type(inst(WitnessType))}
// CHECK:STDOUT: inst78000180: {kind: RequireSpecificDefinition, arg0: specific7800000B, type: type(inst(RequireSpecificDefinitionType))}
// CHECK:STDOUT: inst78000181: {kind: FacetValue, arg0: inst7800001D, arg1: inst_block78000082, type: type(inst78000050)}
// CHECK:STDOUT: inst78000182: {kind: Converted, arg0: inst7800001D, arg1: inst78000181, type: type(inst78000050)}
// CHECK:STDOUT: inst78000183: {kind: SpecificImplFunction, arg0: inst78000177, arg1: specific78000025, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000184: {kind: SpecificImplFunction, arg0: inst78000178, arg1: specific78000025, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000185: {kind: SpecificImplFunction, arg0: inst7800017D, arg1: specific78000026, type: type(inst(SpecificFunctionType))}
// CHECK:STDOUT: inst78000186: {kind: BoundMethod, arg0: inst78000048, arg1: inst78000183, type: type(inst(BoundMethodType))}
// CHECK:STDOUT: inst78000187: {kind: Call, arg0: inst78000186, arg1: inst_block78000089, type: type(symbolic_constant78000004)}
// CHECK:STDOUT: inst78000188: {kind: InPlaceInit, arg0: inst78000187, arg1: inst7800004C, type: type(symbolic_constant78000004)}
// CHECK:STDOUT: inst78000189: {kind: TupleAccess, arg0: inst7800003C, arg1: element1, type: type(inst78000026)}
// CHECK:STDOUT: inst7800018A: {kind: TupleInit, arg0: inst_block_empty, arg1: inst78000189, type: type(inst78000026)}
// CHECK:STDOUT: inst7800018B: {kind: Converted, arg0: inst78000049, arg1: inst7800018A, type: type(inst78000026)}
// CHECK:STDOUT: inst7800018C: {kind: InPlaceInit, arg0: inst7800018B, arg1: inst78000189, type: type(inst78000026)}
// CHECK:STDOUT: inst7800018D: {kind: TupleInit, arg0: inst_block7800008A, arg1: inst7800003C, type: type(symbolic_constant7800000A)}
// CHECK:STDOUT: inst7800018E: {kind: Converted, arg0: inst7800004A, arg1: inst7800018D, type: type(symbolic_constant7800000A)}
// CHECK:STDOUT: inst7800018F: {kind: ReturnExpr, arg0: inst7800018E, arg1: inst7800003C}
// CHECK:STDOUT: bundles: {}
// CHECK:STDOUT: constant_values:
// CHECK:STDOUT: values:
@@ -1248,12 +1253,15 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: inst7800017B: symbolic_constant78000149
// CHECK:STDOUT: inst7800017C: symbolic_constant7800014A
// CHECK:STDOUT: inst7800017D: symbolic_constant7800014B
// CHECK:STDOUT: inst7800017F: symbolic_constant7800014D
// CHECK:STDOUT: inst78000180: symbolic_constant7800014C
// CHECK:STDOUT: inst78000181: symbolic_constant7800014D
// CHECK:STDOUT: inst78000186: concrete_constant(inst78000028)
// CHECK:STDOUT: inst78000187: concrete_constant(inst78000028)
// CHECK:STDOUT: inst78000188: concrete_constant(inst78000028)
// CHECK:STDOUT: inst78000180: symbolic_constant78000141
// CHECK:STDOUT: inst78000181: symbolic_constant78000148
// CHECK:STDOUT: inst78000182: symbolic_constant78000148
// CHECK:STDOUT: inst78000183: symbolic_constant7800014D
// CHECK:STDOUT: inst78000184: symbolic_constant7800014C
// CHECK:STDOUT: inst78000185: symbolic_constant7800014D
// CHECK:STDOUT: inst7800018A: concrete_constant(inst78000028)
// CHECK:STDOUT: inst7800018B: concrete_constant(inst78000028)
// CHECK:STDOUT: inst7800018C: concrete_constant(inst78000028)
// CHECK:STDOUT: symbolic_constants:
// CHECK:STDOUT: symbolic_constant78000000: {inst: inst78000014, kind: self, attached: null}
// CHECK:STDOUT: symbolic_constant78000001: {inst: inst78000018, kind: checked, attached: null}
@@ -1587,8 +1595,8 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: symbolic_constant78000149: {inst: inst78000174, kind: checked, attached: {generic: generic78000000, index: generic_inst_in_def5}}
// CHECK:STDOUT: symbolic_constant7800014A: {inst: inst78000176, kind: checked, attached: {generic: generic78000000, index: generic_inst_in_def6}}
// CHECK:STDOUT: symbolic_constant7800014B: {inst: inst78000178, kind: checked, attached: {generic: generic78000000, index: generic_inst_in_def7}}
// CHECK:STDOUT: symbolic_constant7800014C: {inst: inst78000180, kind: checked, attached: null}
// CHECK:STDOUT: symbolic_constant7800014D: {inst: inst78000180, kind: checked, attached: {generic: generic78000000, index: generic_inst_in_def8}}
// CHECK:STDOUT: symbolic_constant7800014C: {inst: inst78000184, kind: checked, attached: null}
// CHECK:STDOUT: symbolic_constant7800014D: {inst: inst78000184, kind: checked, attached: {generic: generic78000000, index: generic_inst_in_def8}}
// CHECK:STDOUT: inst_blocks:
// CHECK:STDOUT: inst_block_empty: {}
// CHECK:STDOUT: exports:
@@ -1794,18 +1802,20 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: 2: inst7800004A
// CHECK:STDOUT: 3: inst78000177
// CHECK:STDOUT: 4: inst7800017E
// CHECK:STDOUT: 5: inst7800017F
// CHECK:STDOUT: 5: inst78000181
// CHECK:STDOUT: 6: inst78000182
// CHECK:STDOUT: 7: inst78000183
// CHECK:STDOUT: 8: inst7800004C
// CHECK:STDOUT: 9: inst78000184
// CHECK:STDOUT: 10: inst78000185
// CHECK:STDOUT: 11: inst78000186
// CHECK:STDOUT: 12: inst78000187
// CHECK:STDOUT: 13: inst78000188
// CHECK:STDOUT: 14: inst78000189
// CHECK:STDOUT: 15: inst7800018A
// CHECK:STDOUT: 16: inst7800018B
// CHECK:STDOUT: 8: inst78000186
// CHECK:STDOUT: 9: inst78000187
// CHECK:STDOUT: 10: inst7800004C
// CHECK:STDOUT: 11: inst78000188
// CHECK:STDOUT: 12: inst78000189
// CHECK:STDOUT: 13: inst7800018A
// CHECK:STDOUT: 14: inst7800018B
// CHECK:STDOUT: 15: inst7800018C
// CHECK:STDOUT: 16: inst7800018D
// CHECK:STDOUT: 17: inst7800018E
// CHECK:STDOUT: 18: inst7800018F
// CHECK:STDOUT: inst_block78000019:
// CHECK:STDOUT: 0: inst78000048
// CHECK:STDOUT: 1: inst78000049
@@ -2228,8 +2238,8 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: inst_block78000089:
// CHECK:STDOUT: 0: inst78000048
// CHECK:STDOUT: inst_block7800008A:
// CHECK:STDOUT: 0: inst78000184
// CHECK:STDOUT: 1: inst78000188
// CHECK:STDOUT: 0: inst78000188
// CHECK:STDOUT: 1: inst7800018C
// CHECK:STDOUT: inst_block7800008B:
// CHECK:STDOUT: 0: inst78000043
// CHECK:STDOUT: 1: inst78000047
@@ -2239,7 +2249,7 @@ fn Foo[T:! type](p: T*) -> (T*, ()) {
// CHECK:STDOUT: 5: inst7800017B
// CHECK:STDOUT: 6: inst7800017C
// CHECK:STDOUT: 7: inst7800017D
// CHECK:STDOUT: 8: inst78000181
// CHECK:STDOUT: 8: inst78000185
// CHECK:STDOUT: inst_block7800008C:
// CHECK:STDOUT: 0: instF
// CHECK:STDOUT: 1: inst78000010
@@ -92,7 +92,7 @@ library "[[@TEST_NAME]]";
class Circle {
private var radius: i32;
fn GetRadius[self: Self]() -> i32 {
fn GetRadius(self) -> i32 {
return self.radius;
}
@@ -100,7 +100,7 @@ class Circle {
return 0;
}
fn Compute[self: Self]() -> i32 {
fn Compute(self) -> i32 {
return self.SomeInternalFunction();
}
}
@@ -25,7 +25,7 @@ base class Shape {
class Circle {
extend base: Shape;
fn GetPosition[self: Self]() -> (i32, i32) {
fn GetPosition(self) -> (i32, i32) {
return (self.x, self.y);
}
}
@@ -45,7 +45,7 @@ base class B {
base class C {
extend base: B;
fn G[self: Self]() -> () { return self.F(); }
fn G(self) -> () { return self.F(); }
}
// --- inherited_member_access.carbon
@@ -82,7 +82,7 @@ base class Shape {
class Square {
extend base: Shape;
fn GetPosition[self: Self]() -> i32 {
fn GetPosition(self) -> i32 {
// CHECK:STDERR: fail_inherited_private_field_access.carbon:[[@LINE+7]]:12: error: cannot access private member `y` of type `Shape` [ClassInvalidMemberAccess]
// CHECK:STDERR: return self.y;
// CHECK:STDERR: ^~~~~~
@@ -233,7 +233,7 @@ class B {
return A.SOME_PROTECTED_CONSTANT;
}
fn SomeFunc[self: Self]() -> i32{
fn SomeFunc(self) -> i32{
// CHECK:STDERR: fail_non_inherited_access.carbon:[[@LINE+7]]:12: error: cannot access protected member `INTERNAL_CONSTANT` of type `Internal` [ClassInvalidMemberAccess]
// CHECK:STDERR: return self.internal.INTERNAL_CONSTANT;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -255,7 +255,7 @@ base class A {
class B {
extend base: A;
fn F[self: Self]() {
fn F(self) {
// CHECK:STDERR: fail_compound_member_access.carbon:[[@LINE+7]]:11: error: cannot access private member `x` of type `A` [ClassInvalidMemberAccess]
// CHECK:STDERR: self.(A.x);
// CHECK:STDERR: ^~~
@@ -278,11 +278,12 @@ base class A {
class B {
extend base: A;
fn F[self: Self]() {
fn F(self) {
self.(A.x);
}
}
// CHECK:STDOUT: --- instance_protected_field_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -362,13 +363,13 @@ class B {
// CHECK:STDOUT: %self.param_patt: %pattern_type.f70 = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: %pattern_type.f70 = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.394 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.394 = return_slot_pattern %return.param_patt, %.loc12_44.2 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.394 = return_slot_pattern %return.param_patt, %.loc12_36.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32.loc12_36: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %i32.loc12_41: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc12_44.1: %tuple.type.24b = tuple_literal (%i32.loc12_36, %i32.loc12_41) [concrete = constants.%tuple.b59]
// CHECK:STDOUT: %.loc12_44.2: type = converted %.loc12_44.1, constants.%tuple.type.e55 [concrete = constants.%tuple.type.e55]
// CHECK:STDOUT: %.loc12_44.3: Core.Form = init_form %.loc12_44.2 [concrete = constants.%.c11]
// CHECK:STDOUT: %i32.loc12_28: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %i32.loc12_33: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc12_36.1: %tuple.type.24b = tuple_literal (%i32.loc12_28, %i32.loc12_33) [concrete = constants.%tuple.b59]
// CHECK:STDOUT: %.loc12_36.2: type = converted %.loc12_36.1, constants.%tuple.type.e55 [concrete = constants.%tuple.type.e55]
// CHECK:STDOUT: %.loc12_36.3: Core.Form = init_form %.loc12_36.2 [concrete = constants.%.c11]
// CHECK:STDOUT: %self.param: %Circle = value_param call_param0
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Circle [concrete = constants.%Circle]
// CHECK:STDOUT: %self: %Circle = value_binding self, %self.param
@@ -517,11 +518,11 @@ class B {
// CHECK:STDOUT: %self.param_patt: %pattern_type.98b = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: %pattern_type.98b = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern %return.param_patt, %.loc15_26.2 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern %return.param_patt, %.loc15_18.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc15_26.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc15_26.2: type = converted %.loc15_26.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc15_26.3: Core.Form = init_form %.loc15_26.2 [concrete = constants.%.262]
// CHECK:STDOUT: %.loc15_18.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc15_18.2: type = converted %.loc15_18.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc15_18.3: Core.Form = init_form %.loc15_18.2 [concrete = constants.%.262]
// CHECK:STDOUT: %self.param: %C = value_param call_param0
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
// CHECK:STDOUT: %self: %C = value_binding self, %self.param
+1 -1
View File
@@ -15,7 +15,7 @@
// --- fail_multiple_bindings.carbon
class X {
fn F[self: Self]();
fn F(self);
}
fn G(x: X) {
+4 -4
View File
@@ -24,7 +24,7 @@ class SomeClass {
fn StaticMemberFunction();
fn AdapterMethod[self: SomeClassAdapter]();
fn AdapterMethod(self: SomeClassAdapter);
}
class SomeClassAdapter {
@@ -44,7 +44,7 @@ fn TestAdapterMethod(a: SomeClassAdapter) {
library "[[@TEST_NAME]]";
class SomeClass {
fn F[self: Self]();
fn F(self);
}
class SomeClassAdapter {
@@ -59,8 +59,8 @@ fn F(a: SomeClassAdapter) {
// CHECK:STDERR: a.F();
// CHECK:STDERR: ^
// CHECK:STDERR: fail_todo_method_access.carbon:[[@LINE-14]]:8: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn F[self: Self]();
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fn F(self);
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
a.F();
}
@@ -11,13 +11,13 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/adapter/fail_adapt_with_base.carbon
class Simple {};
base class AdaptWithVirtual {
virtual fn F[self: Self]();
virtual fn F(self);
// CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE+7]]:3: error: adapter with virtual function [AdaptWithVirtual]
// CHECK:STDERR: adapt Simple;
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR: fail_adapt_with_base.carbon:[[@LINE-4]]:3: note: first virtual function declaration is here [AdaptWithVirtualHere]
// CHECK:STDERR: virtual fn F[self: Self]();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: virtual fn F(self);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
adapt Simple;
}
+11 -8
View File
@@ -88,6 +88,7 @@ fn F(template T:! type) {
fn G() { F({}); }
// CHECK:STDOUT: --- implicit_return.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -456,11 +457,11 @@ fn G() { F({}); }
// CHECK:STDOUT: %pattern_type: type = pattern_type %C.loc7_20.2 [template = %pattern_type (constants.%pattern_type.ebe)]
// CHECK:STDOUT: %C.val: @F.%C.loc7_20.2 (%C.1d0) = struct_value () [template = %C.val (constants.%C.val.d4f)]
// CHECK:STDOUT: %Destroy.lookup_impl_witness: <witness> = lookup_impl_witness %C.loc7_20.2, @Destroy [template = %Destroy.lookup_impl_witness (constants.%Destroy.lookup_impl_witness)]
// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %C.loc7_20.2, (%Destroy.lookup_impl_witness) [template = %Destroy.facet (constants.%Destroy.facet.19f)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet) [template = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.fc4)]
// CHECK:STDOUT: %.loc7_3.2: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet [template = %.loc7_3.2 (constants.%.cb3)]
// CHECK:STDOUT: %impl.elem0.loc7_3.2: @F.%.loc7_3.2 (%.cb3) = impl_witness_access %Destroy.lookup_impl_witness, element0 [template = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2: <specific function> = specific_impl_function %impl.elem0.loc7_3.2, @Destroy.WithSelf.Op(%Destroy.facet) [template = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Destroy.facet.loc7_3.2: %Destroy.type = facet_value %C.loc7_20.2, (%Destroy.lookup_impl_witness) [template = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.19f)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc7_3.2) [template = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.fc4)]
// CHECK:STDOUT: %.loc7_3.3: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc7_3.2 [template = %.loc7_3.3 (constants.%.cb3)]
// CHECK:STDOUT: %impl.elem0.loc7_3.2: @F.%.loc7_3.3 (%.cb3) = impl_witness_access %Destroy.lookup_impl_witness, element0 [template = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2: <specific function> = specific_impl_function %impl.elem0.loc7_3.2, @Destroy.WithSelf.Op(%Destroy.facet.loc7_3.2) [template = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
@@ -479,8 +480,10 @@ fn G() { F({}); }
// CHECK:STDOUT: %C.loc7_20.1: type = class_type @C, @C(constants.%T) [template = %C.loc7_20.2 (constants.%C.1d0)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v: ref @F.%C.loc7_20.2 (%C.1d0) = ref_binding v, %v.var
// CHECK:STDOUT: %impl.elem0.loc7_3.1: @F.%.loc7_3.2 (%.cb3) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [template = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %impl.elem0.loc7_3.1: @F.%.loc7_3.3 (%.cb3) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [template = %impl.elem0.loc7_3.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %v.var, %impl.elem0.loc7_3.1
// CHECK:STDOUT: %Destroy.facet.loc7_3.1: %Destroy.type = facet_value constants.%C.1d0, (constants.%Destroy.lookup_impl_witness) [template = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.19f)]
// CHECK:STDOUT: %.loc7_3.2: %Destroy.type = converted constants.%C.1d0, %Destroy.facet.loc7_3.1 [template = %Destroy.facet.loc7_3.2 (constants.%Destroy.facet.19f)]
// CHECK:STDOUT: %specific_impl_fn.loc7_3.1: <specific function> = specific_impl_function %impl.elem0.loc7_3.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.19f) [template = %specific_impl_fn.loc7_3.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %v.var, %specific_impl_fn.loc7_3.1
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call %bound_method.loc7_3.2(%v.var)
@@ -508,9 +511,9 @@ fn G() { F({}); }
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.2fd
// CHECK:STDOUT: %C.val => constants.%C.val.58e
// CHECK:STDOUT: %Destroy.lookup_impl_witness => constants.%custom_witness.df9cc1.2
// CHECK:STDOUT: %Destroy.facet => constants.%Destroy.facet.da3
// CHECK:STDOUT: %Destroy.facet.loc7_3.2 => constants.%Destroy.facet.da3
// CHECK:STDOUT: %Destroy.WithSelf.Op.type => constants.%Destroy.WithSelf.Op.type.294
// CHECK:STDOUT: %.loc7_3.2 => constants.%.98c
// CHECK:STDOUT: %.loc7_3.3 => constants.%.98c
// CHECK:STDOUT: %impl.elem0.loc7_3.2 => constants.%Destroy.Op.1a2547.2
// CHECK:STDOUT: %specific_impl_fn.loc7_3.2 => constants.%Destroy.Op.1a2547.2
// CHECK:STDOUT: }
+1 -1
View File
@@ -18,7 +18,7 @@
// CHECK:STDERR:
fn F(unused N:! error_not_found) {
base class C {
virtual fn Foo[unused self: Self]() {}
virtual fn Foo(unused self) {}
}
base class D {
@@ -11,7 +11,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_memaccess_category.carbon
class A {
fn F[ref self: A]();
fn F(ref self: A);
}
class B {
@@ -24,7 +24,7 @@ fn F(s: {.a: A}, b: B) {
// CHECK:STDERR: s.a.F();
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-12]]:8: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn F[ref self: A]();
// CHECK:STDERR: fn F(ref self: A);
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
s.a.F();
@@ -35,7 +35,7 @@ fn F(s: {.a: A}, b: B) {
// CHECK:STDERR: b.a.F();
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_memaccess_category.carbon:[[@LINE-23]]:8: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn F[ref self: A]();
// CHECK:STDERR: fn F(ref self: A);
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR:
b.a.F();
+9 -9
View File
@@ -85,16 +85,16 @@ abstract protected class WrongOrder { }
abstract base class AbstractAndBase {}
abstract class AbstractWithDefinition {
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:38: error: definition of `abstract` function [DefinedAbstractFunction]
// CHECK:STDERR: abstract fn F[unused self: Self]() {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:30: error: definition of `abstract` function [DefinedAbstractFunction]
// CHECK:STDERR: abstract fn F(unused self) {}
// CHECK:STDERR: ^
// CHECK:STDERR:
abstract fn F[unused self: Self]() {}
abstract fn G[self: Self]();
abstract fn F(unused self) {}
abstract fn G(self);
}
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:50: error: definition of `abstract` function [DefinedAbstractFunction]
// CHECK:STDERR: fn AbstractWithDefinition.G[unused self: Self]() {
// CHECK:STDERR: ^
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:42: error: definition of `abstract` function [DefinedAbstractFunction]
// CHECK:STDERR: fn AbstractWithDefinition.G(unused self) {
// CHECK:STDERR: ^
// CHECK:STDERR:
fn AbstractWithDefinition.G[unused self: Self]() {
fn AbstractWithDefinition.G(unused self) {
}
+74 -70
View File
@@ -16,11 +16,11 @@ library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
class Class(T:! Core.Copy) {
fn GetAddr[ref self: Self]() -> T* {
fn GetAddr(ref self) -> T* {
return &self.k;
}
fn GetValue[self: Self]() -> T {
fn GetValue(self) -> T {
return self.k;
}
@@ -30,6 +30,7 @@ class Class(T:! Core.Copy) {
class Declaration(T:! type);
//@dump-sem-ir-end
// CHECK:STDOUT: --- basic.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -124,43 +125,43 @@ class Declaration(T:! type);
// CHECK:STDOUT:
// CHECK:STDOUT: class {
// CHECK:STDOUT: %Class.GetAddr.decl: @Class.%Class.GetAddr.type (%Class.GetAddr.type) = fn_decl @Class.GetAddr [symbolic = @Class.%Class.GetAddr (constants.%Class.GetAddr)] {
// CHECK:STDOUT: %self.param_patt: @Class.GetAddr.%pattern_type.loc6_22 (%pattern_type.e18) = ref_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.GetAddr.%pattern_type.loc6_22 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.GetAddr.%pattern_type.loc6_36 (%pattern_type.d5b) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.GetAddr.%pattern_type.loc6_36 (%pattern_type.d5b) = return_slot_pattern %return.param_patt, %ptr.loc6_36.2 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.GetAddr.%pattern_type.loc6_18 (%pattern_type.e18) = ref_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.GetAddr.%pattern_type.loc6_18 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.GetAddr.%pattern_type.loc6_28 (%pattern_type.d5b) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.GetAddr.%pattern_type.loc6_28 (%pattern_type.d5b) = return_slot_pattern %return.param_patt, %ptr.loc6_28.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref: %Copy.type = name_ref T, @Class.%T.loc5_14.2 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %T.as_type.loc6_36.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc6_36.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc6_36.2: type = converted %T.ref, %T.as_type.loc6_36.2 [symbolic = %T.as_type.loc6_36.1 (constants.%T.as_type)]
// CHECK:STDOUT: %ptr.loc6_36.2: type = ptr_type %.loc6_36.2 [symbolic = %ptr.loc6_36.1 (constants.%ptr.215)]
// CHECK:STDOUT: %.loc6_36.3: Core.Form = init_form %ptr.loc6_36.2 [symbolic = %.loc6_36.1 (constants.%.4fb)]
// CHECK:STDOUT: %T.as_type.loc6_28.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc6_28.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc6_28.2: type = converted %T.ref, %T.as_type.loc6_28.2 [symbolic = %T.as_type.loc6_28.1 (constants.%T.as_type)]
// CHECK:STDOUT: %ptr.loc6_28.2: type = ptr_type %.loc6_28.2 [symbolic = %ptr.loc6_28.1 (constants.%ptr.215)]
// CHECK:STDOUT: %.loc6_28.3: Core.Form = init_form %ptr.loc6_28.2 [symbolic = %.loc6_28.1 (constants.%.4fb)]
// CHECK:STDOUT: %self.param: ref @Class.GetAddr.%Class (%Class) = ref_param call_param0
// CHECK:STDOUT: %.loc6_24.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc6_24.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6_24.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc6_18.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc6_18.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6_18.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: ref @Class.GetAddr.%Class (%Class) = ref_binding self, %self.param
// CHECK:STDOUT: %return.param: ref @Class.GetAddr.%ptr.loc6_36.1 (%ptr.215) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.GetAddr.%ptr.loc6_36.1 (%ptr.215) = return_slot %return.param
// CHECK:STDOUT: %return.param: ref @Class.GetAddr.%ptr.loc6_28.1 (%ptr.215) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.GetAddr.%ptr.loc6_28.1 (%ptr.215) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.GetValue.decl: @Class.%Class.GetValue.type (%Class.GetValue.type) = fn_decl @Class.GetValue [symbolic = @Class.%Class.GetValue (constants.%Class.GetValue)] {
// CHECK:STDOUT: %self.param_patt: @Class.GetValue.%pattern_type.loc10_19 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.GetValue.%pattern_type.loc10_19 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.GetValue.%pattern_type.loc10_32 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.GetValue.%pattern_type.loc10_32 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc10_32.3 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.GetValue.%pattern_type.loc10_15 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.GetValue.%pattern_type.loc10_15 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.GetValue.%pattern_type.loc10_24 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.GetValue.%pattern_type.loc10_24 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc10_24.3 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref: %Copy.type = name_ref T, @Class.%T.loc5_14.2 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %T.as_type.loc10_32.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc10_32.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_32.3: type = converted %T.ref, %T.as_type.loc10_32.2 [symbolic = %T.as_type.loc10_32.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_32.4: Core.Form = init_form %.loc10_32.3 [symbolic = %.loc10_32.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %T.as_type.loc10_24.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc10_24.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_24.3: type = converted %T.ref, %T.as_type.loc10_24.2 [symbolic = %T.as_type.loc10_24.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_24.4: Core.Form = init_form %.loc10_24.3 [symbolic = %.loc10_24.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %self.param: @Class.GetValue.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc10_21.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc10_21.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc10_21.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc10_15.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc10_15.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc10_15.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: @Class.GetValue.%Class (%Class) = value_binding self, %self.param
// CHECK:STDOUT: %return.param: ref @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) = return_slot %return.param
// CHECK:STDOUT: %return.param: ref @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc14: @Class.%Class.elem (%Class.elem) = field_decl k, element0 [concrete]
// CHECK:STDOUT: %complete_type.loc15_1.1: <witness> = complete_type_witness constants.%struct_type.k [symbolic = %complete_type.loc15_1.2 (constants.%complete_type)]
@@ -184,35 +185,37 @@ class Declaration(T:! type);
// CHECK:STDOUT: generic fn @Class.GetAddr(@Class.%T.loc5_14.2: %Copy.type) {
// CHECK:STDOUT: %T: %Copy.type = symbolic_binding T, 0 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %pattern_type.loc6_22: type = pattern_type %Class [symbolic = %pattern_type.loc6_22 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc6_36.1: type = facet_access_type %T [symbolic = %T.as_type.loc6_36.1 (constants.%T.as_type)]
// CHECK:STDOUT: %ptr.loc6_36.1: type = ptr_type %T.as_type.loc6_36.1 [symbolic = %ptr.loc6_36.1 (constants.%ptr.215)]
// CHECK:STDOUT: %.loc6_36.1: Core.Form = init_form %ptr.loc6_36.1 [symbolic = %.loc6_36.1 (constants.%.4fb)]
// CHECK:STDOUT: %pattern_type.loc6_36: type = pattern_type %ptr.loc6_36.1 [symbolic = %pattern_type.loc6_36 (constants.%pattern_type.d5b)]
// CHECK:STDOUT: %pattern_type.loc6_18: type = pattern_type %Class [symbolic = %pattern_type.loc6_18 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc6_28.1: type = facet_access_type %T [symbolic = %T.as_type.loc6_28.1 (constants.%T.as_type)]
// CHECK:STDOUT: %ptr.loc6_28.1: type = ptr_type %T.as_type.loc6_28.1 [symbolic = %ptr.loc6_28.1 (constants.%ptr.215)]
// CHECK:STDOUT: %.loc6_28.1: Core.Form = init_form %ptr.loc6_28.1 [symbolic = %.loc6_28.1 (constants.%.4fb)]
// CHECK:STDOUT: %pattern_type.loc6_28: type = pattern_type %ptr.loc6_28.1 [symbolic = %pattern_type.loc6_28 (constants.%pattern_type.d5b)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc6_22: <witness> = require_complete_type %Class [symbolic = %require_complete.loc6_22 (constants.%require_complete.1dd)]
// CHECK:STDOUT: %require_complete.loc6_32: <witness> = require_complete_type %ptr.loc6_36.1 [symbolic = %require_complete.loc6_32 (constants.%require_complete.94b)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc6_36.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %.loc7_12.1: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%T.as_type.loc6_36.1) [symbolic = %.loc7_12.1 (constants.%.a33)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %ptr.loc6_36.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.cf6)]
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %ptr.loc6_36.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.6e0)]
// CHECK:STDOUT: %.loc7_12.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet [symbolic = %.loc7_12.2 (constants.%.45d)]
// CHECK:STDOUT: %impl.elem0.loc7_12.2: @Class.GetAddr.%.loc7_12.2 (%.45d) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %specific_impl_fn.loc7_12.2: <specific function> = specific_impl_function %impl.elem0.loc7_12.2, @Copy.WithSelf.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc7_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT: %require_complete.loc6_18: <witness> = require_complete_type %Class [symbolic = %require_complete.loc6_18 (constants.%require_complete.1dd)]
// CHECK:STDOUT: %require_complete.loc6_24: <witness> = require_complete_type %ptr.loc6_28.1 [symbolic = %require_complete.loc6_24 (constants.%require_complete.94b)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc6_28.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %.loc7_12.2: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%T.as_type.loc6_28.1) [symbolic = %.loc7_12.2 (constants.%.a33)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %ptr.loc6_28.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.cf6)]
// CHECK:STDOUT: %Copy.facet.loc7_12.2: %Copy.type = facet_value %ptr.loc6_28.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet.loc7_12.2 (constants.%Copy.facet)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.loc7_12.2) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.6e0)]
// CHECK:STDOUT: %.loc7_12.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet.loc7_12.2 [symbolic = %.loc7_12.3 (constants.%.45d)]
// CHECK:STDOUT: %impl.elem0.loc7_12.2: @Class.GetAddr.%.loc7_12.3 (%.45d) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %specific_impl_fn.loc7_12.2: <specific function> = specific_impl_function %impl.elem0.loc7_12.2, @Copy.WithSelf.Op(%Copy.facet.loc7_12.2) [symbolic = %specific_impl_fn.loc7_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: ref @Class.GetAddr.%Class (%Class)) -> out %return.param: @Class.GetAddr.%ptr.loc6_36.1 (%ptr.215) {
// CHECK:STDOUT: fn(%self.param: ref @Class.GetAddr.%Class (%Class)) -> out %return.param: @Class.GetAddr.%ptr.loc6_28.1 (%ptr.215) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: ref @Class.GetAddr.%Class (%Class) = name_ref self, %self
// CHECK:STDOUT: %k.ref: @Class.GetAddr.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc14 [concrete = @Class.%.loc14]
// CHECK:STDOUT: %.loc7_17: ref @Class.GetAddr.%T.as_type.loc6_36.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %addr: @Class.GetAddr.%ptr.loc6_36.1 (%ptr.215) = addr_of %.loc7_17
// CHECK:STDOUT: %impl.elem0.loc7_12.1: @Class.GetAddr.%.loc7_12.2 (%.45d) = impl_witness_access constants.%Copy.lookup_impl_witness.cf6, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %.loc7_17: ref @Class.GetAddr.%T.as_type.loc6_28.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %addr: @Class.GetAddr.%ptr.loc6_28.1 (%ptr.215) = addr_of %.loc7_17
// CHECK:STDOUT: %impl.elem0.loc7_12.1: @Class.GetAddr.%.loc7_12.3 (%.45d) = impl_witness_access constants.%Copy.lookup_impl_witness.cf6, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %bound_method.loc7_12.1: <bound method> = bound_method %addr, %impl.elem0.loc7_12.1
// CHECK:STDOUT: %Copy.facet.loc7_12.1: %Copy.type = facet_value constants.%ptr.215, (constants.%Copy.lookup_impl_witness.cf6) [symbolic = %Copy.facet.loc7_12.2 (constants.%Copy.facet)]
// CHECK:STDOUT: %.loc7_12.1: %Copy.type = converted constants.%ptr.215, %Copy.facet.loc7_12.1 [symbolic = %Copy.facet.loc7_12.2 (constants.%Copy.facet)]
// CHECK:STDOUT: %specific_impl_fn.loc7_12.1: <specific function> = specific_impl_function %impl.elem0.loc7_12.1, @Copy.WithSelf.Op(constants.%Copy.facet) [symbolic = %specific_impl_fn.loc7_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT: %bound_method.loc7_12.2: <bound method> = bound_method %addr, %specific_impl_fn.loc7_12.1
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetAddr.%ptr.loc6_36.1 (%ptr.215) = call %bound_method.loc7_12.2(%addr)
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetAddr.%ptr.loc6_28.1 (%ptr.215) = call %bound_method.loc7_12.2(%addr)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -220,33 +223,34 @@ class Declaration(T:! type);
// CHECK:STDOUT: generic fn @Class.GetValue(@Class.%T.loc5_14.2: %Copy.type) {
// CHECK:STDOUT: %T: %Copy.type = symbolic_binding T, 0 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %pattern_type.loc10_19: type = pattern_type %Class [symbolic = %pattern_type.loc10_19 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc10_32.1: type = facet_access_type %T [symbolic = %T.as_type.loc10_32.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_32.2: Core.Form = init_form %T.as_type.loc10_32.1 [symbolic = %.loc10_32.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc10_32: type = pattern_type %T.as_type.loc10_32.1 [symbolic = %pattern_type.loc10_32 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT: %pattern_type.loc10_15: type = pattern_type %Class [symbolic = %pattern_type.loc10_15 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc10_24.1: type = facet_access_type %T [symbolic = %T.as_type.loc10_24.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_24.2: Core.Form = init_form %T.as_type.loc10_24.1 [symbolic = %.loc10_24.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc10_24: type = pattern_type %T.as_type.loc10_24.1 [symbolic = %pattern_type.loc10_24 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Class [symbolic = %require_complete.loc10 (constants.%require_complete.1dd)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc10_32.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc11: <witness> = require_complete_type %T.as_type.loc10_32.1 [symbolic = %require_complete.loc11 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc10_24.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc11: <witness> = require_complete_type %T.as_type.loc10_24.1 [symbolic = %require_complete.loc11 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc11_16.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc11_16.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc11_16.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc11_16.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc11_16.2: @Class.GetValue.%.loc11_16.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc11_16.2: @Class.GetValue.%.loc11_16.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc11_16.2: <specific function> = specific_impl_function %impl.elem0.loc11_16.2, @Copy.WithSelf.Op(%T) [symbolic = %specific_impl_fn.loc11_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @Class.GetValue.%Class (%Class)) -> out %return.param: @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) {
// CHECK:STDOUT: fn(%self.param: @Class.GetValue.%Class (%Class)) -> out %return.param: @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @Class.GetValue.%Class (%Class) = name_ref self, %self
// CHECK:STDOUT: %k.ref: @Class.GetValue.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc14 [concrete = @Class.%.loc14]
// CHECK:STDOUT: %.loc11_16.1: ref @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc11_16.2: @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) = acquire_value %.loc11_16.1
// CHECK:STDOUT: %impl.elem0.loc11_16.1: @Class.GetValue.%.loc11_16.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %.loc11_16.1: ref @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc11_16.2: @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) = acquire_value %.loc11_16.1
// CHECK:STDOUT: %impl.elem0.loc11_16.1: @Class.GetValue.%.loc11_16.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc11_16.1: <bound method> = bound_method %.loc11_16.2, %impl.elem0.loc11_16.1
// CHECK:STDOUT: %.loc11_16.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc11_16.1: <specific function> = specific_impl_function %impl.elem0.loc11_16.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc11_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc11_16.2: <bound method> = bound_method %.loc11_16.2, %specific_impl_fn.loc11_16.1
// CHECK:STDOUT: %.loc10_32.1: ref @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) = splice_block %return.param {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetValue.%T.as_type.loc10_32.1 (%T.as_type) to %.loc10_32.1 = call %bound_method.loc11_16.2(%.loc11_16.2)
// CHECK:STDOUT: %.loc10_24.1: ref @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) = splice_block %return.param {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetValue.%T.as_type.loc10_24.1 (%T.as_type) to %.loc10_24.1 = call %bound_method.loc11_16.2(%.loc11_16.2)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -270,20 +274,20 @@ class Declaration(T:! type);
// CHECK:STDOUT: specific @Class.GetAddr(constants.%T.f84) {
// CHECK:STDOUT: %T => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %pattern_type.loc6_22 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc6_36.1 => constants.%T.as_type
// CHECK:STDOUT: %ptr.loc6_36.1 => constants.%ptr.215
// CHECK:STDOUT: %.loc6_36.1 => constants.%.4fb
// CHECK:STDOUT: %pattern_type.loc6_36 => constants.%pattern_type.d5b
// CHECK:STDOUT: %pattern_type.loc6_18 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc6_28.1 => constants.%T.as_type
// CHECK:STDOUT: %ptr.loc6_28.1 => constants.%ptr.215
// CHECK:STDOUT: %.loc6_28.1 => constants.%.4fb
// CHECK:STDOUT: %pattern_type.loc6_28 => constants.%pattern_type.d5b
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.GetValue(constants.%T.f84) {
// CHECK:STDOUT: %T => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %pattern_type.loc10_19 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc10_32.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc10_32.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc10_32 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: %pattern_type.loc10_15 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc10_24.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc10_24.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc10_24 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Declaration(constants.%T.67d) {
+9 -6
View File
@@ -32,6 +32,7 @@ fn H(U:! Core.Copy, c: Class(U)) -> U {
}
//@dump-sem-ir-end
// CHECK:STDOUT: --- field.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -261,9 +262,9 @@ fn H(U:! Core.Copy, c: Class(U)) -> U {
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class.loc13_31.1, %T.as_type.loc13_31.1 [symbolic = %Class.elem (constants.%Class.elem.14b853.1)]
// CHECK:STDOUT: %require_complete.loc14: <witness> = require_complete_type %T.as_type.loc13_31.1 [symbolic = %require_complete.loc14 (constants.%require_complete.d83f06.1)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc13_7.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc14_11.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc13_7.1 [symbolic = %.loc14_11.3 (constants.%.c29330.1)]
// CHECK:STDOUT: %.loc14_11.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc13_7.1 [symbolic = %.loc14_11.4 (constants.%.c29330.1)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc13_7.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c332.1)]
// CHECK:STDOUT: %impl.elem0.loc14_11.2: @G.%.loc14_11.3 (%.c29330.1) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc14_11.2 (constants.%impl.elem0.bd2456.1)]
// CHECK:STDOUT: %impl.elem0.loc14_11.2: @G.%.loc14_11.4 (%.c29330.1) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc14_11.2 (constants.%impl.elem0.bd2456.1)]
// CHECK:STDOUT: %specific_impl_fn.loc14_11.2: <specific function> = specific_impl_function %impl.elem0.loc14_11.2, @Copy.WithSelf.Op(%T.loc13_7.1) [symbolic = %specific_impl_fn.loc14_11.2 (constants.%specific_impl_fn.e2af7e.1)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%c.param: @G.%Class.loc13_31.1 (%Class.c74ef3.1)) -> out %return.param: @G.%T.as_type.loc13_31.1 (%T.as_type) {
@@ -272,8 +273,9 @@ fn H(U:! Core.Copy, c: Class(U)) -> U {
// CHECK:STDOUT: %x.ref: @G.%Class.elem (%Class.elem.14b853.1) = name_ref x, @Class.%.loc6 [concrete = @Class.%.loc6]
// CHECK:STDOUT: %.loc14_11.1: ref @G.%T.as_type.loc13_31.1 (%T.as_type) = class_element_access %c.ref, element0
// CHECK:STDOUT: %.loc14_11.2: @G.%T.as_type.loc13_31.1 (%T.as_type) = acquire_value %.loc14_11.1
// CHECK:STDOUT: %impl.elem0.loc14_11.1: @G.%.loc14_11.3 (%.c29330.1) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c332.1, element0 [symbolic = %impl.elem0.loc14_11.2 (constants.%impl.elem0.bd2456.1)]
// CHECK:STDOUT: %impl.elem0.loc14_11.1: @G.%.loc14_11.4 (%.c29330.1) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c332.1, element0 [symbolic = %impl.elem0.loc14_11.2 (constants.%impl.elem0.bd2456.1)]
// CHECK:STDOUT: %bound_method.loc14_11.1: <bound method> = bound_method %.loc14_11.2, %impl.elem0.loc14_11.1
// CHECK:STDOUT: %.loc14_11.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc13_7.1 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc14_11.1: <specific function> = specific_impl_function %impl.elem0.loc14_11.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc14_11.2 (constants.%specific_impl_fn.e2af7e.1)]
// CHECK:STDOUT: %bound_method.loc14_11.2: <bound method> = bound_method %.loc14_11.2, %specific_impl_fn.loc14_11.1
// CHECK:STDOUT: %.loc13_37.1: ref @G.%T.as_type.loc13_31.1 (%T.as_type) = splice_block %return.param {}
@@ -295,9 +297,9 @@ fn H(U:! Core.Copy, c: Class(U)) -> U {
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class.loc17_31.1, %U.as_type.loc17_31.1 [symbolic = %Class.elem (constants.%Class.elem.14b853.2)]
// CHECK:STDOUT: %require_complete.loc18: <witness> = require_complete_type %U.as_type.loc17_31.1 [symbolic = %require_complete.loc18 (constants.%require_complete.d83f06.2)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%U.loc17_7.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.3)]
// CHECK:STDOUT: %.loc18_11.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %U.loc17_7.1 [symbolic = %.loc18_11.3 (constants.%.c29330.2)]
// CHECK:STDOUT: %.loc18_11.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %U.loc17_7.1 [symbolic = %.loc18_11.4 (constants.%.c29330.2)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %U.loc17_7.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c332.2)]
// CHECK:STDOUT: %impl.elem0.loc18_11.2: @H.%.loc18_11.3 (%.c29330.2) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc18_11.2 (constants.%impl.elem0.bd2456.2)]
// CHECK:STDOUT: %impl.elem0.loc18_11.2: @H.%.loc18_11.4 (%.c29330.2) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc18_11.2 (constants.%impl.elem0.bd2456.2)]
// CHECK:STDOUT: %specific_impl_fn.loc18_11.2: <specific function> = specific_impl_function %impl.elem0.loc18_11.2, @Copy.WithSelf.Op(%U.loc17_7.1) [symbolic = %specific_impl_fn.loc18_11.2 (constants.%specific_impl_fn.e2af7e.2)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%c.param: @H.%Class.loc17_31.1 (%Class.c74ef3.2)) -> out %return.param: @H.%U.as_type.loc17_31.1 (%U.as_type.c1c) {
@@ -306,8 +308,9 @@ fn H(U:! Core.Copy, c: Class(U)) -> U {
// CHECK:STDOUT: %x.ref: @H.%Class.elem (%Class.elem.14b853.2) = name_ref x, @Class.%.loc6 [concrete = @Class.%.loc6]
// CHECK:STDOUT: %.loc18_11.1: ref @H.%U.as_type.loc17_31.1 (%U.as_type.c1c) = class_element_access %c.ref, element0
// CHECK:STDOUT: %.loc18_11.2: @H.%U.as_type.loc17_31.1 (%U.as_type.c1c) = acquire_value %.loc18_11.1
// CHECK:STDOUT: %impl.elem0.loc18_11.1: @H.%.loc18_11.3 (%.c29330.2) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c332.2, element0 [symbolic = %impl.elem0.loc18_11.2 (constants.%impl.elem0.bd2456.2)]
// CHECK:STDOUT: %impl.elem0.loc18_11.1: @H.%.loc18_11.4 (%.c29330.2) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c332.2, element0 [symbolic = %impl.elem0.loc18_11.2 (constants.%impl.elem0.bd2456.2)]
// CHECK:STDOUT: %bound_method.loc18_11.1: <bound method> = bound_method %.loc18_11.2, %impl.elem0.loc18_11.1
// CHECK:STDOUT: %.loc18_11.3: %Copy.type = converted constants.%U.as_type.c1c, constants.%U.f84 [symbolic = %U.loc17_7.1 (constants.%U.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc18_11.1: <specific function> = specific_impl_function %impl.elem0.loc18_11.1, @Copy.WithSelf.Op(constants.%U.f84) [symbolic = %specific_impl_fn.loc18_11.2 (constants.%specific_impl_fn.e2af7e.2)]
// CHECK:STDOUT: %bound_method.loc18_11.2: <bound method> = bound_method %.loc18_11.2, %specific_impl_fn.loc18_11.1
// CHECK:STDOUT: %.loc17_37.1: ref @H.%U.as_type.loc17_31.1 (%U.as_type.c1c) = splice_block %return.param {}
+24 -16
View File
@@ -48,6 +48,7 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
}
//@dump-sem-ir-end
// CHECK:STDOUT: --- from_struct.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -212,18 +213,18 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
// CHECK:STDOUT: %pattern_type.loc10: type = pattern_type %Class.loc10_17.2 [symbolic = %pattern_type.loc10 (constants.%pattern_type.0b6)]
// CHECK:STDOUT: %struct_type.k: type = struct_type {.k: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b)} [symbolic = %struct_type.k (constants.%struct_type.k.aa4)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_27.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.4df)]
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %T.as_type.loc9_59.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.090)]
// CHECK:STDOUT: %.loc10_27: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet [symbolic = %.loc10_27 (constants.%.018)]
// CHECK:STDOUT: %impl.elem0.loc10_27.2: @InitFromStructGeneric.%.loc10_27 (%.018) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %specific_impl_fn.loc10_27.2: <specific function> = specific_impl_function %impl.elem0.loc10_27.2, @Copy.WithSelf.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.be5)]
// CHECK:STDOUT: %Copy.facet.loc10_27.2: %Copy.type = facet_value %T.as_type.loc9_59.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet.loc10_27.2 (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.loc10_27.2) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.090)]
// CHECK:STDOUT: %.loc10_27.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet.loc10_27.2 [symbolic = %.loc10_27.2 (constants.%.018)]
// CHECK:STDOUT: %impl.elem0.loc10_27.2: @InitFromStructGeneric.%.loc10_27.2 (%.018) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %specific_impl_fn.loc10_27.2: <specific function> = specific_impl_function %impl.elem0.loc10_27.2, @Copy.WithSelf.Op(%Copy.facet.loc10_27.2) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.be5)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class.loc10_17.2, %T.as_type.loc9_59.1 [symbolic = %Class.elem (constants.%Class.elem.b97)]
// CHECK:STDOUT: %Destroy.lookup_impl_witness.loc10_3: <witness> = lookup_impl_witness %Class.loc10_17.2, @Destroy [symbolic = %Destroy.lookup_impl_witness.loc10_3 (constants.%Destroy.lookup_impl_witness.62e)]
// CHECK:STDOUT: %Destroy.facet.loc10_3: %Destroy.type = facet_value %Class.loc10_17.2, (%Destroy.lookup_impl_witness.loc10_3) [symbolic = %Destroy.facet.loc10_3 (constants.%Destroy.facet.25e)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc10_3) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.d76)]
// CHECK:STDOUT: %.loc10_3.2: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc10_3 [symbolic = %.loc10_3.2 (constants.%.0da)]
// CHECK:STDOUT: %impl.elem0.loc10_3.2: @InitFromStructGeneric.%.loc10_3.2 (%.0da) = impl_witness_access %Destroy.lookup_impl_witness.loc10_3, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.730)]
// CHECK:STDOUT: %specific_impl_fn.loc10_3.2: <specific function> = specific_impl_function %impl.elem0.loc10_3.2, @Destroy.WithSelf.Op(%Destroy.facet.loc10_3) [symbolic = %specific_impl_fn.loc10_3.2 (constants.%specific_impl_fn.fa9)]
// CHECK:STDOUT: %Destroy.facet.loc10_3.2: %Destroy.type = facet_value %Class.loc10_17.2, (%Destroy.lookup_impl_witness.loc10_3) [symbolic = %Destroy.facet.loc10_3.2 (constants.%Destroy.facet.25e)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc10_3.2) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.d76)]
// CHECK:STDOUT: %.loc10_3.3: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc10_3.2 [symbolic = %.loc10_3.3 (constants.%.0da)]
// CHECK:STDOUT: %impl.elem0.loc10_3.2: @InitFromStructGeneric.%.loc10_3.3 (%.0da) = impl_witness_access %Destroy.lookup_impl_witness.loc10_3, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.730)]
// CHECK:STDOUT: %specific_impl_fn.loc10_3.2: <specific function> = specific_impl_function %impl.elem0.loc10_3.2, @Destroy.WithSelf.Op(%Destroy.facet.loc10_3.2) [symbolic = %specific_impl_fn.loc10_3.2 (constants.%specific_impl_fn.fa9)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b)) -> out %return.param: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) {
// CHECK:STDOUT: !entry:
@@ -234,8 +235,10 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
// CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class.loc10_17.2 (%Class.55b) = var %v.var_patt
// CHECK:STDOUT: %x.ref: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) = name_ref x, %x
// CHECK:STDOUT: %.loc10_28.1: @InitFromStructGeneric.%struct_type.k (%struct_type.k.aa4) = struct_literal (%x.ref)
// CHECK:STDOUT: %impl.elem0.loc10_27.1: @InitFromStructGeneric.%.loc10_27 (%.018) = impl_witness_access constants.%Copy.lookup_impl_witness.4df, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %impl.elem0.loc10_27.1: @InitFromStructGeneric.%.loc10_27.2 (%.018) = impl_witness_access constants.%Copy.lookup_impl_witness.4df, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %bound_method.loc10_27.1: <bound method> = bound_method %x.ref, %impl.elem0.loc10_27.1
// CHECK:STDOUT: %Copy.facet.loc10_27.1: %Copy.type = facet_value constants.%T.as_type.74b, (constants.%Copy.lookup_impl_witness.4df) [symbolic = %Copy.facet.loc10_27.2 (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %.loc10_27.1: %Copy.type = converted constants.%T.as_type.74b, %Copy.facet.loc10_27.1 [symbolic = %Copy.facet.loc10_27.2 (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %specific_impl_fn.loc10_27.1: <specific function> = specific_impl_function %impl.elem0.loc10_27.1, @Copy.WithSelf.Op(constants.%Copy.facet.3f0) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.be5)]
// CHECK:STDOUT: %bound_method.loc10_27.2: <bound method> = bound_method %x.ref, %specific_impl_fn.loc10_27.1
// CHECK:STDOUT: %.loc10_28.2: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) = class_element_access %v.var, element0
@@ -257,14 +260,18 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
// CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%Class.elem (%Class.elem.b97) = name_ref k, @Class.%.loc5 [concrete = @Class.%.loc5]
// CHECK:STDOUT: %.loc11_11.1: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) = class_element_access %v.ref, element0
// CHECK:STDOUT: %.loc11_11.2: @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) = acquire_value %.loc11_11.1
// CHECK:STDOUT: %impl.elem0.loc11: @InitFromStructGeneric.%.loc10_27 (%.018) = impl_witness_access constants.%Copy.lookup_impl_witness.4df, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %impl.elem0.loc11: @InitFromStructGeneric.%.loc10_27.2 (%.018) = impl_witness_access constants.%Copy.lookup_impl_witness.4df, element0 [symbolic = %impl.elem0.loc10_27.2 (constants.%impl.elem0.170)]
// CHECK:STDOUT: %bound_method.loc11_11.1: <bound method> = bound_method %.loc11_11.2, %impl.elem0.loc11
// CHECK:STDOUT: %Copy.facet.loc11: %Copy.type = facet_value constants.%T.as_type.74b, (constants.%Copy.lookup_impl_witness.4df) [symbolic = %Copy.facet.loc10_27.2 (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %.loc11_11.3: %Copy.type = converted constants.%T.as_type.74b, %Copy.facet.loc11 [symbolic = %Copy.facet.loc10_27.2 (constants.%Copy.facet.3f0)]
// CHECK:STDOUT: %specific_impl_fn.loc11: <specific function> = specific_impl_function %impl.elem0.loc11, @Copy.WithSelf.Op(constants.%Copy.facet.3f0) [symbolic = %specific_impl_fn.loc10_27.2 (constants.%specific_impl_fn.be5)]
// CHECK:STDOUT: %bound_method.loc11_11.2: <bound method> = bound_method %.loc11_11.2, %specific_impl_fn.loc11
// CHECK:STDOUT: %.loc9_65.1: ref @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) = splice_block %return.param {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call.loc11: init @InitFromStructGeneric.%T.as_type.loc9_59.1 (%T.as_type.74b) to %.loc9_65.1 = call %bound_method.loc11_11.2(%.loc11_11.2)
// CHECK:STDOUT: %impl.elem0.loc10_3.1: @InitFromStructGeneric.%.loc10_3.2 (%.0da) = impl_witness_access constants.%Destroy.lookup_impl_witness.62e, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.730)]
// CHECK:STDOUT: %impl.elem0.loc10_3.1: @InitFromStructGeneric.%.loc10_3.3 (%.0da) = impl_witness_access constants.%Destroy.lookup_impl_witness.62e, element0 [symbolic = %impl.elem0.loc10_3.2 (constants.%impl.elem0.730)]
// CHECK:STDOUT: %bound_method.loc10_3.1: <bound method> = bound_method %v.var, %impl.elem0.loc10_3.1
// CHECK:STDOUT: %Destroy.facet.loc10_3.1: %Destroy.type = facet_value constants.%Class.55b, (constants.%Destroy.lookup_impl_witness.62e) [symbolic = %Destroy.facet.loc10_3.2 (constants.%Destroy.facet.25e)]
// CHECK:STDOUT: %.loc10_3.2: %Destroy.type = converted constants.%Class.55b, %Destroy.facet.loc10_3.1 [symbolic = %Destroy.facet.loc10_3.2 (constants.%Destroy.facet.25e)]
// CHECK:STDOUT: %specific_impl_fn.loc10_3.1: <specific function> = specific_impl_function %impl.elem0.loc10_3.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.25e) [symbolic = %specific_impl_fn.loc10_3.2 (constants.%specific_impl_fn.fa9)]
// CHECK:STDOUT: %bound_method.loc10_3.2: <bound method> = bound_method %v.var, %specific_impl_fn.loc10_3.1
// CHECK:STDOUT: %Destroy.WithSelf.Op.call: init %empty_tuple.type = call %bound_method.loc10_3.2(%v.var)
@@ -449,9 +456,9 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
// CHECK:STDOUT: %Adapt.loc10_23.2: type = class_type @Adapt, @Adapt(%T.as_type.loc9_45.1) [symbolic = %Adapt.loc10_23.2 (constants.%Adapt.210)]
// CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Adapt.loc10_23.2 [symbolic = %require_complete.loc10 (constants.%require_complete.29a)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc9_28.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc10_26.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc9_28.1 [symbolic = %.loc10_26.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc10_26.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc9_28.1 [symbolic = %.loc10_26.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc9_28.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc10_26.2: @InitFromAdaptedGeneric.%.loc10_26.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc10_26.2: @InitFromAdaptedGeneric.%.loc10_26.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc10_26.2: <specific function> = specific_impl_function %impl.elem0.loc10_26.2, @Copy.WithSelf.Op(%T.loc9_28.1) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type)) -> out %return.param: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) {
@@ -469,8 +476,9 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 {
// CHECK:STDOUT: %.loc10_29: type = converted %T.ref.loc10_29, %T.as_type.loc10_29 [symbolic = %T.as_type.loc9_45.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_26.1: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = as_compatible %.loc10_13.2
// CHECK:STDOUT: %.loc10_26.2: @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = converted %.loc10_13.2, %.loc10_26.1
// CHECK:STDOUT: %impl.elem0.loc10_26.1: @InitFromAdaptedGeneric.%.loc10_26.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc10_26.1: @InitFromAdaptedGeneric.%.loc10_26.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc10_26.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc10_26.1: <bound method> = bound_method %.loc10_26.2, %impl.elem0.loc10_26.1
// CHECK:STDOUT: %.loc10_26.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc9_28.1 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc10_26.1: <specific function> = specific_impl_function %impl.elem0.loc10_26.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc10_26.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc10_26.2: <bound method> = bound_method %.loc10_26.2, %specific_impl_fn.loc10_26.1
// CHECK:STDOUT: %.loc9_51.1: ref @InitFromAdaptedGeneric.%T.as_type.loc9_45.1 (%T.as_type) = splice_block %return.param {}
+52 -48
View File
@@ -17,13 +17,13 @@ library "[[@TEST_NAME]]";
class Class(T:! Core.Copy) {
var x: T;
fn Get[self: Self]() -> T {
fn Get(self) -> T {
//@dump-sem-ir-begin
return self.x;
//@dump-sem-ir-end
}
fn GetAddr[ref self: Self]() -> T* {
fn GetAddr(ref self) -> T* {
//@dump-sem-ir-begin
return &self.x;
//@dump-sem-ir-end
@@ -62,6 +62,7 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
//@dump-sem-ir-end
}
// CHECK:STDOUT: --- member_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -171,26 +172,27 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc7_27.1 [symbolic = %Class.elem (constants.%Class.elem.1ee)]
// CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc7_27.1 [symbolic = %require_complete.loc9 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc7_19.1 [symbolic = %Class.elem (constants.%Class.elem.1ee)]
// CHECK:STDOUT: %require_complete.loc9: <witness> = require_complete_type %T.as_type.loc7_19.1 [symbolic = %require_complete.loc9 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc9_16.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc9_16.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc9_16.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc9_16.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc9_16.2: @Class.Get.%.loc9_16.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc9_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc9_16.2: @Class.Get.%.loc9_16.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc9_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc9_16.2: <specific function> = specific_impl_function %impl.elem0.loc9_16.2, @Copy.WithSelf.Op(%T) [symbolic = %specific_impl_fn.loc9_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @Class.Get.%Class (%Class.575)) -> out %return.param: @Class.Get.%T.as_type.loc7_27.1 (%T.as_type) {
// CHECK:STDOUT: fn(%self.param: @Class.Get.%Class (%Class.575)) -> out %return.param: @Class.Get.%T.as_type.loc7_19.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @Class.Get.%Class (%Class.575) = name_ref self, %self
// CHECK:STDOUT: %x.ref: @Class.Get.%Class.elem (%Class.elem.1ee) = name_ref x, @Class.%.loc5 [concrete = @Class.%.loc5]
// CHECK:STDOUT: %.loc9_16.1: ref @Class.Get.%T.as_type.loc7_27.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc9_16.2: @Class.Get.%T.as_type.loc7_27.1 (%T.as_type) = acquire_value %.loc9_16.1
// CHECK:STDOUT: %impl.elem0.loc9_16.1: @Class.Get.%.loc9_16.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc9_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %.loc9_16.1: ref @Class.Get.%T.as_type.loc7_19.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc9_16.2: @Class.Get.%T.as_type.loc7_19.1 (%T.as_type) = acquire_value %.loc9_16.1
// CHECK:STDOUT: %impl.elem0.loc9_16.1: @Class.Get.%.loc9_16.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc9_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc9_16.1: <bound method> = bound_method %.loc9_16.2, %impl.elem0.loc9_16.1
// CHECK:STDOUT: %.loc9_16.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc9_16.1: <specific function> = specific_impl_function %impl.elem0.loc9_16.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc9_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc9_16.2: <bound method> = bound_method %.loc9_16.2, %specific_impl_fn.loc9_16.1
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.Get.%T.as_type.loc7_27.1 (%T.as_type) to %.loc7_27.1 = call %bound_method.loc9_16.2(%.loc9_16.2)
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.Get.%T.as_type.loc7_19.1 (%T.as_type) to %.loc7_19.1 = call %bound_method.loc9_16.2(%.loc9_16.2)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -200,26 +202,28 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc13_36.1 [symbolic = %Class.elem (constants.%Class.elem.1ee)]
// CHECK:STDOUT: %.loc15_12.1: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%T.as_type.loc13_36.1) [symbolic = %.loc15_12.1 (constants.%.a33)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %ptr.loc13_36.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.cf6)]
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %ptr.loc13_36.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.ed3)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.6e0)]
// CHECK:STDOUT: %.loc15_12.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet [symbolic = %.loc15_12.2 (constants.%.45d)]
// CHECK:STDOUT: %impl.elem0.loc15_12.2: @Class.GetAddr.%.loc15_12.2 (%.45d) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %specific_impl_fn.loc15_12.2: <specific function> = specific_impl_function %impl.elem0.loc15_12.2, @Copy.WithSelf.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc15_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc13_28.1 [symbolic = %Class.elem (constants.%Class.elem.1ee)]
// CHECK:STDOUT: %.loc15_12.2: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%T.as_type.loc13_28.1) [symbolic = %.loc15_12.2 (constants.%.a33)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %ptr.loc13_28.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.cf6)]
// CHECK:STDOUT: %Copy.facet.loc15_12.2: %Copy.type = facet_value %ptr.loc13_28.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet.loc15_12.2 (constants.%Copy.facet.ed3)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.loc15_12.2) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.6e0)]
// CHECK:STDOUT: %.loc15_12.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet.loc15_12.2 [symbolic = %.loc15_12.3 (constants.%.45d)]
// CHECK:STDOUT: %impl.elem0.loc15_12.2: @Class.GetAddr.%.loc15_12.3 (%.45d) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %specific_impl_fn.loc15_12.2: <specific function> = specific_impl_function %impl.elem0.loc15_12.2, @Copy.WithSelf.Op(%Copy.facet.loc15_12.2) [symbolic = %specific_impl_fn.loc15_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: ref @Class.GetAddr.%Class (%Class.575)) -> out %return.param: @Class.GetAddr.%ptr.loc13_36.1 (%ptr.215) {
// CHECK:STDOUT: fn(%self.param: ref @Class.GetAddr.%Class (%Class.575)) -> out %return.param: @Class.GetAddr.%ptr.loc13_28.1 (%ptr.215) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: ref @Class.GetAddr.%Class (%Class.575) = name_ref self, %self
// CHECK:STDOUT: %x.ref: @Class.GetAddr.%Class.elem (%Class.elem.1ee) = name_ref x, @Class.%.loc5 [concrete = @Class.%.loc5]
// CHECK:STDOUT: %.loc15_17: ref @Class.GetAddr.%T.as_type.loc13_36.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %addr: @Class.GetAddr.%ptr.loc13_36.1 (%ptr.215) = addr_of %.loc15_17
// CHECK:STDOUT: %impl.elem0.loc15_12.1: @Class.GetAddr.%.loc15_12.2 (%.45d) = impl_witness_access constants.%Copy.lookup_impl_witness.cf6, element0 [symbolic = %impl.elem0.loc15_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %.loc15_17: ref @Class.GetAddr.%T.as_type.loc13_28.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %addr: @Class.GetAddr.%ptr.loc13_28.1 (%ptr.215) = addr_of %.loc15_17
// CHECK:STDOUT: %impl.elem0.loc15_12.1: @Class.GetAddr.%.loc15_12.3 (%.45d) = impl_witness_access constants.%Copy.lookup_impl_witness.cf6, element0 [symbolic = %impl.elem0.loc15_12.2 (constants.%impl.elem0.c5d)]
// CHECK:STDOUT: %bound_method.loc15_12.1: <bound method> = bound_method %addr, %impl.elem0.loc15_12.1
// CHECK:STDOUT: %Copy.facet.loc15_12.1: %Copy.type = facet_value constants.%ptr.215, (constants.%Copy.lookup_impl_witness.cf6) [symbolic = %Copy.facet.loc15_12.2 (constants.%Copy.facet.ed3)]
// CHECK:STDOUT: %.loc15_12.1: %Copy.type = converted constants.%ptr.215, %Copy.facet.loc15_12.1 [symbolic = %Copy.facet.loc15_12.2 (constants.%Copy.facet.ed3)]
// CHECK:STDOUT: %specific_impl_fn.loc15_12.1: <specific function> = specific_impl_function %impl.elem0.loc15_12.1, @Copy.WithSelf.Op(constants.%Copy.facet.ed3) [symbolic = %specific_impl_fn.loc15_12.2 (constants.%specific_impl_fn.5cf)]
// CHECK:STDOUT: %bound_method.loc15_12.2: <bound method> = bound_method %addr, %specific_impl_fn.loc15_12.1
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetAddr.%ptr.loc13_36.1 (%ptr.215) = call %bound_method.loc15_12.2(%addr)
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.GetAddr.%ptr.loc13_28.1 (%ptr.215) = call %bound_method.loc15_12.2(%addr)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -291,20 +295,20 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
// CHECK:STDOUT: specific @Class.Get(constants.%T.f84) {
// CHECK:STDOUT: %T => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class.575
// CHECK:STDOUT: %pattern_type.loc7_14 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc7_27.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc7_27.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc7_27 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: %pattern_type.loc7_10 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc7_19.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc7_19.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc7_19 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.GetAddr(constants.%T.f84) {
// CHECK:STDOUT: %T => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class.575
// CHECK:STDOUT: %pattern_type.loc13_22 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc13_36.1 => constants.%T.as_type
// CHECK:STDOUT: %ptr.loc13_36.1 => constants.%ptr.215
// CHECK:STDOUT: %.loc13_36.1 => constants.%.4fb
// CHECK:STDOUT: %pattern_type.loc13_36 => constants.%pattern_type.d5b
// CHECK:STDOUT: %pattern_type.loc13_18 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc13_28.1 => constants.%T.as_type
// CHECK:STDOUT: %ptr.loc13_28.1 => constants.%ptr.215
// CHECK:STDOUT: %.loc13_28.1 => constants.%.4fb
// CHECK:STDOUT: %pattern_type.loc13_28 => constants.%pattern_type.d5b
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class(constants.%Copy.facet.987) {
@@ -326,17 +330,17 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
// CHECK:STDOUT: specific @Class.Get(constants.%Copy.facet.987) {
// CHECK:STDOUT: %T => constants.%Copy.facet.987
// CHECK:STDOUT: %Class => constants.%Class.ce6
// CHECK:STDOUT: %pattern_type.loc7_14 => constants.%pattern_type.658
// CHECK:STDOUT: %T.as_type.loc7_27.1 => constants.%i32
// CHECK:STDOUT: %.loc7_27.2 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc7_27 => constants.%pattern_type.6b6
// CHECK:STDOUT: %pattern_type.loc7_10 => constants.%pattern_type.658
// CHECK:STDOUT: %T.as_type.loc7_19.1 => constants.%i32
// CHECK:STDOUT: %.loc7_19.2 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc7_19 => constants.%pattern_type.6b6
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc7 => constants.%complete_type.0c6
// CHECK:STDOUT: %Class.elem => constants.%Class.elem.32a
// CHECK:STDOUT: %require_complete.loc9 => constants.%complete_type.f8a
// CHECK:STDOUT: %Copy.WithSelf.Op.type => constants.%Copy.WithSelf.Op.type.d09
// CHECK:STDOUT: %.loc9_16.3 => constants.%.7a6
// CHECK:STDOUT: %.loc9_16.4 => constants.%.7a6
// CHECK:STDOUT: %Copy.lookup_impl_witness => constants.%Copy.impl_witness.0e0
// CHECK:STDOUT: %impl.elem0.loc9_16.2 => constants.%Int.as.Copy.impl.Op.4f6
// CHECK:STDOUT: %specific_impl_fn.loc9_16.2 => constants.%Int.as.Copy.impl.Op.specific_fn
@@ -345,21 +349,21 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) {
// CHECK:STDOUT: specific @Class.GetAddr(constants.%Copy.facet.987) {
// CHECK:STDOUT: %T => constants.%Copy.facet.987
// CHECK:STDOUT: %Class => constants.%Class.ce6
// CHECK:STDOUT: %pattern_type.loc13_22 => constants.%pattern_type.658
// CHECK:STDOUT: %T.as_type.loc13_36.1 => constants.%i32
// CHECK:STDOUT: %ptr.loc13_36.1 => constants.%ptr.d08
// CHECK:STDOUT: %.loc13_36.1 => constants.%.952
// CHECK:STDOUT: %pattern_type.loc13_36 => constants.%pattern_type.f00
// CHECK:STDOUT: %pattern_type.loc13_18 => constants.%pattern_type.658
// CHECK:STDOUT: %T.as_type.loc13_28.1 => constants.%i32
// CHECK:STDOUT: %ptr.loc13_28.1 => constants.%ptr.d08
// CHECK:STDOUT: %.loc13_28.1 => constants.%.952
// CHECK:STDOUT: %pattern_type.loc13_28 => constants.%pattern_type.f00
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc13_22 => constants.%complete_type.0c6
// CHECK:STDOUT: %require_complete.loc13_32 => constants.%complete_type.07f
// CHECK:STDOUT: %require_complete.loc13_18 => constants.%complete_type.0c6
// CHECK:STDOUT: %require_complete.loc13_24 => constants.%complete_type.07f
// CHECK:STDOUT: %Class.elem => constants.%Class.elem.32a
// CHECK:STDOUT: %.loc15_12.1 => constants.%.c00
// CHECK:STDOUT: %.loc15_12.2 => constants.%.c00
// CHECK:STDOUT: %Copy.lookup_impl_witness => constants.%Copy.impl_witness.ce1
// CHECK:STDOUT: %Copy.facet => constants.%Copy.facet.b49
// CHECK:STDOUT: %Copy.facet.loc15_12.2 => constants.%Copy.facet.b49
// CHECK:STDOUT: %Copy.WithSelf.Op.type => constants.%Copy.WithSelf.Op.type.f9d
// CHECK:STDOUT: %.loc15_12.2 => constants.%.ac9
// CHECK:STDOUT: %.loc15_12.3 => constants.%.ac9
// CHECK:STDOUT: %impl.elem0.loc15_12.2 => constants.%ptr.as.Copy.impl.Op.d1c
// CHECK:STDOUT: %specific_impl_fn.loc15_12.2 => constants.%ptr.as.Copy.impl.Op.specific_fn
// CHECK:STDOUT: }
+37 -34
View File
@@ -20,7 +20,7 @@ class Class(T:! Core.Copy) {
return n;
}
fn G[self: Self]() -> T {
fn G(self) -> T {
return self.n;
}
@@ -45,6 +45,7 @@ class C(T:! Core.Copy) {
}
//@dump-sem-ir-end
// CHECK:STDOUT: --- member_inline.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -135,23 +136,23 @@ class C(T:! Core.Copy) {
// CHECK:STDOUT: %return: ref @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.G.decl: @Class.%Class.G.type (%Class.G.type) = fn_decl @Class.G [symbolic = @Class.%Class.G (constants.%Class.G)] {
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc10_12 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc10_12 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc10_25 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc10_25 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc10_25.3 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc10_8 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc10_8 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc10_17 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc10_17 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc10_17.3 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref: %Copy.type = name_ref T, @Class.%T.loc5_14.2 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %T.as_type.loc10_25.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc10_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_25.3: type = converted %T.ref, %T.as_type.loc10_25.2 [symbolic = %T.as_type.loc10_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_25.4: Core.Form = init_form %.loc10_25.3 [symbolic = %.loc10_25.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %T.as_type.loc10_17.2: type = facet_access_type %T.ref [symbolic = %T.as_type.loc10_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_17.3: type = converted %T.ref, %T.as_type.loc10_17.2 [symbolic = %T.as_type.loc10_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_17.4: Core.Form = init_form %.loc10_17.3 [symbolic = %.loc10_17.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %self.param: @Class.G.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc10_14.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc10_14.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc10_14.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc10_8.1: type = splice_block %Self.ref [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc10_8.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc10_8.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: @Class.G.%Class (%Class) = value_binding self, %self.param
// CHECK:STDOUT: %return.param: ref @Class.G.%T.as_type.loc10_25.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.G.%T.as_type.loc10_25.1 (%T.as_type) = return_slot %return.param
// CHECK:STDOUT: %return.param: ref @Class.G.%T.as_type.loc10_17.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.G.%T.as_type.loc10_17.1 (%T.as_type) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc14: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [concrete]
// CHECK:STDOUT: %complete_type.loc15_1.1: <witness> = complete_type_witness constants.%struct_type.n [symbolic = %complete_type.loc15_1.2 (constants.%complete_type)]
@@ -175,16 +176,17 @@ class C(T:! Core.Copy) {
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type.loc6_11.1 [symbolic = %require_complete (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc7: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc7 (constants.%.c29)]
// CHECK:STDOUT: %.loc7_12.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc7_12.2 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc7_12.2: @Class.F.%.loc7 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc7_12.2: @Class.F.%.loc7_12.2 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc7_12.2: <specific function> = specific_impl_function %impl.elem0.loc7_12.2, @Copy.WithSelf.Op(%T) [symbolic = %specific_impl_fn.loc7_12.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%n.param: @Class.F.%T.as_type.loc6_11.1 (%T.as_type)) -> out %return.param: @Class.F.%T.as_type.loc6_11.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %n.ref: @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = name_ref n, %n
// CHECK:STDOUT: %impl.elem0.loc7_12.1: @Class.F.%.loc7 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc7_12.1: @Class.F.%.loc7_12.2 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc7_12.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc7_12.1: <bound method> = bound_method %n.ref, %impl.elem0.loc7_12.1
// CHECK:STDOUT: %.loc7_12.1: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc7_12.1: <specific function> = specific_impl_function %impl.elem0.loc7_12.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc7_12.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc7_12.2: <bound method> = bound_method %n.ref, %specific_impl_fn.loc7_12.1
// CHECK:STDOUT: %.loc6_17.1: ref @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = splice_block %return.param {}
@@ -196,33 +198,34 @@ class C(T:! Core.Copy) {
// CHECK:STDOUT: generic fn @Class.G(@Class.%T.loc5_14.2: %Copy.type) {
// CHECK:STDOUT: %T: %Copy.type = symbolic_binding T, 0 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %pattern_type.loc10_12: type = pattern_type %Class [symbolic = %pattern_type.loc10_12 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc10_25.1: type = facet_access_type %T [symbolic = %T.as_type.loc10_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_25.2: Core.Form = init_form %T.as_type.loc10_25.1 [symbolic = %.loc10_25.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc10_25: type = pattern_type %T.as_type.loc10_25.1 [symbolic = %pattern_type.loc10_25 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT: %pattern_type.loc10_8: type = pattern_type %Class [symbolic = %pattern_type.loc10_8 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc10_17.1: type = facet_access_type %T [symbolic = %T.as_type.loc10_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc10_17.2: Core.Form = init_form %T.as_type.loc10_17.1 [symbolic = %.loc10_17.2 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc10_17: type = pattern_type %T.as_type.loc10_17.1 [symbolic = %pattern_type.loc10_17 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc10: <witness> = require_complete_type %Class [symbolic = %require_complete.loc10 (constants.%require_complete.1dd)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc10_25.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc11: <witness> = require_complete_type %T.as_type.loc10_25.1 [symbolic = %require_complete.loc11 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc10_17.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc11: <witness> = require_complete_type %T.as_type.loc10_17.1 [symbolic = %require_complete.loc11 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc11_16.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc11_16.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc11_16.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc11_16.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc11_16.2: @Class.G.%.loc11_16.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc11_16.2: @Class.G.%.loc11_16.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc11_16.2: <specific function> = specific_impl_function %impl.elem0.loc11_16.2, @Copy.WithSelf.Op(%T) [symbolic = %specific_impl_fn.loc11_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @Class.G.%Class (%Class)) -> out %return.param: @Class.G.%T.as_type.loc10_25.1 (%T.as_type) {
// CHECK:STDOUT: fn(%self.param: @Class.G.%Class (%Class)) -> out %return.param: @Class.G.%T.as_type.loc10_17.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @Class.G.%Class (%Class) = name_ref self, %self
// CHECK:STDOUT: %n.ref: @Class.G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc14 [concrete = @Class.%.loc14]
// CHECK:STDOUT: %.loc11_16.1: ref @Class.G.%T.as_type.loc10_25.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc11_16.2: @Class.G.%T.as_type.loc10_25.1 (%T.as_type) = acquire_value %.loc11_16.1
// CHECK:STDOUT: %impl.elem0.loc11_16.1: @Class.G.%.loc11_16.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %.loc11_16.1: ref @Class.G.%T.as_type.loc10_17.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc11_16.2: @Class.G.%T.as_type.loc10_17.1 (%T.as_type) = acquire_value %.loc11_16.1
// CHECK:STDOUT: %impl.elem0.loc11_16.1: @Class.G.%.loc11_16.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc11_16.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc11_16.1: <bound method> = bound_method %.loc11_16.2, %impl.elem0.loc11_16.1
// CHECK:STDOUT: %.loc11_16.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc11_16.1: <specific function> = specific_impl_function %impl.elem0.loc11_16.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc11_16.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc11_16.2: <bound method> = bound_method %.loc11_16.2, %specific_impl_fn.loc11_16.1
// CHECK:STDOUT: %.loc10_25.1: ref @Class.G.%T.as_type.loc10_25.1 (%T.as_type) = splice_block %return.param {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.G.%T.as_type.loc10_25.1 (%T.as_type) to %.loc10_25.1 = call %bound_method.loc11_16.2(%.loc11_16.2)
// CHECK:STDOUT: %.loc10_17.1: ref @Class.G.%T.as_type.loc10_17.1 (%T.as_type) = splice_block %return.param {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.G.%T.as_type.loc10_17.1 (%T.as_type) to %.loc10_17.1 = call %bound_method.loc11_16.2(%.loc11_16.2)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -253,10 +256,10 @@ class C(T:! Core.Copy) {
// CHECK:STDOUT: specific @Class.G(constants.%T.f84) {
// CHECK:STDOUT: %T => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %pattern_type.loc10_12 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc10_25.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc10_25.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc10_25 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: %pattern_type.loc10_8 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc10_17.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc10_17.2 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc10_17 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_member_inline_missing_self_dot.carbon
@@ -76,6 +76,7 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
return x.nonesuch;
}
// CHECK:STDOUT: --- member_access.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -106,9 +107,9 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
// CHECK:STDOUT: %Derived.elem: type = unbound_element_type %Derived.loc13_45.1, %T.as_type.loc13_45.1 [symbolic = %Derived.elem (constants.%Derived.elem.eb3)]
// CHECK:STDOUT: %require_complete.loc15: <witness> = require_complete_type %T.as_type.loc13_45.1 [symbolic = %require_complete.loc15 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc13_19.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc15_11.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc13_19.1 [symbolic = %.loc15_11.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc15_11.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc13_19.1 [symbolic = %.loc15_11.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc13_19.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc15_11.2: @AccessDerived.%.loc15_11.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc15_11.2: @AccessDerived.%.loc15_11.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc15_11.2: <specific function> = specific_impl_function %impl.elem0.loc15_11.2, @Copy.WithSelf.Op(%T.loc13_19.1) [symbolic = %specific_impl_fn.loc15_11.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @AccessDerived.%Derived.loc13_45.1 (%Derived.e87)) -> out %return.param: @AccessDerived.%T.as_type.loc13_45.1 (%T.as_type) {
@@ -117,8 +118,9 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
// CHECK:STDOUT: %d.ref: @AccessDerived.%Derived.elem (%Derived.elem.eb3) = name_ref d, @Derived.%.loc10 [concrete = @Derived.%.loc10]
// CHECK:STDOUT: %.loc15_11.1: ref @AccessDerived.%T.as_type.loc13_45.1 (%T.as_type) = class_element_access %x.ref, element1
// CHECK:STDOUT: %.loc15_11.2: @AccessDerived.%T.as_type.loc13_45.1 (%T.as_type) = acquire_value %.loc15_11.1
// CHECK:STDOUT: %impl.elem0.loc15_11.1: @AccessDerived.%.loc15_11.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc15_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc15_11.1: @AccessDerived.%.loc15_11.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc15_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc15_11.1: <bound method> = bound_method %.loc15_11.2, %impl.elem0.loc15_11.1
// CHECK:STDOUT: %.loc15_11.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc13_19.1 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc15_11.1: <specific function> = specific_impl_function %impl.elem0.loc15_11.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc15_11.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc15_11.2: <bound method> = bound_method %.loc15_11.2, %specific_impl_fn.loc15_11.1
// CHECK:STDOUT: <elided>
@@ -137,9 +139,9 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
// CHECK:STDOUT: %require_complete.loc21_11: <witness> = require_complete_type %Base [symbolic = %require_complete.loc21_11 (constants.%require_complete.0fb)]
// CHECK:STDOUT: %require_complete.loc21_13: <witness> = require_complete_type %T.as_type.loc19_42.1 [symbolic = %require_complete.loc21_13 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc19_16.1) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc21_11.5: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc19_16.1 [symbolic = %.loc21_11.5 (constants.%.c29)]
// CHECK:STDOUT: %.loc21_11.6: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc19_16.1 [symbolic = %.loc21_11.6 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc19_16.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc21_11.2: @AccessBase.%.loc21_11.5 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc21_11.2: @AccessBase.%.loc21_11.6 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc21_11.2: <specific function> = specific_impl_function %impl.elem0.loc21_11.2, @Copy.WithSelf.Op(%T.loc19_16.1) [symbolic = %specific_impl_fn.loc21_11.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%x.param: @AccessBase.%Derived.loc19_42.1 (%Derived.e87)) -> out %return.param: @AccessBase.%T.as_type.loc19_42.1 (%T.as_type) {
@@ -150,8 +152,9 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
// CHECK:STDOUT: %.loc21_11.2: ref @AccessBase.%Base (%Base.146) = converted %x.ref, %.loc21_11.1
// CHECK:STDOUT: %.loc21_11.3: ref @AccessBase.%T.as_type.loc19_42.1 (%T.as_type) = class_element_access %.loc21_11.2, element0
// CHECK:STDOUT: %.loc21_11.4: @AccessBase.%T.as_type.loc19_42.1 (%T.as_type) = acquire_value %.loc21_11.3
// CHECK:STDOUT: %impl.elem0.loc21_11.1: @AccessBase.%.loc21_11.5 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc21_11.1: @AccessBase.%.loc21_11.6 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc21_11.1: <bound method> = bound_method %.loc21_11.4, %impl.elem0.loc21_11.1
// CHECK:STDOUT: %.loc21_11.5: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc19_16.1 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc21_11.1: <specific function> = specific_impl_function %impl.elem0.loc21_11.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc21_11.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc21_11.2: <bound method> = bound_method %.loc21_11.4, %specific_impl_fn.loc21_11.1
// CHECK:STDOUT: <elided>
@@ -17,7 +17,7 @@ library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
class Class(T:! Core.Copy) {
fn F(n: T) -> T;
fn G[self: Self]() -> T;
fn G(self) -> T;
var n: T;
}
@@ -25,7 +25,7 @@ fn Class(T:! Core.Copy).F(n: T) -> T {
return n;
}
fn Class(T:! Core.Copy).G[self: Self]() -> T {
fn Class(T:! Core.Copy).G(self) -> T {
return self.n;
}
//@dump-sem-ir-end
@@ -37,11 +37,11 @@ library "[[@TEST_NAME]]";
//@dump-sem-ir-begin
class A(T:! type) {
class B(_:! T) {
fn F[self: Self](a: T);
fn F(self, a: T);
}
}
fn A(T:! type).B(_:! T).F[unused self: Self](unused a: T) {}
fn A(T:! type).B(_:! T).F(unused self, unused a: T) {}
//@dump-sem-ir-end
// --- fail_mismatched_not_generic_vs_generic.carbon
@@ -112,6 +112,7 @@ class Generic(unused T:! type) {
// CHECK:STDERR:
fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: --- basic.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -190,10 +191,10 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: %return.loc11: ref @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = return_slot %return.param.loc11
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.G.decl: %Class.G.type = fn_decl @Class.G [symbolic = constants.%Class.G] {
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc7_12 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc7_12 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc7_25 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc7_25 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc15_44.2 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc7_8 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc7_8 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc7_17 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc7_17 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc15_36.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc15_18: type = splice_block %Copy.ref [concrete = constants.%Copy.type] {
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
@@ -202,17 +203,17 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: }
// CHECK:STDOUT: %T.loc15: %Copy.type = symbolic_binding T, 0 [symbolic = @Class.%T.loc5_14.1 (constants.%T.f84)]
// CHECK:STDOUT: %T.ref.loc15: %Copy.type = name_ref T, %T.loc15 [symbolic = %T.loc7 (constants.%T.f84)]
// CHECK:STDOUT: %T.as_type.loc15: type = facet_access_type %T.ref.loc15 [symbolic = %T.as_type.loc7_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc15_44.2: type = converted %T.ref.loc15, %T.as_type.loc15 [symbolic = %T.as_type.loc7_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc15_44.3: Core.Form = init_form %.loc15_44.2 [symbolic = %.loc7_25.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %T.as_type.loc15: type = facet_access_type %T.ref.loc15 [symbolic = %T.as_type.loc7_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc15_36.2: type = converted %T.ref.loc15, %T.as_type.loc15 [symbolic = %T.as_type.loc7_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc15_36.3: Core.Form = init_form %.loc15_36.2 [symbolic = %.loc7_17.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %self.param.loc15: @Class.G.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc15_33.1: type = splice_block %Self.ref.loc15 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc15_33.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc15: type = name_ref Self, %.loc15_33.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc15_27.1: type = splice_block %Self.ref.loc15 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc15_27.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc15: type = name_ref Self, %.loc15_27.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc15: @Class.G.%Class (%Class) = value_binding self, %self.param.loc15
// CHECK:STDOUT: %return.param.loc15: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return.loc15: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = return_slot %return.param.loc15
// CHECK:STDOUT: %return.param.loc15: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return.loc15: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = return_slot %return.param.loc15
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -253,23 +254,23 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: %return.loc6: ref @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = return_slot %return.param.loc6
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.G.decl: @Class.%Class.G.type (%Class.G.type) = fn_decl @Class.G [symbolic = @Class.%Class.G (constants.%Class.G)] {
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc7_12 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc7_12 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc7_25 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc7_25 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc15_44.2 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.G.%pattern_type.loc7_8 (%pattern_type.e18) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.G.%pattern_type.loc7_8 (%pattern_type.e18) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.G.%pattern_type.loc7_17 (%pattern_type.2c66b4.2) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.G.%pattern_type.loc7_17 (%pattern_type.2c66b4.2) = return_slot_pattern %return.param_patt, %.loc15_36.2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref.loc7: %Copy.type = name_ref T, @Class.%T.loc5_14.2 [symbolic = %T.loc7 (constants.%T.f84)]
// CHECK:STDOUT: %T.as_type.loc7_25.2: type = facet_access_type %T.ref.loc7 [symbolic = %T.as_type.loc7_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_25.2: type = converted %T.ref.loc7, %T.as_type.loc7_25.2 [symbolic = %T.as_type.loc7_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_25.3: Core.Form = init_form %.loc7_25.2 [symbolic = %.loc7_25.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %T.as_type.loc7_17.2: type = facet_access_type %T.ref.loc7 [symbolic = %T.as_type.loc7_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_17.2: type = converted %T.ref.loc7, %T.as_type.loc7_17.2 [symbolic = %T.as_type.loc7_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_17.3: Core.Form = init_form %.loc7_17.2 [symbolic = %.loc7_17.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %self.param.loc7: @Class.G.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc7_14.1: type = splice_block %Self.ref.loc7 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc7_14.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc7: type = name_ref Self, %.loc7_14.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc7_8.1: type = splice_block %Self.ref.loc7 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc7_8.2: type = specific_constant constants.%Class, @Class(constants.%T.f84) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc7: type = name_ref Self, %.loc7_8.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc7: @Class.G.%Class (%Class) = value_binding self, %self.param.loc7
// CHECK:STDOUT: %return.param.loc7: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return.loc7: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = return_slot %return.param.loc7
// CHECK:STDOUT: %return.param.loc7: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = out_param call_param1
// CHECK:STDOUT: %return.loc7: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = return_slot %return.param.loc7
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc8: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [concrete]
// CHECK:STDOUT: %complete_type.loc9_1.1: <witness> = complete_type_witness constants.%struct_type.n [symbolic = %complete_type.loc9_1.2 (constants.%complete_type)]
@@ -293,16 +294,17 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T.as_type.loc6_11.1 [symbolic = %require_complete (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc6) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc12: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc6 [symbolic = %.loc12 (constants.%.c29)]
// CHECK:STDOUT: %.loc12_10.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc6 [symbolic = %.loc12_10.2 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc6, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc12_10.2: @Class.F.%.loc12 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc12_10.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc12_10.2: @Class.F.%.loc12_10.2 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc12_10.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc12_10.2: <specific function> = specific_impl_function %impl.elem0.loc12_10.2, @Copy.WithSelf.Op(%T.loc6) [symbolic = %specific_impl_fn.loc12_10.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%n.param.loc11: @Class.F.%T.as_type.loc6_11.1 (%T.as_type)) -> out %return.param.loc11: @Class.F.%T.as_type.loc6_11.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %n.ref: @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = name_ref n, %n.loc11
// CHECK:STDOUT: %impl.elem0.loc12_10.1: @Class.F.%.loc12 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc12_10.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc12_10.1: @Class.F.%.loc12_10.2 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc12_10.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc12_10.1: <bound method> = bound_method %n.ref, %impl.elem0.loc12_10.1
// CHECK:STDOUT: %.loc12_10.1: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc6 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc12_10.1: <specific function> = specific_impl_function %impl.elem0.loc12_10.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc12_10.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc12_10.2: <bound method> = bound_method %n.ref, %specific_impl_fn.loc12_10.1
// CHECK:STDOUT: %.loc11_36.1: ref @Class.F.%T.as_type.loc6_11.1 (%T.as_type) = splice_block %return.param.loc11 {}
@@ -314,33 +316,34 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: generic fn @Class.G(@Class.%T.loc5_14.2: %Copy.type) {
// CHECK:STDOUT: %T.loc7: %Copy.type = symbolic_binding T, 0 [symbolic = %T.loc7 (constants.%T.f84)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.loc7) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %pattern_type.loc7_12: type = pattern_type %Class [symbolic = %pattern_type.loc7_12 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc7_25.1: type = facet_access_type %T.loc7 [symbolic = %T.as_type.loc7_25.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_25.1: Core.Form = init_form %T.as_type.loc7_25.1 [symbolic = %.loc7_25.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc7_25: type = pattern_type %T.as_type.loc7_25.1 [symbolic = %pattern_type.loc7_25 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT: %pattern_type.loc7_8: type = pattern_type %Class [symbolic = %pattern_type.loc7_8 (constants.%pattern_type.e18)]
// CHECK:STDOUT: %T.as_type.loc7_17.1: type = facet_access_type %T.loc7 [symbolic = %T.as_type.loc7_17.1 (constants.%T.as_type)]
// CHECK:STDOUT: %.loc7_17.1: Core.Form = init_form %T.as_type.loc7_17.1 [symbolic = %.loc7_17.1 (constants.%.1ce700.2)]
// CHECK:STDOUT: %pattern_type.loc7_17: type = pattern_type %T.as_type.loc7_17.1 [symbolic = %pattern_type.loc7_17 (constants.%pattern_type.2c66b4.2)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc15: <witness> = require_complete_type %Class [symbolic = %require_complete.loc15 (constants.%require_complete.1dd)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc7_25.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc16: <witness> = require_complete_type %T.as_type.loc7_25.1 [symbolic = %require_complete.loc16 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T.as_type.loc7_17.1 [symbolic = %Class.elem (constants.%Class.elem)]
// CHECK:STDOUT: %require_complete.loc16: <witness> = require_complete_type %T.as_type.loc7_17.1 [symbolic = %require_complete.loc16 (constants.%require_complete.d83)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T.loc7) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc16_14.3: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc7 [symbolic = %.loc16_14.3 (constants.%.c29)]
// CHECK:STDOUT: %.loc16_14.4: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T.loc7 [symbolic = %.loc16_14.4 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc7, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc16_14.2: @Class.G.%.loc16_14.3 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc16_14.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc16_14.2: @Class.G.%.loc16_14.4 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc16_14.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc16_14.2: <specific function> = specific_impl_function %impl.elem0.loc16_14.2, @Copy.WithSelf.Op(%T.loc7) [symbolic = %specific_impl_fn.loc16_14.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param.loc15: @Class.G.%Class (%Class)) -> out %return.param.loc15: @Class.G.%T.as_type.loc7_25.1 (%T.as_type) {
// CHECK:STDOUT: fn(%self.param.loc15: @Class.G.%Class (%Class)) -> out %return.param.loc15: @Class.G.%T.as_type.loc7_17.1 (%T.as_type) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @Class.G.%Class (%Class) = name_ref self, %self.loc15
// CHECK:STDOUT: %n.ref: @Class.G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc8 [concrete = @Class.%.loc8]
// CHECK:STDOUT: %.loc16_14.1: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc16_14.2: @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = acquire_value %.loc16_14.1
// CHECK:STDOUT: %impl.elem0.loc16_14.1: @Class.G.%.loc16_14.3 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc16_14.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %.loc16_14.1: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc16_14.2: @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = acquire_value %.loc16_14.1
// CHECK:STDOUT: %impl.elem0.loc16_14.1: @Class.G.%.loc16_14.4 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc16_14.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc16_14.1: <bound method> = bound_method %.loc16_14.2, %impl.elem0.loc16_14.1
// CHECK:STDOUT: %.loc16_14.3: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T.loc7 (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc16_14.1: <specific function> = specific_impl_function %impl.elem0.loc16_14.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc16_14.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc16_14.2: <bound method> = bound_method %.loc16_14.2, %specific_impl_fn.loc16_14.1
// CHECK:STDOUT: %.loc15_44.1: ref @Class.G.%T.as_type.loc7_25.1 (%T.as_type) = splice_block %return.param.loc15 {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.G.%T.as_type.loc7_25.1 (%T.as_type) to %.loc15_44.1 = call %bound_method.loc16_14.2(%.loc16_14.2)
// CHECK:STDOUT: %.loc15_36.1: ref @Class.G.%T.as_type.loc7_17.1 (%T.as_type) = splice_block %return.param.loc15 {}
// CHECK:STDOUT: %Copy.WithSelf.Op.call: init @Class.G.%T.as_type.loc7_17.1 (%T.as_type) to %.loc15_36.1 = call %bound_method.loc16_14.2(%.loc16_14.2)
// CHECK:STDOUT: return %Copy.WithSelf.Op.call to %return.param.loc15
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -371,10 +374,10 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: specific @Class.G(constants.%T.f84) {
// CHECK:STDOUT: %T.loc7 => constants.%T.f84
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %pattern_type.loc7_12 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc7_25.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc7_25.1 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc7_25 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: %pattern_type.loc7_8 => constants.%pattern_type.e18
// CHECK:STDOUT: %T.as_type.loc7_17.1 => constants.%T.as_type
// CHECK:STDOUT: %.loc7_17.1 => constants.%.1ce700.2
// CHECK:STDOUT: %pattern_type.loc7_17 => constants.%pattern_type.2c66b4.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- nested.carbon
@@ -412,10 +415,10 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: %T.loc5_10.2: type = symbolic_binding T, 0 [symbolic = %T.loc5_10.1 (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %B.F.decl: %B.F.type = fn_decl @B.F [symbolic = constants.%B.F] {
// CHECK:STDOUT: %self.param_patt: @B.F.%pattern_type.loc7_14 (%pattern_type.b16) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @B.F.%pattern_type.loc7_14 (%pattern_type.b16) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %a.param_patt: @B.F.%pattern_type.loc7_23 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %a.patt: @B.F.%pattern_type.loc7_23 (%pattern_type.51d) = at_binding_pattern a, %a.param_patt [concrete]
// CHECK:STDOUT: %self.param_patt: @B.F.%pattern_type.loc7_10 (%pattern_type.b16) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @B.F.%pattern_type.loc7_10 (%pattern_type.b16) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %a.param_patt: @B.F.%pattern_type.loc7_17 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %a.patt: @B.F.%pattern_type.loc7_17 (%pattern_type.51d) = at_binding_pattern a, %a.param_patt [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc11_10.1: type = splice_block %.loc11_10.2 [concrete = type] {
// CHECK:STDOUT: %.Self.loc11_7: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
@@ -428,13 +431,13 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: }
// CHECK:STDOUT: %_.loc11: @B.%T (%T) = symbolic_binding _, 1 [symbolic = @B.%_.loc6_12.1 (constants.%_)]
// CHECK:STDOUT: %self.param.loc11: @B.F.%B (%B) = value_param call_param0
// CHECK:STDOUT: %.loc11_40.1: type = splice_block %Self.ref.loc11 [symbolic = %B (constants.%B)] {
// CHECK:STDOUT: %.loc11_40.2: type = specific_constant constants.%B, @B(constants.%T, constants.%_) [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %Self.ref.loc11: type = name_ref Self, %.loc11_40.2 [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %.loc11_34.1: type = splice_block %Self.ref.loc11 [symbolic = %B (constants.%B)] {
// CHECK:STDOUT: %.loc11_34.2: type = specific_constant constants.%B, @B(constants.%T, constants.%_) [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %Self.ref.loc11: type = name_ref Self, %.loc11_34.2 [symbolic = %B (constants.%B)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc11: @B.F.%B (%B) = value_binding self, %self.param.loc11
// CHECK:STDOUT: %a.param.loc11: @B.F.%T.loc7 (%T) = value_param call_param1
// CHECK:STDOUT: %T.ref.loc11_56: type = name_ref T, %T.loc11 [symbolic = %T.loc7 (constants.%T)]
// CHECK:STDOUT: %T.ref.loc11_50: type = name_ref T, %T.loc11 [symbolic = %T.loc7 (constants.%T)]
// CHECK:STDOUT: %a.loc11: @B.F.%T.loc7 (%T) = value_binding a, %a.param.loc11
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -477,15 +480,15 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT:
// CHECK:STDOUT: class {
// CHECK:STDOUT: %B.F.decl: @B.%B.F.type (%B.F.type) = fn_decl @B.F [symbolic = @B.%B.F (constants.%B.F)] {
// CHECK:STDOUT: %self.param_patt: @B.F.%pattern_type.loc7_14 (%pattern_type.b16) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @B.F.%pattern_type.loc7_14 (%pattern_type.b16) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %a.param_patt: @B.F.%pattern_type.loc7_23 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %a.patt: @B.F.%pattern_type.loc7_23 (%pattern_type.51d) = at_binding_pattern a, %a.param_patt [concrete]
// CHECK:STDOUT: %self.param_patt: @B.F.%pattern_type.loc7_10 (%pattern_type.b16) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @B.F.%pattern_type.loc7_10 (%pattern_type.b16) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %a.param_patt: @B.F.%pattern_type.loc7_17 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %a.patt: @B.F.%pattern_type.loc7_17 (%pattern_type.51d) = at_binding_pattern a, %a.param_patt [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %self.param.loc7: @B.F.%B (%B) = value_param call_param0
// CHECK:STDOUT: %.loc7_16.1: type = splice_block %Self.ref.loc7 [symbolic = %B (constants.%B)] {
// CHECK:STDOUT: %.loc7_16.2: type = specific_constant constants.%B, @B(constants.%T, constants.%_) [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %Self.ref.loc7: type = name_ref Self, %.loc7_16.2 [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %.loc7_10.1: type = splice_block %Self.ref.loc7 [symbolic = %B (constants.%B)] {
// CHECK:STDOUT: %.loc7_10.2: type = specific_constant constants.%B, @B(constants.%T, constants.%_) [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %Self.ref.loc7: type = name_ref Self, %.loc7_10.2 [symbolic = %B (constants.%B)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc7: @B.F.%B (%B) = value_binding self, %self.param.loc7
// CHECK:STDOUT: %a.param.loc7: @B.F.%T.loc7 (%T) = value_param call_param1
@@ -506,12 +509,12 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: %T.loc7: type = symbolic_binding T, 0 [symbolic = %T.loc7 (constants.%T)]
// CHECK:STDOUT: %_.loc7: @B.F.%T.loc7 (%T) = symbolic_binding _, 1 [symbolic = %_.loc7 (constants.%_)]
// CHECK:STDOUT: %B: type = class_type @B, @B(%T.loc7, %_.loc7) [symbolic = %B (constants.%B)]
// CHECK:STDOUT: %pattern_type.loc7_14: type = pattern_type %B [symbolic = %pattern_type.loc7_14 (constants.%pattern_type.b16)]
// CHECK:STDOUT: %pattern_type.loc7_23: type = pattern_type %T.loc7 [symbolic = %pattern_type.loc7_23 (constants.%pattern_type.51d)]
// CHECK:STDOUT: %pattern_type.loc7_10: type = pattern_type %B [symbolic = %pattern_type.loc7_10 (constants.%pattern_type.b16)]
// CHECK:STDOUT: %pattern_type.loc7_17: type = pattern_type %T.loc7 [symbolic = %pattern_type.loc7_17 (constants.%pattern_type.51d)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc11_38: <witness> = require_complete_type %B [symbolic = %require_complete.loc11_38 (constants.%require_complete.0e8)]
// CHECK:STDOUT: %require_complete.loc11_54: <witness> = require_complete_type %T.loc7 [symbolic = %require_complete.loc11_54 (constants.%require_complete.944)]
// CHECK:STDOUT: %require_complete.loc11_34: <witness> = require_complete_type %B [symbolic = %require_complete.loc11_34 (constants.%require_complete.0e8)]
// CHECK:STDOUT: %require_complete.loc11_48: <witness> = require_complete_type %T.loc7 [symbolic = %require_complete.loc11_48 (constants.%require_complete.944)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param.loc11: @B.F.%B (%B), %a.param.loc11: @B.F.%T.loc7 (%T)) {
// CHECK:STDOUT: !entry:
@@ -541,7 +544,7 @@ fn Generic(unused T:! ()).WrongType() {}
// CHECK:STDOUT: %T.loc7 => constants.%T
// CHECK:STDOUT: %_.loc7 => constants.%_
// CHECK:STDOUT: %B => constants.%B
// CHECK:STDOUT: %pattern_type.loc7_14 => constants.%pattern_type.b16
// CHECK:STDOUT: %pattern_type.loc7_23 => constants.%pattern_type.51d
// CHECK:STDOUT: %pattern_type.loc7_10 => constants.%pattern_type.b16
// CHECK:STDOUT: %pattern_type.loc7_17 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
+86 -84
View File
@@ -35,19 +35,19 @@ library "[[@TEST_NAME]]";
class Outer(T:! type) {
interface Inner {
fn F[self: Self]() -> T;
fn F(self) -> T;
}
class C {
impl as Inner {
fn F[self: C]() -> T { return self.(Inner.F)(); }
fn F(self: C) -> T { return self.(Inner.F)(); }
}
}
}
class D {
impl as Outer(i32).Inner {
fn F[self: D]() -> i32;
fn F(self: D) -> i32;
}
}
@@ -56,6 +56,7 @@ fn Test() -> i32 {
return c.(Outer(i32).Inner.F)();
}
// CHECK:STDOUT: --- class.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -265,17 +266,18 @@ fn Test() -> i32 {
// CHECK:STDOUT: %require_complete.loc9_14: <witness> = require_complete_type %Inner [symbolic = %require_complete.loc9_14 (constants.%require_complete.972)]
// CHECK:STDOUT: %struct_type.n: type = struct_type {.n: @Outer.F.%T.as_type.loc9_11.1 (%T.as_type)} [symbolic = %struct_type.n (constants.%struct_type.n.797)]
// CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%T) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.c85f21.2)]
// CHECK:STDOUT: %.loc9_38: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc9_38 (constants.%.c29)]
// CHECK:STDOUT: %.loc9_38.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %T [symbolic = %.loc9_38.2 (constants.%.c29)]
// CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.d9c)]
// CHECK:STDOUT: %impl.elem0.loc9_38.2: @Outer.F.%.loc9_38 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc9_38.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc9_38.2: @Outer.F.%.loc9_38.2 (%.c29) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc9_38.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %specific_impl_fn.loc9_38.2: <specific function> = specific_impl_function %impl.elem0.loc9_38.2, @Copy.WithSelf.Op(%T) [symbolic = %specific_impl_fn.loc9_38.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%n.param: @Outer.F.%T.as_type.loc9_11.1 (%T.as_type)) -> out %return.param: @Outer.F.%Inner (%Inner.06b) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %n.ref: @Outer.F.%T.as_type.loc9_11.1 (%T.as_type) = name_ref n, %n
// CHECK:STDOUT: %.loc9_39.1: @Outer.F.%struct_type.n (%struct_type.n.797) = struct_literal (%n.ref)
// CHECK:STDOUT: %impl.elem0.loc9_38.1: @Outer.F.%.loc9_38 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc9_38.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %impl.elem0.loc9_38.1: @Outer.F.%.loc9_38.2 (%.c29) = impl_witness_access constants.%Copy.lookup_impl_witness.d9c, element0 [symbolic = %impl.elem0.loc9_38.2 (constants.%impl.elem0.bd2)]
// CHECK:STDOUT: %bound_method.loc9_38.1: <bound method> = bound_method %n.ref, %impl.elem0.loc9_38.1
// CHECK:STDOUT: %.loc9_38.1: %Copy.type = converted constants.%T.as_type, constants.%T.f84 [symbolic = %T (constants.%T.f84)]
// CHECK:STDOUT: %specific_impl_fn.loc9_38.1: <specific function> = specific_impl_function %impl.elem0.loc9_38.1, @Copy.WithSelf.Op(constants.%T.f84) [symbolic = %specific_impl_fn.loc9_38.2 (constants.%specific_impl_fn.e2a)]
// CHECK:STDOUT: %bound_method.loc9_38.2: <bound method> = bound_method %n.ref, %specific_impl_fn.loc9_38.1
// CHECK:STDOUT: %.loc9_39.2: ref @Outer.F.%T.as_type.loc9_11.1 (%T.as_type) = class_element_access %return.param, element0
@@ -418,7 +420,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %require_complete.loc9_14 => constants.%complete_type.cdf
// CHECK:STDOUT: %struct_type.n => constants.%struct_type.n.9ed
// CHECK:STDOUT: %Copy.WithSelf.Op.type => constants.%Copy.WithSelf.Op.type.d09
// CHECK:STDOUT: %.loc9_38 => constants.%.7a6
// CHECK:STDOUT: %.loc9_38.2 => constants.%.7a6
// CHECK:STDOUT: %Copy.lookup_impl_witness => constants.%Copy.impl_witness.0e0
// CHECK:STDOUT: %impl.elem0.loc9_38.2 => constants.%Int.as.Copy.impl.Op.4f6
// CHECK:STDOUT: %specific_impl_fn.loc9_38.2 => constants.%Int.as.Copy.impl.Op.specific_fn
@@ -562,31 +564,31 @@ fn Test() -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: !with Self:
// CHECK:STDOUT: %Inner.WithSelf.F.decl: @Inner.WithSelf.%Inner.WithSelf.F.type (%Inner.WithSelf.F.type.792) = fn_decl @Inner.WithSelf.F [symbolic = @Inner.WithSelf.%Inner.WithSelf.F (constants.%Inner.WithSelf.F.576)] {
// CHECK:STDOUT: %self.param_patt: @Inner.WithSelf.F.%pattern_type.loc6_14 (%pattern_type.397) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Inner.WithSelf.F.%pattern_type.loc6_14 (%pattern_type.397) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Inner.WithSelf.F.%pattern_type.loc6_27 (%pattern_type.51d) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Inner.WithSelf.F.%pattern_type.loc6_27 (%pattern_type.51d) = return_slot_pattern %return.param_patt, %T.ref [concrete]
// CHECK:STDOUT: %self.param_patt: @Inner.WithSelf.F.%pattern_type.loc6_10 (%pattern_type.397) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Inner.WithSelf.F.%pattern_type.loc6_10 (%pattern_type.397) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Inner.WithSelf.F.%pattern_type.loc6_19 (%pattern_type.51d) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Inner.WithSelf.F.%pattern_type.loc6_19 (%pattern_type.51d) = return_slot_pattern %return.param_patt, %T.ref [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref: type = name_ref T, @Outer.%T.loc4_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %.loc6_27.2: Core.Form = init_form %T.ref [symbolic = %.loc6_27.1 (constants.%.184)]
// CHECK:STDOUT: %self.param: @Inner.WithSelf.F.%Self.as_type.loc6_16.1 (%Self.as_type.abe) = value_param call_param0
// CHECK:STDOUT: %.loc6_16.1: type = splice_block %.loc6_16.3 [symbolic = %Self.as_type.loc6_16.1 (constants.%Self.as_type.abe)] {
// CHECK:STDOUT: %.loc6_16.2: @Inner.WithSelf.F.%Inner.type (%Inner.type.84b) = specific_constant @Inner.%Self.loc5_19.1, @Inner(constants.%T) [symbolic = %Self (constants.%Self.656)]
// CHECK:STDOUT: %Self.ref: @Inner.WithSelf.F.%Inner.type (%Inner.type.84b) = name_ref Self, %.loc6_16.2 [symbolic = %Self (constants.%Self.656)]
// CHECK:STDOUT: %Self.as_type.loc6_16.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc6_16.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: %.loc6_16.3: type = converted %Self.ref, %Self.as_type.loc6_16.2 [symbolic = %Self.as_type.loc6_16.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: %.loc6_19.2: Core.Form = init_form %T.ref [symbolic = %.loc6_19.1 (constants.%.184)]
// CHECK:STDOUT: %self.param: @Inner.WithSelf.F.%Self.as_type.loc6_10.1 (%Self.as_type.abe) = value_param call_param0
// CHECK:STDOUT: %.loc6_10.1: type = splice_block %.loc6_10.3 [symbolic = %Self.as_type.loc6_10.1 (constants.%Self.as_type.abe)] {
// CHECK:STDOUT: %.loc6_10.2: @Inner.WithSelf.F.%Inner.type (%Inner.type.84b) = specific_constant @Inner.%Self.loc5_19.1, @Inner(constants.%T) [symbolic = %Self (constants.%Self.656)]
// CHECK:STDOUT: %Self.ref: @Inner.WithSelf.F.%Inner.type (%Inner.type.84b) = name_ref Self, %.loc6_10.2 [symbolic = %Self (constants.%Self.656)]
// CHECK:STDOUT: %Self.as_type.loc6_10.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc6_10.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: %.loc6_10.3: type = converted %Self.ref, %Self.as_type.loc6_10.2 [symbolic = %Self.as_type.loc6_10.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: @Inner.WithSelf.F.%Self.as_type.loc6_16.1 (%Self.as_type.abe) = value_binding self, %self.param
// CHECK:STDOUT: %self: @Inner.WithSelf.F.%Self.as_type.loc6_10.1 (%Self.as_type.abe) = value_binding self, %self.param
// CHECK:STDOUT: %return.param: ref @Inner.WithSelf.F.%T (%T) = out_param call_param1
// CHECK:STDOUT: %return: ref @Inner.WithSelf.F.%T (%T) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %assoc0.loc6_28.1: @Inner.WithSelf.%Inner.assoc_type (%Inner.assoc_type.b6b) = assoc_entity element0, %Inner.WithSelf.F.decl [symbolic = %assoc0.loc6_28.2 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %assoc0.loc6_20.1: @Inner.WithSelf.%Inner.assoc_type (%Inner.assoc_type.b6b) = assoc_entity element0, %Inner.WithSelf.F.decl [symbolic = %assoc0.loc6_20.2 (constants.%assoc0.6dc)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc5_19.1
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: .F = @Inner.WithSelf.%assoc0.loc6_28.1
// CHECK:STDOUT: .F = @Inner.WithSelf.%assoc0.loc6_20.1
// CHECK:STDOUT: .C = <poisoned>
// CHECK:STDOUT: .Inner = <poisoned>
// CHECK:STDOUT: .D = <poisoned>
@@ -611,11 +613,11 @@ fn Test() -> i32 {
// CHECK:STDOUT: %C.as.Inner.impl.F.decl: @C.as.Inner.impl.%C.as.Inner.impl.F.type (%C.as.Inner.impl.F.type.1ec) = fn_decl @C.as.Inner.impl.F [symbolic = @C.as.Inner.impl.%C.as.Inner.impl.F (constants.%C.as.Inner.impl.F.4be)] {
// CHECK:STDOUT: %self.param_patt: @C.as.Inner.impl.F.%pattern_type.loc11_16 (%pattern_type.6fd) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @C.as.Inner.impl.F.%pattern_type.loc11_16 (%pattern_type.6fd) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @C.as.Inner.impl.F.%pattern_type.loc11_26 (%pattern_type.51d) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @C.as.Inner.impl.F.%pattern_type.loc11_26 (%pattern_type.51d) = return_slot_pattern %return.param_patt, %T.ref [concrete]
// CHECK:STDOUT: %return.param_patt: @C.as.Inner.impl.F.%pattern_type.loc11_24 (%pattern_type.51d) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @C.as.Inner.impl.F.%pattern_type.loc11_24 (%pattern_type.51d) = return_slot_pattern %return.param_patt, %T.ref [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.ref: type = name_ref T, @Outer.%T.loc4_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %.loc11_26.3: Core.Form = init_form %T.ref [symbolic = %.loc11_26.2 (constants.%.184)]
// CHECK:STDOUT: %.loc11_24.3: Core.Form = init_form %T.ref [symbolic = %.loc11_24.2 (constants.%.184)]
// CHECK:STDOUT: %self.param: @C.as.Inner.impl.F.%C (%C.7d7) = value_param call_param0
// CHECK:STDOUT: %.loc11_18.1: type = splice_block %C.ref [symbolic = %C (constants.%C.7d7)] {
// CHECK:STDOUT: %.loc11_18.2: type = specific_constant @Outer.%C.decl, @Outer(constants.%T) [symbolic = %C (constants.%C.7d7)]
@@ -726,49 +728,49 @@ fn Test() -> i32 {
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %Inner.type: type = facet_type <@Inner, @Inner(%T)> [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %Self: @Inner.WithSelf.F.%Inner.type (%Inner.type.84b) = symbolic_binding Self, 1 [symbolic = %Self (constants.%Self.656)]
// CHECK:STDOUT: %Self.as_type.loc6_16.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc6_16.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: %pattern_type.loc6_14: type = pattern_type %Self.as_type.loc6_16.1 [symbolic = %pattern_type.loc6_14 (constants.%pattern_type.397)]
// CHECK:STDOUT: %.loc6_27.1: Core.Form = init_form %T [symbolic = %.loc6_27.1 (constants.%.184)]
// CHECK:STDOUT: %pattern_type.loc6_27: type = pattern_type %T [symbolic = %pattern_type.loc6_27 (constants.%pattern_type.51d)]
// CHECK:STDOUT: %Self.as_type.loc6_10.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc6_10.1 (constants.%Self.as_type.abe)]
// CHECK:STDOUT: %pattern_type.loc6_10: type = pattern_type %Self.as_type.loc6_10.1 [symbolic = %pattern_type.loc6_10 (constants.%pattern_type.397)]
// CHECK:STDOUT: %.loc6_19.1: Core.Form = init_form %T [symbolic = %.loc6_19.1 (constants.%.184)]
// CHECK:STDOUT: %pattern_type.loc6_19: type = pattern_type %T [symbolic = %pattern_type.loc6_19 (constants.%pattern_type.51d)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @Inner.WithSelf.F.%Self.as_type.loc6_16.1 (%Self.as_type.abe)) -> out %return.param: @Inner.WithSelf.F.%T (%T);
// CHECK:STDOUT: fn(%self.param: @Inner.WithSelf.F.%Self.as_type.loc6_10.1 (%Self.as_type.abe)) -> out %return.param: @Inner.WithSelf.F.%T (%T);
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @C.as.Inner.impl.F(@Outer.%T.loc4_14.2: type) {
// CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic = %C (constants.%C.7d7)]
// CHECK:STDOUT: %pattern_type.loc11_16: type = pattern_type %C [symbolic = %pattern_type.loc11_16 (constants.%pattern_type.6fd)]
// CHECK:STDOUT: %.loc11_26.2: Core.Form = init_form %T [symbolic = %.loc11_26.2 (constants.%.184)]
// CHECK:STDOUT: %pattern_type.loc11_26: type = pattern_type %T [symbolic = %pattern_type.loc11_26 (constants.%pattern_type.51d)]
// CHECK:STDOUT: %.loc11_24.2: Core.Form = init_form %T [symbolic = %.loc11_24.2 (constants.%.184)]
// CHECK:STDOUT: %pattern_type.loc11_24: type = pattern_type %T [symbolic = %pattern_type.loc11_24 (constants.%pattern_type.51d)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc11_16: <witness> = require_complete_type %C [symbolic = %require_complete.loc11_16 (constants.%require_complete.895)]
// CHECK:STDOUT: %require_complete.loc11_23: <witness> = require_complete_type %T [symbolic = %require_complete.loc11_23 (constants.%require_complete.944)]
// CHECK:STDOUT: %require_complete.loc11_21: <witness> = require_complete_type %T [symbolic = %require_complete.loc11_21 (constants.%require_complete.944)]
// CHECK:STDOUT: %Inner.type: type = facet_type <@Inner, @Inner(%T)> [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %require_complete.loc11_48: <witness> = require_complete_type %Inner.type [symbolic = %require_complete.loc11_48 (constants.%require_complete.fcc)]
// CHECK:STDOUT: %require_complete.loc11_46: <witness> = require_complete_type %Inner.type [symbolic = %require_complete.loc11_46 (constants.%require_complete.fcc)]
// CHECK:STDOUT: %Inner.assoc_type: type = assoc_entity_type @Inner, @Inner(%T) [symbolic = %Inner.assoc_type (constants.%Inner.assoc_type.b6b)]
// CHECK:STDOUT: %assoc0: @C.as.Inner.impl.F.%Inner.assoc_type (%Inner.assoc_type.b6b) = assoc_entity element0, @Inner.WithSelf.%Inner.WithSelf.F.decl [symbolic = %assoc0 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %.loc11_41.1: require_specific_def_type = require_specific_def @C.as.Inner.impl(%T) [symbolic = %.loc11_41.1 (constants.%.72e)]
// CHECK:STDOUT: %.loc11_39.1: require_specific_def_type = require_specific_def @C.as.Inner.impl(%T) [symbolic = %.loc11_39.1 (constants.%.72e)]
// CHECK:STDOUT: %Inner.lookup_impl_witness: <witness> = lookup_impl_witness %C, @Inner, @Inner(%T) [symbolic = %Inner.lookup_impl_witness (constants.%Inner.lookup_impl_witness)]
// CHECK:STDOUT: %Inner.facet: @C.as.Inner.impl.F.%Inner.type (%Inner.type.84b) = facet_value %C, (%Inner.lookup_impl_witness) [symbolic = %Inner.facet (constants.%Inner.facet.8ef)]
// CHECK:STDOUT: %Inner.WithSelf.F.type: type = fn_type @Inner.WithSelf.F, @Inner.WithSelf(%T, %Inner.facet) [symbolic = %Inner.WithSelf.F.type (constants.%Inner.WithSelf.F.type.26a)]
// CHECK:STDOUT: %.loc11_41.2: type = fn_type_with_self_type %Inner.WithSelf.F.type, %Inner.facet [symbolic = %.loc11_41.2 (constants.%.35d)]
// CHECK:STDOUT: %impl.elem0.loc11_41.2: @C.as.Inner.impl.F.%.loc11_41.2 (%.35d) = impl_witness_access %Inner.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_41.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc11_41.2: <specific function> = specific_impl_function %impl.elem0.loc11_41.2, @Inner.WithSelf.F(%T, %Inner.facet) [symbolic = %specific_impl_fn.loc11_41.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %.loc11_39.2: type = fn_type_with_self_type %Inner.WithSelf.F.type, %Inner.facet [symbolic = %.loc11_39.2 (constants.%.35d)]
// CHECK:STDOUT: %impl.elem0.loc11_39.2: @C.as.Inner.impl.F.%.loc11_39.2 (%.35d) = impl_witness_access %Inner.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_39.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc11_39.2: <specific function> = specific_impl_function %impl.elem0.loc11_39.2, @Inner.WithSelf.F(%T, %Inner.facet) [symbolic = %specific_impl_fn.loc11_39.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @C.as.Inner.impl.F.%C (%C.7d7)) -> out %return.param: @C.as.Inner.impl.F.%T (%T) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @C.as.Inner.impl.F.%C (%C.7d7) = name_ref self, %self
// CHECK:STDOUT: %.loc11_43: type = specific_constant @Outer.%Inner.decl, @Outer(constants.%T) [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %.loc11_43 [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %.loc11_48: @C.as.Inner.impl.F.%Inner.assoc_type (%Inner.assoc_type.b6b) = specific_constant @Inner.WithSelf.%assoc0.loc6_28.1, @Inner.WithSelf(constants.%T, constants.%Self.656) [symbolic = %assoc0 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %F.ref: @C.as.Inner.impl.F.%Inner.assoc_type (%Inner.assoc_type.b6b) = name_ref F, %.loc11_48 [symbolic = %assoc0 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %impl.elem0.loc11_41.1: @C.as.Inner.impl.F.%.loc11_41.2 (%.35d) = impl_witness_access constants.%Inner.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_41.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc11_41: <bound method> = bound_method %self.ref, %impl.elem0.loc11_41.1
// CHECK:STDOUT: %specific_impl_fn.loc11_41.1: <specific function> = specific_impl_function %impl.elem0.loc11_41.1, @Inner.WithSelf.F(constants.%T, constants.%Inner.facet.8ef) [symbolic = %specific_impl_fn.loc11_41.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc11_52: <bound method> = bound_method %self.ref, %specific_impl_fn.loc11_41.1
// CHECK:STDOUT: %.loc11_26.1: ref @C.as.Inner.impl.F.%T (%T) = splice_block %return.param {}
// CHECK:STDOUT: %Inner.WithSelf.F.call: init @C.as.Inner.impl.F.%T (%T) to %.loc11_26.1 = call %bound_method.loc11_52(%self.ref)
// CHECK:STDOUT: %.loc11_41: type = specific_constant @Outer.%Inner.decl, @Outer(constants.%T) [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %.loc11_41 [symbolic = %Inner.type (constants.%Inner.type.84b)]
// CHECK:STDOUT: %.loc11_46: @C.as.Inner.impl.F.%Inner.assoc_type (%Inner.assoc_type.b6b) = specific_constant @Inner.WithSelf.%assoc0.loc6_20.1, @Inner.WithSelf(constants.%T, constants.%Self.656) [symbolic = %assoc0 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %F.ref: @C.as.Inner.impl.F.%Inner.assoc_type (%Inner.assoc_type.b6b) = name_ref F, %.loc11_46 [symbolic = %assoc0 (constants.%assoc0.6dc)]
// CHECK:STDOUT: %impl.elem0.loc11_39.1: @C.as.Inner.impl.F.%.loc11_39.2 (%.35d) = impl_witness_access constants.%Inner.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc11_39.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc11_39: <bound method> = bound_method %self.ref, %impl.elem0.loc11_39.1
// CHECK:STDOUT: %specific_impl_fn.loc11_39.1: <specific function> = specific_impl_function %impl.elem0.loc11_39.1, @Inner.WithSelf.F(constants.%T, constants.%Inner.facet.8ef) [symbolic = %specific_impl_fn.loc11_39.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc11_50: <bound method> = bound_method %self.ref, %specific_impl_fn.loc11_39.1
// CHECK:STDOUT: %.loc11_24.1: ref @C.as.Inner.impl.F.%T (%T) = splice_block %return.param {}
// CHECK:STDOUT: %Inner.WithSelf.F.call: init @C.as.Inner.impl.F.%T (%T) to %.loc11_24.1 = call %bound_method.loc11_50(%self.ref)
// CHECK:STDOUT: return %Inner.WithSelf.F.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
@@ -800,7 +802,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Outer.loc24: type = class_type @Outer, @Outer(constants.%i32) [concrete = constants.%Outer.e7c]
// CHECK:STDOUT: %.loc24_23: type = specific_constant @Outer.%Inner.decl, @Outer(constants.%i32) [concrete = constants.%Inner.type.5cc]
// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, %.loc24_23 [concrete = constants.%Inner.type.5cc]
// CHECK:STDOUT: %.loc24_29: %Inner.assoc_type.477 = specific_constant @Inner.WithSelf.%assoc0.loc6_28.1, @Inner.WithSelf(constants.%i32, constants.%Self.656) [concrete = constants.%assoc0.7b8]
// CHECK:STDOUT: %.loc24_29: %Inner.assoc_type.477 = specific_constant @Inner.WithSelf.%assoc0.loc6_20.1, @Inner.WithSelf(constants.%i32, constants.%Self.656) [concrete = constants.%assoc0.7b8]
// CHECK:STDOUT: %F.ref: %Inner.assoc_type.477 = name_ref F, %.loc24_29 [concrete = constants.%assoc0.7b8]
// CHECK:STDOUT: %impl.elem0: %.8da = impl_witness_access constants.%Inner.impl_witness.cdc, element0 [concrete = constants.%C.as.Inner.impl.F.e77]
// CHECK:STDOUT: %bound_method.loc24_11: <bound method> = bound_method %c.ref, %impl.elem0
@@ -843,17 +845,17 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.792
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.576
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.b6b
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.6dc
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.6dc
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf.F(constants.%T, constants.%Self.656) {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.84b
// CHECK:STDOUT: %Self => constants.%Self.656
// CHECK:STDOUT: %Self.as_type.loc6_16.1 => constants.%Self.as_type.abe
// CHECK:STDOUT: %pattern_type.loc6_14 => constants.%pattern_type.397
// CHECK:STDOUT: %.loc6_27.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_27 => constants.%pattern_type.51d
// CHECK:STDOUT: %Self.as_type.loc6_10.1 => constants.%Self.as_type.abe
// CHECK:STDOUT: %pattern_type.loc6_10 => constants.%pattern_type.397
// CHECK:STDOUT: %.loc6_19.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_19 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @C(constants.%T) {
@@ -876,8 +878,8 @@ fn Test() -> i32 {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %C => constants.%C.7d7
// CHECK:STDOUT: %pattern_type.loc11_16 => constants.%pattern_type.6fd
// CHECK:STDOUT: %.loc11_26.2 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc11_26 => constants.%pattern_type.51d
// CHECK:STDOUT: %.loc11_24.2 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc11_24 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf(constants.%T, constants.%Inner.facet.285) {
@@ -888,17 +890,17 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.b47
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.350
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.b6b
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.6dc
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.6dc
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf.F(constants.%T, constants.%Inner.facet.285) {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.84b
// CHECK:STDOUT: %Self => constants.%Inner.facet.285
// CHECK:STDOUT: %Self.as_type.loc6_16.1 => constants.%C.7d7
// CHECK:STDOUT: %pattern_type.loc6_14 => constants.%pattern_type.6fd
// CHECK:STDOUT: %.loc6_27.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_27 => constants.%pattern_type.51d
// CHECK:STDOUT: %Self.as_type.loc6_10.1 => constants.%C.7d7
// CHECK:STDOUT: %pattern_type.loc6_10 => constants.%pattern_type.6fd
// CHECK:STDOUT: %.loc6_19.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_19 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf(constants.%T, constants.%Inner.facet.8ef) {
@@ -909,17 +911,17 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.26a
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.3e0
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.b6b
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.6dc
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.6dc
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf.F(constants.%T, constants.%Inner.facet.8ef) {
// CHECK:STDOUT: %T => constants.%T
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.84b
// CHECK:STDOUT: %Self => constants.%Inner.facet.8ef
// CHECK:STDOUT: %Self.as_type.loc6_16.1 => constants.%C.7d7
// CHECK:STDOUT: %pattern_type.loc6_14 => constants.%pattern_type.6fd
// CHECK:STDOUT: %.loc6_27.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_27 => constants.%pattern_type.51d
// CHECK:STDOUT: %Self.as_type.loc6_10.1 => constants.%C.7d7
// CHECK:STDOUT: %pattern_type.loc6_10 => constants.%pattern_type.6fd
// CHECK:STDOUT: %.loc6_19.1 => constants.%.184
// CHECK:STDOUT: %pattern_type.loc6_19 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Outer(constants.%i32) {
@@ -949,7 +951,7 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.62d
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.389
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.477
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.7b8
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.7b8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf(constants.%i32, constants.%Inner.facet.45b) {
@@ -960,17 +962,17 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.576
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.adb
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.477
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.7b8
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.7b8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf.F(constants.%i32, constants.%Inner.facet.45b) {
// CHECK:STDOUT: %T => constants.%i32
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.5cc
// CHECK:STDOUT: %Self => constants.%Inner.facet.45b
// CHECK:STDOUT: %Self.as_type.loc6_16.1 => constants.%D
// CHECK:STDOUT: %pattern_type.loc6_14 => constants.%pattern_type.d8d
// CHECK:STDOUT: %.loc6_27.1 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc6_27 => constants.%pattern_type.6b6
// CHECK:STDOUT: %Self.as_type.loc6_10.1 => constants.%D
// CHECK:STDOUT: %pattern_type.loc6_10 => constants.%pattern_type.d8d
// CHECK:STDOUT: %.loc6_19.1 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc6_19 => constants.%pattern_type.6b6
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @C.as.Inner.impl(constants.%i32) {
@@ -993,39 +995,39 @@ fn Test() -> i32 {
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.a78
// CHECK:STDOUT: %Inner.WithSelf.F => constants.%Inner.WithSelf.F.e60
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.477
// CHECK:STDOUT: %assoc0.loc6_28.2 => constants.%assoc0.7b8
// CHECK:STDOUT: %assoc0.loc6_20.2 => constants.%assoc0.7b8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @C.as.Inner.impl.F(constants.%i32) {
// CHECK:STDOUT: %T => constants.%i32
// CHECK:STDOUT: %C => constants.%C.b7f
// CHECK:STDOUT: %pattern_type.loc11_16 => constants.%pattern_type.9d0
// CHECK:STDOUT: %.loc11_26.2 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc11_26 => constants.%pattern_type.6b6
// CHECK:STDOUT: %.loc11_24.2 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc11_24 => constants.%pattern_type.6b6
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc11_16 => constants.%complete_type.357
// CHECK:STDOUT: %require_complete.loc11_23 => constants.%complete_type.f8a
// CHECK:STDOUT: %require_complete.loc11_21 => constants.%complete_type.f8a
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.5cc
// CHECK:STDOUT: %require_complete.loc11_48 => constants.%complete_type.11e
// CHECK:STDOUT: %require_complete.loc11_46 => constants.%complete_type.11e
// CHECK:STDOUT: %Inner.assoc_type => constants.%Inner.assoc_type.477
// CHECK:STDOUT: %assoc0 => constants.%assoc0.7b8
// CHECK:STDOUT: %.loc11_41.1 => constants.%.fff
// CHECK:STDOUT: %.loc11_39.1 => constants.%.fff
// CHECK:STDOUT: %Inner.lookup_impl_witness => constants.%Inner.impl_witness.cdc
// CHECK:STDOUT: %Inner.facet => constants.%Inner.facet.39b
// CHECK:STDOUT: %Inner.WithSelf.F.type => constants.%Inner.WithSelf.F.type.a78
// CHECK:STDOUT: %.loc11_41.2 => constants.%.8da
// CHECK:STDOUT: %impl.elem0.loc11_41.2 => constants.%C.as.Inner.impl.F.e77
// CHECK:STDOUT: %specific_impl_fn.loc11_41.2 => constants.%C.as.Inner.impl.F.specific_fn
// CHECK:STDOUT: %.loc11_39.2 => constants.%.8da
// CHECK:STDOUT: %impl.elem0.loc11_39.2 => constants.%C.as.Inner.impl.F.e77
// CHECK:STDOUT: %specific_impl_fn.loc11_39.2 => constants.%C.as.Inner.impl.F.specific_fn
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Inner.WithSelf.F(constants.%i32, constants.%Inner.facet.39b) {
// CHECK:STDOUT: %T => constants.%i32
// CHECK:STDOUT: %Inner.type => constants.%Inner.type.5cc
// CHECK:STDOUT: %Self => constants.%Inner.facet.39b
// CHECK:STDOUT: %Self.as_type.loc6_16.1 => constants.%C.b7f
// CHECK:STDOUT: %pattern_type.loc6_14 => constants.%pattern_type.9d0
// CHECK:STDOUT: %.loc6_27.1 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc6_27 => constants.%pattern_type.6b6
// CHECK:STDOUT: %Self.as_type.loc6_10.1 => constants.%C.b7f
// CHECK:STDOUT: %pattern_type.loc6_10 => constants.%pattern_type.9d0
// CHECK:STDOUT: %.loc6_19.1 => constants.%.795
// CHECK:STDOUT: %pattern_type.loc6_19 => constants.%pattern_type.6b6
// CHECK:STDOUT: }
// CHECK:STDOUT:
+200 -35
View File
@@ -18,6 +18,7 @@ class B {}
class Class(T:! type) {
fn Get(U:! type) -> (T, U) { return Get(U); }
fn GetNoDeduce(x: T, U:! type) -> (T, U) { return GetNoDeduce(x, U); }
fn F[U:! type](self: Class(U)) -> U { return self.F(); }
}
fn CallGenericMethod(c: Class(A)) -> (A, B) {
@@ -28,6 +29,11 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
return c.GetNoDeduce({}, B);
}
fn CallMethodSelfDeduce(c: Class(A)) -> A {
return c.F();
}
// CHECK:STDOUT: --- method_deduce.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -54,10 +60,24 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %pattern_type.51d: type = pattern_type %T [symbolic]
// CHECK:STDOUT: %Class.GetNoDeduce.type.83e: type = fn_type @Class.GetNoDeduce, @Class(%T) [symbolic]
// CHECK:STDOUT: %Class.GetNoDeduce.a04: %Class.GetNoDeduce.type.83e = struct_value () [symbolic]
// CHECK:STDOUT: %Class.d74: type = class_type @Class, @Class(%U) [symbolic]
// CHECK:STDOUT: %pattern_type.cc0: type = pattern_type %Class.d74 [symbolic]
// CHECK:STDOUT: %.822: Core.Form = init_form %U [symbolic]
// CHECK:STDOUT: %pattern_type.946: type = pattern_type %U [symbolic]
// CHECK:STDOUT: %Class.F.type.982: type = fn_type @Class.F, @Class(%T) [symbolic]
// CHECK:STDOUT: %Class.F.c63: %Class.F.type.982 = struct_value () [symbolic]
// CHECK:STDOUT: %require_complete.220: <witness> = require_complete_type %tuple.type.a5e [symbolic]
// CHECK:STDOUT: %Class.Get.specific_fn.ba5: <specific function> = specific_function %Class.Get.ceb, @Class.Get(%T, %U) [symbolic]
// CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T [symbolic]
// CHECK:STDOUT: %Class.GetNoDeduce.specific_fn.def: <specific function> = specific_function %Class.GetNoDeduce.a04, @Class.GetNoDeduce(%T, %U) [symbolic]
// CHECK:STDOUT: %Class.Get.type.3dc: type = fn_type @Class.Get, @Class(%U) [symbolic]
// CHECK:STDOUT: %Class.Get.d1f: %Class.Get.type.3dc = struct_value () [symbolic]
// CHECK:STDOUT: %Class.GetNoDeduce.type.2cf: type = fn_type @Class.GetNoDeduce, @Class(%U) [symbolic]
// CHECK:STDOUT: %Class.GetNoDeduce.0cf: %Class.GetNoDeduce.type.2cf = struct_value () [symbolic]
// CHECK:STDOUT: %Class.F.type.6df: type = fn_type @Class.F, @Class(%U) [symbolic]
// CHECK:STDOUT: %Class.F.c29: %Class.F.type.6df = struct_value () [symbolic]
// CHECK:STDOUT: %require_complete.716: <witness> = require_complete_type %Class.d74 [symbolic]
// CHECK:STDOUT: %Class.F.specific_fn.844: <specific function> = specific_function %Class.F.c29, @Class.F(%U, %U) [symbolic]
// CHECK:STDOUT: %Class.30a: type = class_type @Class, @Class(%A) [concrete]
// CHECK:STDOUT: %pattern_type.89e: type = pattern_type %Class.30a [concrete]
// CHECK:STDOUT: %tuple.9aa: %tuple.type.24b = tuple_value (%A, %B) [concrete]
@@ -70,6 +90,8 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.Get.e47: %Class.Get.type.9a5 = struct_value () [concrete]
// CHECK:STDOUT: %Class.GetNoDeduce.type.7e9: type = fn_type @Class.GetNoDeduce, @Class(%A) [concrete]
// CHECK:STDOUT: %Class.GetNoDeduce.c1e: %Class.GetNoDeduce.type.7e9 = struct_value () [concrete]
// CHECK:STDOUT: %Class.F.type.e68: type = fn_type @Class.F, @Class(%A) [concrete]
// CHECK:STDOUT: %Class.F.805: %Class.F.type.e68 = struct_value () [concrete]
// CHECK:STDOUT: %Class.Get.specific_fn.0ec: <specific function> = specific_function %Class.Get.e47, @Class.Get(%A, %B) [concrete]
// CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam.type: type = fn_type @CallGenericMethodWithNonDeducedParam [concrete]
// CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam: %CallGenericMethodWithNonDeducedParam.type = struct_value () [concrete]
@@ -79,9 +101,13 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %A.val: %A = struct_value () [concrete]
// CHECK:STDOUT: %.367: ref %A = temporary invalid, %A.val [concrete]
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
// CHECK:STDOUT: %Destroy.Op.type.1d8f74.2: type = fn_type @Destroy.Op.loc28_25.2 [concrete]
// CHECK:STDOUT: %Destroy.Op.type.1d8f74.2: type = fn_type @Destroy.Op.loc29_25.2 [concrete]
// CHECK:STDOUT: %Destroy.Op.1a2547.2: %Destroy.Op.type.1d8f74.2 = struct_value () [concrete]
// CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.367, %Destroy.Op.1a2547.2 [concrete]
// CHECK:STDOUT: %.cbf: Core.Form = init_form %A [concrete]
// CHECK:STDOUT: %CallMethodSelfDeduce.type: type = fn_type @CallMethodSelfDeduce [concrete]
// CHECK:STDOUT: %CallMethodSelfDeduce: %CallMethodSelfDeduce.type = struct_value () [concrete]
// CHECK:STDOUT: %Class.F.specific_fn.0bd: <specific function> = specific_function %Class.F.805, @Class.F(%A, %A) [concrete]
// CHECK:STDOUT: %complete_type.c44: <witness> = complete_type_witness %tuple.type.1e7 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -102,6 +128,7 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: .Class = %Class.decl
// CHECK:STDOUT: .CallGenericMethod = %CallGenericMethod.decl
// CHECK:STDOUT: .CallGenericMethodWithNonDeducedParam = %CallGenericMethodWithNonDeducedParam.decl
// CHECK:STDOUT: .CallMethodSelfDeduce = %CallMethodSelfDeduce.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
@@ -119,17 +146,17 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %c.param_patt: %pattern_type.89e = value_param_pattern [concrete]
// CHECK:STDOUT: %c.patt: %pattern_type.89e = at_binding_pattern c, %c.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7c6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7c6 = return_slot_pattern %return.param_patt, %.loc23_43.3 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7c6 = return_slot_pattern %return.param_patt, %.loc24_43.3 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %A.ref.loc23_39: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %B.ref.loc23: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc23_43.2: %tuple.type.24b = tuple_literal (%A.ref.loc23_39, %B.ref.loc23) [concrete = constants.%tuple.9aa]
// CHECK:STDOUT: %.loc23_43.3: type = converted %.loc23_43.2, constants.%tuple.type.1e7 [concrete = constants.%tuple.type.1e7]
// CHECK:STDOUT: %.loc23_43.4: Core.Form = init_form %.loc23_43.3 [concrete = constants.%.7f5]
// CHECK:STDOUT: %A.ref.loc24_39: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc24_43.2: %tuple.type.24b = tuple_literal (%A.ref.loc24_39, %B.ref.loc24) [concrete = constants.%tuple.9aa]
// CHECK:STDOUT: %.loc24_43.3: type = converted %.loc24_43.2, constants.%tuple.type.1e7 [concrete = constants.%tuple.type.1e7]
// CHECK:STDOUT: %.loc24_43.4: Core.Form = init_form %.loc24_43.3 [concrete = constants.%.7f5]
// CHECK:STDOUT: %c.param: %Class.30a = value_param call_param0
// CHECK:STDOUT: %.loc23_32: type = splice_block %Class [concrete = constants.%Class.30a] {
// CHECK:STDOUT: %.loc24_32: type = splice_block %Class [concrete = constants.%Class.30a] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %A.ref.loc23_31: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %A.ref.loc24_31: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%A) [concrete = constants.%Class.30a]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: %Class.30a = value_binding c, %c.param
@@ -140,23 +167,41 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %c.param_patt: %pattern_type.89e = value_param_pattern [concrete]
// CHECK:STDOUT: %c.patt: %pattern_type.89e = at_binding_pattern c, %c.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7c6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7c6 = return_slot_pattern %return.param_patt, %.loc27_62.3 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7c6 = return_slot_pattern %return.param_patt, %.loc28_62.3 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %A.ref.loc27_58: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %B.ref.loc27: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc27_62.2: %tuple.type.24b = tuple_literal (%A.ref.loc27_58, %B.ref.loc27) [concrete = constants.%tuple.9aa]
// CHECK:STDOUT: %.loc27_62.3: type = converted %.loc27_62.2, constants.%tuple.type.1e7 [concrete = constants.%tuple.type.1e7]
// CHECK:STDOUT: %.loc27_62.4: Core.Form = init_form %.loc27_62.3 [concrete = constants.%.7f5]
// CHECK:STDOUT: %A.ref.loc28_58: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %B.ref.loc28: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc28_62.2: %tuple.type.24b = tuple_literal (%A.ref.loc28_58, %B.ref.loc28) [concrete = constants.%tuple.9aa]
// CHECK:STDOUT: %.loc28_62.3: type = converted %.loc28_62.2, constants.%tuple.type.1e7 [concrete = constants.%tuple.type.1e7]
// CHECK:STDOUT: %.loc28_62.4: Core.Form = init_form %.loc28_62.3 [concrete = constants.%.7f5]
// CHECK:STDOUT: %c.param: %Class.30a = value_param call_param0
// CHECK:STDOUT: %.loc27_51: type = splice_block %Class [concrete = constants.%Class.30a] {
// CHECK:STDOUT: %.loc28_51: type = splice_block %Class [concrete = constants.%Class.30a] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %A.ref.loc27_50: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %A.ref.loc28_50: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%A) [concrete = constants.%Class.30a]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: %Class.30a = value_binding c, %c.param
// CHECK:STDOUT: %return.param: ref %tuple.type.1e7 = out_param call_param1
// CHECK:STDOUT: %return: ref %tuple.type.1e7 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %CallMethodSelfDeduce.decl: %CallMethodSelfDeduce.type = fn_decl @CallMethodSelfDeduce [concrete = constants.%CallMethodSelfDeduce] {
// CHECK:STDOUT: %c.param_patt: %pattern_type.89e = value_param_pattern [concrete]
// CHECK:STDOUT: %c.patt: %pattern_type.89e = at_binding_pattern c, %c.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.9ef = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.9ef = return_slot_pattern %return.param_patt, %A.ref.loc32_41 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %A.ref.loc32_41: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %.loc32_41.2: Core.Form = init_form %A.ref.loc32_41 [concrete = constants.%.cbf]
// CHECK:STDOUT: %c.param: %Class.30a = value_param call_param0
// CHECK:STDOUT: %.loc32_35: type = splice_block %Class [concrete = constants.%Class.30a] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %A.ref.loc32_34: type = name_ref A, file.%A.decl [concrete = constants.%A]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%A) [concrete = constants.%Class.30a]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: %Class.30a = value_binding c, %c.param
// CHECK:STDOUT: %return.param: ref %A = out_param call_param1
// CHECK:STDOUT: %return: ref %A = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @A {
@@ -183,6 +228,8 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.Get: @Class.%Class.Get.type (%Class.Get.type.49d) = struct_value () [symbolic = %Class.Get (constants.%Class.Get.ceb)]
// CHECK:STDOUT: %Class.GetNoDeduce.type: type = fn_type @Class.GetNoDeduce, @Class(%T.loc18_14.1) [symbolic = %Class.GetNoDeduce.type (constants.%Class.GetNoDeduce.type.83e)]
// CHECK:STDOUT: %Class.GetNoDeduce: @Class.%Class.GetNoDeduce.type (%Class.GetNoDeduce.type.83e) = struct_value () [symbolic = %Class.GetNoDeduce (constants.%Class.GetNoDeduce.a04)]
// CHECK:STDOUT: %Class.F.type: type = fn_type @Class.F, @Class(%T.loc18_14.1) [symbolic = %Class.F.type (constants.%Class.F.type.982)]
// CHECK:STDOUT: %Class.F: @Class.%Class.F.type (%Class.F.type.982) = struct_value () [symbolic = %Class.F (constants.%Class.F.c63)]
// CHECK:STDOUT:
// CHECK:STDOUT: class {
// CHECK:STDOUT: %Class.Get.decl: @Class.%Class.Get.type (%Class.Get.type.49d) = fn_decl @Class.Get [symbolic = @Class.%Class.Get (constants.%Class.Get.ceb)] {
@@ -226,6 +273,30 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %return.param: ref @Class.GetNoDeduce.%tuple.type (%tuple.type.a5e) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.GetNoDeduce.%tuple.type (%tuple.type.a5e) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.F.decl: @Class.%Class.F.type (%Class.F.type.982) = fn_decl @Class.F [symbolic = @Class.%Class.F (constants.%Class.F.c63)] {
// CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 1 [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.F.%pattern_type.loc21_22 (%pattern_type.cc0) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.F.%pattern_type.loc21_22 (%pattern_type.cc0) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: @Class.F.%pattern_type.loc21_37 (%pattern_type.946) = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: @Class.F.%pattern_type.loc21_37 (%pattern_type.946) = return_slot_pattern %return.param_patt, %U.ref.loc21_37 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %U.ref.loc21_37: type = name_ref U, %U.loc21_9.2 [symbolic = %U.loc21_9.1 (constants.%U)]
// CHECK:STDOUT: %.loc21_37.3: Core.Form = init_form %U.ref.loc21_37 [symbolic = %.loc21_37.2 (constants.%.822)]
// CHECK:STDOUT: %.loc21_12.1: type = splice_block %.loc21_12.2 [concrete = type] {
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
// CHECK:STDOUT: %.loc21_12.2: type = type_literal type [concrete = type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %U.loc21_9.2: type = symbolic_binding U, 1 [symbolic = %U.loc21_9.1 (constants.%U)]
// CHECK:STDOUT: %self.param: @Class.F.%Class.loc21_31.1 (%Class.d74) = value_param call_param0
// CHECK:STDOUT: %.loc21_31: type = splice_block %Class.loc21_31.2 [symbolic = %Class.loc21_31.1 (constants.%Class.d74)] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
// CHECK:STDOUT: %U.ref.loc21_30: type = name_ref U, %U.loc21_9.2 [symbolic = %U.loc21_9.1 (constants.%U)]
// CHECK:STDOUT: %Class.loc21_31.2: type = class_type @Class, @Class(constants.%U) [symbolic = %Class.loc21_31.1 (constants.%Class.d74)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self: @Class.F.%Class.loc21_31.1 (%Class.d74) = value_binding self, %self.param
// CHECK:STDOUT: %return.param: ref @Class.F.%U.loc21_9.1 (%U) = out_param call_param1
// CHECK:STDOUT: %return: ref @Class.F.%U.loc21_9.1 (%U) = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
@@ -234,6 +305,8 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: .Get = %Class.Get.decl
// CHECK:STDOUT: .GetNoDeduce = %Class.GetNoDeduce.decl
// CHECK:STDOUT: .Class = <poisoned>
// CHECK:STDOUT: .F = %Class.F.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -291,44 +364,84 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @Class.F(@Class.%T.loc18_14.2: type, %U.loc21_9.2: type) {
// CHECK:STDOUT: %U.loc21_9.1: type = symbolic_binding U, 1 [symbolic = %U.loc21_9.1 (constants.%U)]
// CHECK:STDOUT: %Class.loc21_31.1: type = class_type @Class, @Class(%U.loc21_9.1) [symbolic = %Class.loc21_31.1 (constants.%Class.d74)]
// CHECK:STDOUT: %pattern_type.loc21_22: type = pattern_type %Class.loc21_31.1 [symbolic = %pattern_type.loc21_22 (constants.%pattern_type.cc0)]
// CHECK:STDOUT: %.loc21_37.2: Core.Form = init_form %U.loc21_9.1 [symbolic = %.loc21_37.2 (constants.%.822)]
// CHECK:STDOUT: %pattern_type.loc21_37: type = pattern_type %U.loc21_9.1 [symbolic = %pattern_type.loc21_37 (constants.%pattern_type.946)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %Class.loc21_31.1 [symbolic = %require_complete (constants.%require_complete.716)]
// CHECK:STDOUT: %Class.F.type: type = fn_type @Class.F, @Class(%U.loc21_9.1) [symbolic = %Class.F.type (constants.%Class.F.type.6df)]
// CHECK:STDOUT: %Class.F: @Class.F.%Class.F.type (%Class.F.type.6df) = struct_value () [symbolic = %Class.F (constants.%Class.F.c29)]
// CHECK:STDOUT: %Class.F.specific_fn.loc21_52.2: <specific function> = specific_function %Class.F, @Class.F(%U.loc21_9.1, %U.loc21_9.1) [symbolic = %Class.F.specific_fn.loc21_52.2 (constants.%Class.F.specific_fn.844)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param: @Class.F.%Class.loc21_31.1 (%Class.d74)) -> out %return.param: @Class.F.%U.loc21_9.1 (%U) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: @Class.F.%Class.loc21_31.1 (%Class.d74) = name_ref self, %self
// CHECK:STDOUT: %.loc21_52: @Class.F.%Class.F.type (%Class.F.type.6df) = specific_constant @Class.%Class.F.decl, @Class(constants.%U) [symbolic = %Class.F (constants.%Class.F.c29)]
// CHECK:STDOUT: %F.ref: @Class.F.%Class.F.type (%Class.F.type.6df) = name_ref F, %.loc21_52 [symbolic = %Class.F (constants.%Class.F.c29)]
// CHECK:STDOUT: %Class.F.bound: <bound method> = bound_method %self.ref, %F.ref
// CHECK:STDOUT: %Class.F.specific_fn.loc21_52.1: <specific function> = specific_function %F.ref, @Class.F(constants.%U, constants.%U) [symbolic = %Class.F.specific_fn.loc21_52.2 (constants.%Class.F.specific_fn.844)]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %self.ref, %Class.F.specific_fn.loc21_52.1
// CHECK:STDOUT: %.loc21_37.1: ref @Class.F.%U.loc21_9.1 (%U) = splice_block %return.param {}
// CHECK:STDOUT: %Class.F.call: init @Class.F.%U.loc21_9.1 (%U) to %.loc21_37.1 = call %bound_method(%self.ref)
// CHECK:STDOUT: return %Class.F.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallGenericMethod(%c.param: %Class.30a) -> out %return.param: %tuple.type.1e7 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %c.ref: %Class.30a = name_ref c, %c
// CHECK:STDOUT: %.loc24: %Class.Get.type.9a5 = specific_constant @Class.%Class.Get.decl, @Class(constants.%A) [concrete = constants.%Class.Get.e47]
// CHECK:STDOUT: %Get.ref: %Class.Get.type.9a5 = name_ref Get, %.loc24 [concrete = constants.%Class.Get.e47]
// CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc25: %Class.Get.type.9a5 = specific_constant @Class.%Class.Get.decl, @Class(constants.%A) [concrete = constants.%Class.Get.e47]
// CHECK:STDOUT: %Get.ref: %Class.Get.type.9a5 = name_ref Get, %.loc25 [concrete = constants.%Class.Get.e47]
// CHECK:STDOUT: %B.ref.loc25: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %Class.Get.specific_fn: <specific function> = specific_function %Get.ref, @Class.Get(constants.%A, constants.%B) [concrete = constants.%Class.Get.specific_fn.0ec]
// CHECK:STDOUT: %.loc23_43.1: ref %tuple.type.1e7 = splice_block %return.param {}
// CHECK:STDOUT: %Class.Get.call: init %tuple.type.1e7 to %.loc23_43.1 = call %Class.Get.specific_fn()
// CHECK:STDOUT: %.loc24_43.1: ref %tuple.type.1e7 = splice_block %return.param {}
// CHECK:STDOUT: %Class.Get.call: init %tuple.type.1e7 to %.loc24_43.1 = call %Class.Get.specific_fn()
// CHECK:STDOUT: return %Class.Get.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallGenericMethodWithNonDeducedParam(%c.param: %Class.30a) -> out %return.param: %tuple.type.1e7 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %c.ref: %Class.30a = name_ref c, %c
// CHECK:STDOUT: %.loc28_11: %Class.GetNoDeduce.type.7e9 = specific_constant @Class.%Class.GetNoDeduce.decl, @Class(constants.%A) [concrete = constants.%Class.GetNoDeduce.c1e]
// CHECK:STDOUT: %GetNoDeduce.ref: %Class.GetNoDeduce.type.7e9 = name_ref GetNoDeduce, %.loc28_11 [concrete = constants.%Class.GetNoDeduce.c1e]
// CHECK:STDOUT: %.loc28_25.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %B.ref.loc28: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %.loc29_11: %Class.GetNoDeduce.type.7e9 = specific_constant @Class.%Class.GetNoDeduce.decl, @Class(constants.%A) [concrete = constants.%Class.GetNoDeduce.c1e]
// CHECK:STDOUT: %GetNoDeduce.ref: %Class.GetNoDeduce.type.7e9 = name_ref GetNoDeduce, %.loc29_11 [concrete = constants.%Class.GetNoDeduce.c1e]
// CHECK:STDOUT: %.loc29_25.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %B.ref.loc29: type = name_ref B, file.%B.decl [concrete = constants.%B]
// CHECK:STDOUT: %Class.GetNoDeduce.specific_fn: <specific function> = specific_function %GetNoDeduce.ref, @Class.GetNoDeduce(constants.%A, constants.%B) [concrete = constants.%Class.GetNoDeduce.specific_fn.931]
// CHECK:STDOUT: %.loc27_62.1: ref %tuple.type.1e7 = splice_block %return.param {}
// CHECK:STDOUT: %.loc28_25.2: ref %A = temporary_storage
// CHECK:STDOUT: %.loc28_25.3: init %A to %.loc28_25.2 = class_init () [concrete = constants.%A.val]
// CHECK:STDOUT: %.loc28_25.4: init %A = converted %.loc28_25.1, %.loc28_25.3 [concrete = constants.%A.val]
// CHECK:STDOUT: %.loc28_25.5: ref %A = temporary %.loc28_25.2, %.loc28_25.4 [concrete = constants.%.367]
// CHECK:STDOUT: %.loc28_25.6: %A = acquire_value %.loc28_25.5 [concrete = constants.%A.val]
// CHECK:STDOUT: %Class.GetNoDeduce.call: init %tuple.type.1e7 to %.loc27_62.1 = call %Class.GetNoDeduce.specific_fn(%.loc28_25.6)
// CHECK:STDOUT: %.loc28_62.1: ref %tuple.type.1e7 = splice_block %return.param {}
// CHECK:STDOUT: %.loc29_25.2: ref %A = temporary_storage
// CHECK:STDOUT: %.loc29_25.3: init %A to %.loc29_25.2 = class_init () [concrete = constants.%A.val]
// CHECK:STDOUT: %.loc29_25.4: init %A = converted %.loc29_25.1, %.loc29_25.3 [concrete = constants.%A.val]
// CHECK:STDOUT: %.loc29_25.5: ref %A = temporary %.loc29_25.2, %.loc29_25.4 [concrete = constants.%.367]
// CHECK:STDOUT: %.loc29_25.6: %A = acquire_value %.loc29_25.5 [concrete = constants.%A.val]
// CHECK:STDOUT: %Class.GetNoDeduce.call: init %tuple.type.1e7 to %.loc28_62.1 = call %Class.GetNoDeduce.specific_fn(%.loc29_25.6)
// CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.367)
// CHECK:STDOUT: return %Class.GetNoDeduce.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc28_25.1(%self.param: ref %empty_struct_type) = "no_op";
// CHECK:STDOUT: fn @Destroy.Op.loc29_25.1(%self.param: ref %empty_struct_type) = "no_op";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc28_25.2(%self.param: ref %A) {
// CHECK:STDOUT: fn @Destroy.Op.loc29_25.2(%self.param: ref %A) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallMethodSelfDeduce(%c.param: %Class.30a) -> out %return.param: %A {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %c.ref: %Class.30a = name_ref c, %c
// CHECK:STDOUT: %.loc33: %Class.F.type.e68 = specific_constant @Class.%Class.F.decl, @Class(constants.%A) [concrete = constants.%Class.F.805]
// CHECK:STDOUT: %F.ref: %Class.F.type.e68 = name_ref F, %.loc33 [concrete = constants.%Class.F.805]
// CHECK:STDOUT: %Class.F.bound: <bound method> = bound_method %c.ref, %F.ref
// CHECK:STDOUT: %Class.F.specific_fn: <specific function> = specific_function %F.ref, @Class.F(constants.%A, constants.%A) [concrete = constants.%Class.F.specific_fn.0bd]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %Class.F.specific_fn
// CHECK:STDOUT: %.loc32_41.1: ref %A = splice_block %return.param {}
// CHECK:STDOUT: %Class.F.call: init %A to %.loc32_41.1 = call %bound_method(%c.ref)
// CHECK:STDOUT: return %Class.F.call to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class(constants.%T) {
// CHECK:STDOUT: %T.loc18_14.1 => constants.%T
// CHECK:STDOUT:
@@ -337,6 +450,8 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.Get => constants.%Class.Get.ceb
// CHECK:STDOUT: %Class.GetNoDeduce.type => constants.%Class.GetNoDeduce.type.83e
// CHECK:STDOUT: %Class.GetNoDeduce => constants.%Class.GetNoDeduce.a04
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type.982
// CHECK:STDOUT: %Class.F => constants.%Class.F.c63
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.Get(constants.%T, constants.%U) {
@@ -370,6 +485,40 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.GetNoDeduce.specific_fn.loc20_53.2 => constants.%Class.GetNoDeduce.specific_fn.def
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class(constants.%U) {
// CHECK:STDOUT: %T.loc18_14.1 => constants.%U
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %Class.Get.type => constants.%Class.Get.type.3dc
// CHECK:STDOUT: %Class.Get => constants.%Class.Get.d1f
// CHECK:STDOUT: %Class.GetNoDeduce.type => constants.%Class.GetNoDeduce.type.2cf
// CHECK:STDOUT: %Class.GetNoDeduce => constants.%Class.GetNoDeduce.0cf
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type.6df
// CHECK:STDOUT: %Class.F => constants.%Class.F.c29
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.F(constants.%T, constants.%U) {
// CHECK:STDOUT: %U.loc21_9.1 => constants.%U
// CHECK:STDOUT: %Class.loc21_31.1 => constants.%Class.d74
// CHECK:STDOUT: %pattern_type.loc21_22 => constants.%pattern_type.cc0
// CHECK:STDOUT: %.loc21_37.2 => constants.%.822
// CHECK:STDOUT: %pattern_type.loc21_37 => constants.%pattern_type.946
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.F(constants.%U, constants.%U) {
// CHECK:STDOUT: %U.loc21_9.1 => constants.%U
// CHECK:STDOUT: %Class.loc21_31.1 => constants.%Class.d74
// CHECK:STDOUT: %pattern_type.loc21_22 => constants.%pattern_type.cc0
// CHECK:STDOUT: %.loc21_37.2 => constants.%.822
// CHECK:STDOUT: %pattern_type.loc21_37 => constants.%pattern_type.946
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%require_complete.716
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type.6df
// CHECK:STDOUT: %Class.F => constants.%Class.F.c29
// CHECK:STDOUT: %Class.F.specific_fn.loc21_52.2 => constants.%Class.F.specific_fn.844
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class(constants.%A) {
// CHECK:STDOUT: %T.loc18_14.1 => constants.%A
// CHECK:STDOUT:
@@ -378,6 +527,8 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.Get => constants.%Class.Get.e47
// CHECK:STDOUT: %Class.GetNoDeduce.type => constants.%Class.GetNoDeduce.type.7e9
// CHECK:STDOUT: %Class.GetNoDeduce => constants.%Class.GetNoDeduce.c1e
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type.e68
// CHECK:STDOUT: %Class.F => constants.%Class.F.805
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.Get(constants.%A, constants.%B) {
@@ -411,3 +562,17 @@ fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
// CHECK:STDOUT: %Class.GetNoDeduce.specific_fn.loc20_53.2 => constants.%Class.GetNoDeduce.specific_fn.931
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Class.F(constants.%A, constants.%A) {
// CHECK:STDOUT: %U.loc21_9.1 => constants.%A
// CHECK:STDOUT: %Class.loc21_31.1 => constants.%Class.30a
// CHECK:STDOUT: %pattern_type.loc21_22 => constants.%pattern_type.89e
// CHECK:STDOUT: %.loc21_37.2 => constants.%.cbf
// CHECK:STDOUT: %pattern_type.loc21_37 => constants.%pattern_type.9ef
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.357
// CHECK:STDOUT: %Class.F.type => constants.%Class.F.type.e68
// CHECK:STDOUT: %Class.F => constants.%Class.F.805
// CHECK:STDOUT: %Class.F.specific_fn.loc21_52.2 => constants.%Class.F.specific_fn.0bd
// CHECK:STDOUT: }
// CHECK:STDOUT:
+14 -9
View File
@@ -23,6 +23,7 @@ class Class(T:! type) {
}
}
// CHECK:STDOUT: --- self.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -182,11 +183,11 @@ class Class(T:! type) {
// CHECK:STDOUT: %Class.MakeClass: @Class.F.%Class.MakeClass.type (%Class.MakeClass.type) = struct_value () [symbolic = %Class.MakeClass (constants.%Class.MakeClass)]
// CHECK:STDOUT: %Class.MakeClass.specific_fn.loc22_26.2: <specific function> = specific_function %Class.MakeClass, @Class.MakeClass(%T) [symbolic = %Class.MakeClass.specific_fn.loc22_26.2 (constants.%Class.MakeClass.specific_fn)]
// CHECK:STDOUT: %Destroy.lookup_impl_witness: <witness> = lookup_impl_witness %Class.loc21_26.2, @Destroy [symbolic = %Destroy.lookup_impl_witness (constants.%Destroy.lookup_impl_witness)]
// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %Class.loc21_26.2, (%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.297)]
// CHECK:STDOUT: %.loc22_5.2: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet [symbolic = %.loc22_5.2 (constants.%.73f)]
// CHECK:STDOUT: %impl.elem0.loc22_5.2: @Class.F.%.loc22_5.2 (%.73f) = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc22_5.2: <specific function> = specific_impl_function %impl.elem0.loc22_5.2, @Destroy.WithSelf.Op(%Destroy.facet) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Destroy.facet.loc22_5.2: %Destroy.type = facet_value %Class.loc21_26.2, (%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %Destroy.WithSelf.Op.type: type = fn_type @Destroy.WithSelf.Op, @Destroy.WithSelf(%Destroy.facet.loc22_5.2) [symbolic = %Destroy.WithSelf.Op.type (constants.%Destroy.WithSelf.Op.type.297)]
// CHECK:STDOUT: %.loc22_5.3: type = fn_type_with_self_type %Destroy.WithSelf.Op.type, %Destroy.facet.loc22_5.2 [symbolic = %.loc22_5.3 (constants.%.73f)]
// CHECK:STDOUT: %impl.elem0.loc22_5.2: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access %Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc22_5.2: <specific function> = specific_impl_function %impl.elem0.loc22_5.2, @Destroy.WithSelf.Op(%Destroy.facet.loc22_5.2) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
@@ -198,8 +199,8 @@ class Class(T:! type) {
// CHECK:STDOUT: %.loc21_30: @Class.F.%Class.MakeSelf.type (%Class.MakeSelf.type) = specific_constant @Class.%Class.MakeSelf.decl, @Class(constants.%T) [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %MakeSelf.ref: @Class.F.%Class.MakeSelf.type (%Class.MakeSelf.type) = name_ref MakeSelf, %.loc21_30 [symbolic = %Class.MakeSelf (constants.%Class.MakeSelf)]
// CHECK:STDOUT: %Class.MakeSelf.specific_fn.loc21_30.1: <specific function> = specific_function %MakeSelf.ref, @Class.MakeSelf(constants.%T) [symbolic = %Class.MakeSelf.specific_fn.loc21_30.2 (constants.%Class.MakeSelf.specific_fn)]
// CHECK:STDOUT: %.loc21_5: ref @Class.F.%Class.loc21_26.2 (%Class) = splice_block %c.var {}
// CHECK:STDOUT: %Class.MakeSelf.call: init @Class.F.%Class.loc21_26.2 (%Class) to %.loc21_5 = call %Class.MakeSelf.specific_fn.loc21_30.1()
// CHECK:STDOUT: %.loc21_5.1: ref @Class.F.%Class.loc21_26.2 (%Class) = splice_block %c.var {}
// CHECK:STDOUT: %Class.MakeSelf.call: init @Class.F.%Class.loc21_26.2 (%Class) to %.loc21_5.1 = call %Class.MakeSelf.specific_fn.loc21_30.1()
// CHECK:STDOUT: assign %c.var, %Class.MakeSelf.call
// CHECK:STDOUT: %.loc21_26: type = splice_block %Class.loc21_26.1 [symbolic = %Class.loc21_26.2 (constants.%Class)] {
// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [concrete = constants.%Class.generic]
@@ -223,13 +224,17 @@ class Class(T:! type) {
// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc22_19.2 [symbolic = %Class.loc21_26.2 (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %s: ref @Class.F.%Class.loc21_26.2 (%Class) = ref_binding s, %s.var
// CHECK:STDOUT: %impl.elem0.loc22_5.1: @Class.F.%.loc22_5.2 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %impl.elem0.loc22_5.1: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc22_5.1: <bound method> = bound_method %s.var, %impl.elem0.loc22_5.1
// CHECK:STDOUT: %Destroy.facet.loc22_5.1: %Destroy.type = facet_value constants.%Class, (constants.%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %.loc22_5.2: %Destroy.type = converted constants.%Class, %Destroy.facet.loc22_5.1 [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %specific_impl_fn.loc22_5.1: <specific function> = specific_impl_function %impl.elem0.loc22_5.1, @Destroy.WithSelf.Op(constants.%Destroy.facet.86d) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc22_5.2: <bound method> = bound_method %s.var, %specific_impl_fn.loc22_5.1
// CHECK:STDOUT: %Destroy.WithSelf.Op.call.loc22: init %empty_tuple.type = call %bound_method.loc22_5.2(%s.var)
// CHECK:STDOUT: %impl.elem0.loc21: @Class.F.%.loc22_5.2 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %impl.elem0.loc21: @Class.F.%.loc22_5.3 (%.73f) = impl_witness_access constants.%Destroy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc22_5.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %bound_method.loc21_5.1: <bound method> = bound_method %c.var, %impl.elem0.loc21
// CHECK:STDOUT: %Destroy.facet.loc21: %Destroy.type = facet_value constants.%Class, (constants.%Destroy.lookup_impl_witness) [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %.loc21_5.2: %Destroy.type = converted constants.%Class, %Destroy.facet.loc21 [symbolic = %Destroy.facet.loc22_5.2 (constants.%Destroy.facet.86d)]
// CHECK:STDOUT: %specific_impl_fn.loc21: <specific function> = specific_impl_function %impl.elem0.loc21, @Destroy.WithSelf.Op(constants.%Destroy.facet.86d) [symbolic = %specific_impl_fn.loc22_5.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %bound_method.loc21_5.2: <bound method> = bound_method %c.var, %specific_impl_fn.loc21
// CHECK:STDOUT: %Destroy.WithSelf.Op.call.loc21: init %empty_tuple.type = call %bound_method.loc21_5.2(%c.var)
+7 -6
View File
@@ -26,8 +26,8 @@ class Field {
class ForwardDeclared;
class ForwardDeclared {
fn F[self: Self]();
fn G[ref self: Self]();
fn F(self);
fn G(ref self);
}
class Incomplete;
@@ -53,6 +53,7 @@ fn Run() {
var unused e: Incomplete*;
}
// CHECK:STDOUT: --- a.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -263,12 +264,12 @@ fn Run() {
// CHECK:STDOUT: %.860: %Field.elem = field_decl x, element0 [concrete]
// CHECK:STDOUT: %Main.import_ref.8f24d3.2: <witness> = import_ref Main//a, loc16_1, loaded [concrete = constants.%complete_type.357]
// CHECK:STDOUT: %Main.import_ref.fbb203.1 = import_ref Main//a, inst{{[0-9A-F]+}} [no loc], unloaded
// CHECK:STDOUT: %Main.import_ref.bc9: %ForwardDeclared.F.type = import_ref Main//a, loc14_21, loaded [concrete = constants.%ForwardDeclared.F]
// CHECK:STDOUT: %Main.import_ref.341: %ForwardDeclared.G.type = import_ref Main//a, loc15_25, loaded [concrete = constants.%ForwardDeclared.G]
// CHECK:STDOUT: %Main.import_ref.bc9: %ForwardDeclared.F.type = import_ref Main//a, loc14_13, loaded [concrete = constants.%ForwardDeclared.F]
// CHECK:STDOUT: %Main.import_ref.341: %ForwardDeclared.G.type = import_ref Main//a, loc15_17, loaded [concrete = constants.%ForwardDeclared.G]
// CHECK:STDOUT: %Main.import_ref.8f24d3.3: <witness> = import_ref Main//a, loc16_1, loaded [concrete = constants.%complete_type.357]
// CHECK:STDOUT: %Main.import_ref.fbb203.2 = import_ref Main//a, inst{{[0-9A-F]+}} [no loc], unloaded
// CHECK:STDOUT: %Main.import_ref.439 = import_ref Main//a, loc14_21, unloaded
// CHECK:STDOUT: %Main.import_ref.c46 = import_ref Main//a, loc15_25, unloaded
// CHECK:STDOUT: %Main.import_ref.439 = import_ref Main//a, loc14_13, unloaded
// CHECK:STDOUT: %Main.import_ref.c46 = import_ref Main//a, loc15_17, unloaded
// CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
// CHECK:STDOUT: %Core.import_ref.e5f: @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op.type (%ptr.as.Copy.impl.Op.type.ff5) = import_ref Core//prelude/parts/copy, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op (constants.%ptr.as.Copy.impl.Op.ce9)]
// CHECK:STDOUT: %Copy.impl_witness_table.4f1 = impl_witness_table (%Core.import_ref.e5f), @ptr.as.Copy.impl [concrete]
+1 -1
View File
@@ -13,7 +13,7 @@
class Class;
class IncompleteRefSelf {
fn F[ref self: Class]();
fn F(ref self: Class);
}
fn CallIncompleteRefSelf(p: Class*) {
@@ -15,10 +15,10 @@
base class Base {
var a: i32;
fn F[ref self: Self]();
fn F(ref self);
}
fn Base.F[ref self: Self]() {
fn Base.F(ref self) {
self.a = 1;
}
@@ -15,15 +15,15 @@
class Derived;
base class Base {
fn F[self: Self]() -> i32;
fn G[self: Derived]() -> i32;
fn F(self) -> i32;
fn G(self: Derived) -> i32;
}
class Derived {
extend base: Base;
fn F[self: Self]();
fn G[self: Self]();
fn F(self);
fn G(self);
}
fn Call(a: Derived) -> i32 {
@@ -13,17 +13,17 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/inheritance/base_method_shadow.carbon
base class A {
fn F[ref self: Self]();
fn F(ref self);
}
base class B {
extend base: A;
fn F[ref self: Self]();
fn F(ref self);
}
class C {
extend base: B;
fn F[ref self: Self]();
fn F(ref self);
}
class D {
@@ -17,8 +17,8 @@
library "[[@TEST_NAME]]";
base class Base {
fn F[self: Self]();
fn Unused[self: Self]();
fn F(self);
fn Unused(self);
var x: i32;
var unused_y: i32;
@@ -40,6 +40,7 @@ fn Run() {
a.F();
}
// CHECK:STDOUT: --- a.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
@@ -197,8 +198,8 @@ fn Run() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Main.import_ref.6fc: <witness> = import_ref Main//a, loc10_1, loaded [concrete = constants.%complete_type.6c3]
// CHECK:STDOUT: %Main.import_ref.d68 = import_ref Main//a, inst{{[0-9A-F]+}} [no loc], unloaded
// CHECK:STDOUT: %Main.import_ref.bc9: %Base.F.type = import_ref Main//a, loc5_21, loaded [concrete = constants.%Base.F]
// CHECK:STDOUT: %Main.import_ref.077 = import_ref Main//a, loc6_26, unloaded
// CHECK:STDOUT: %Main.import_ref.bc9: %Base.F.type = import_ref Main//a, loc5_13, loaded [concrete = constants.%Base.F]
// CHECK:STDOUT: %Main.import_ref.077 = import_ref Main//a, loc6_18, unloaded
// CHECK:STDOUT: %Main.import_ref.230: %Base.elem = import_ref Main//a, loc8_8, loaded [concrete = %.11f]
// CHECK:STDOUT: %Main.import_ref.9f4 = import_ref Main//a, loc9_15, unloaded
// CHECK:STDOUT: %Main.import_ref.60e: <witness> = import_ref Main//a, loc14_1, loaded [concrete = constants.%complete_type.c02]
@@ -19,15 +19,15 @@ base class Base {
class Derived {
extend base: Base;
fn SelfBase[self: Base]() -> i32;
fn RefSelfBase[ref self: Base]();
fn SelfBase(self: Base) -> i32;
fn RefSelfBase(ref self: Base);
}
fn Derived.SelfBase[self: Base]() -> i32 {
fn Derived.SelfBase(self: Base) -> i32 {
return self.a;
}
fn Derived.RefSelfBase[ref self: Base]() {
fn Derived.RefSelfBase(ref self: Base) {
self.a = 1;
}
@@ -0,0 +1,255 @@
// 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/int.carbon
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/method/call_without_method_syntax.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/method/call_without_method_syntax.carbon
// --- call_without_method_syntax.carbon
library "[[@TEST_NAME]]";
class Point {
fn Get(self) -> i32 { return self.x; }
fn First(self, unused other: Point) -> i32 { return self.x; }
var x: i32;
}
// A method is a function whose first parameter is `self`, so it can be called
// as an ordinary function by passing the receiver as the first explicit
// argument. `Point.Get(p)` is equivalent to `p.Get()`.
fn CallGet(p: Point) -> i32 {
return Point.Get(p);
}
// The remaining explicit arguments follow the receiver.
fn CallFirst(p: Point, q: Point) -> i32 {
return Point.First(p, q);
}
// The same works through an alias of the method.
fn CallViaAlias(p: Point) -> i32 {
alias A = Point.Get;
return A(p);
}
// CHECK:STDOUT: --- call_without_method_syntax.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Point: type = class_type @Point [concrete]
// CHECK:STDOUT: %pattern_type.9d8: type = pattern_type %Point [concrete]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %.795: Core.Form = init_form %i32 [concrete]
// CHECK:STDOUT: %pattern_type.6b6: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %Point.Get.type: type = fn_type @Point.Get [concrete]
// CHECK:STDOUT: %Point.Get: %Point.Get.type = struct_value () [concrete]
// CHECK:STDOUT: %Point.First.type: type = fn_type @Point.First [concrete]
// CHECK:STDOUT: %Point.First: %Point.First.type = struct_value () [concrete]
// CHECK:STDOUT: %Point.elem: type = unbound_element_type %Point, %i32 [concrete]
// CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %i32} [concrete]
// CHECK:STDOUT: %complete_type.0c6: <witness> = complete_type_witness %struct_type.x [concrete]
// CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.ac8: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.5e0: %Int.as.Copy.impl.Op.type.ac8 = struct_value () [symbolic]
// CHECK:STDOUT: %Copy.impl_witness.0e0: <witness> = impl_witness imports.%Copy.impl_witness_table.367, @Int.as.Copy.impl(%int_32) [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.type.3f6: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.4f6: %Int.as.Copy.impl.Op.type.3f6 = struct_value () [concrete]
// CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.0e0) [concrete]
// CHECK:STDOUT: %Copy.WithSelf.Op.type.d09: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
// CHECK:STDOUT: %.7a6: type = fn_type_with_self_type %Copy.WithSelf.Op.type.d09, %Copy.facet [concrete]
// CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.4f6, @Int.as.Copy.impl.Op(%int_32) [concrete]
// CHECK:STDOUT: %CallGet.type: type = fn_type @CallGet [concrete]
// CHECK:STDOUT: %CallGet: %CallGet.type = struct_value () [concrete]
// CHECK:STDOUT: %CallFirst.type: type = fn_type @CallFirst [concrete]
// CHECK:STDOUT: %CallFirst: %CallFirst.type = struct_value () [concrete]
// CHECK:STDOUT: %CallViaAlias.type: type = fn_type @CallViaAlias [concrete]
// CHECK:STDOUT: %CallViaAlias: %CallViaAlias.type = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// CHECK:STDOUT: .Copy = %Core.Copy
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
// CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
// CHECK:STDOUT: %Core.import_ref.cd6: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.ac8) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.5e0)]
// CHECK:STDOUT: %Copy.impl_witness_table.367 = impl_witness_table (%Core.import_ref.cd6), @Int.as.Copy.impl [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .Point = %Point.decl
// CHECK:STDOUT: .CallGet = %CallGet.decl
// CHECK:STDOUT: .CallFirst = %CallFirst.decl
// CHECK:STDOUT: .CallViaAlias = %CallViaAlias.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Point.decl: type = class_decl @Point [concrete = constants.%Point] {} {}
// CHECK:STDOUT: %CallGet.decl: %CallGet.type = fn_decl @CallGet [concrete = constants.%CallGet] {
// CHECK:STDOUT: %p.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %p.patt: %pattern_type.9d8 = at_binding_pattern p, %p.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc13: Core.Form = init_form %i32 [concrete = constants.%.795]
// CHECK:STDOUT: %p.param: %Point = value_param call_param0
// CHECK:STDOUT: %Point.ref.loc13: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %p: %Point = value_binding p, %p.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %CallFirst.decl: %CallFirst.type = fn_decl @CallFirst [concrete = constants.%CallFirst] {
// CHECK:STDOUT: %p.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %p.patt: %pattern_type.9d8 = at_binding_pattern p, %p.param_patt [concrete]
// CHECK:STDOUT: %q.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %q.patt: %pattern_type.9d8 = at_binding_pattern q, %q.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc18: Core.Form = init_form %i32 [concrete = constants.%.795]
// CHECK:STDOUT: %p.param: %Point = value_param call_param0
// CHECK:STDOUT: %Point.ref.loc18_17: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %p: %Point = value_binding p, %p.param
// CHECK:STDOUT: %q.param: %Point = value_param call_param1
// CHECK:STDOUT: %Point.ref.loc18_27: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %q: %Point = value_binding q, %q.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %CallViaAlias.decl: %CallViaAlias.type = fn_decl @CallViaAlias [concrete = constants.%CallViaAlias] {
// CHECK:STDOUT: %p.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %p.patt: %pattern_type.9d8 = at_binding_pattern p, %p.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc23: Core.Form = init_form %i32 [concrete = constants.%.795]
// CHECK:STDOUT: %p.param: %Point = value_param call_param0
// CHECK:STDOUT: %Point.ref.loc23: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %p: %Point = value_binding p, %p.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @Point {
// CHECK:STDOUT: %Point.Get.decl: %Point.Get.type = fn_decl @Point.Get [concrete = constants.%Point.Get] {
// CHECK:STDOUT: %self.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: %pattern_type.9d8 = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc4_19: Core.Form = init_form %i32 [concrete = constants.%.795]
// CHECK:STDOUT: %self.param: %Point = value_param call_param0
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Point [concrete = constants.%Point]
// CHECK:STDOUT: %self: %Point = value_binding self, %self.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Point.First.decl: %Point.First.type = fn_decl @Point.First [concrete = constants.%Point.First] {
// CHECK:STDOUT: %self.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: %pattern_type.9d8 = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %other.param_patt: %pattern_type.9d8 = value_param_pattern [concrete]
// CHECK:STDOUT: %other.patt: %pattern_type.9d8 = at_binding_pattern other, %other.param_patt [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.6b6 = out_param_pattern [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.6b6 = return_slot_pattern %return.param_patt, %i32 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc5_42: Core.Form = init_form %i32 [concrete = constants.%.795]
// CHECK:STDOUT: %self.param: %Point = value_param call_param0
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Point [concrete = constants.%Point]
// CHECK:STDOUT: %self: %Point = value_binding self, %self.param
// CHECK:STDOUT: %other.param: %Point = value_param call_param1
// CHECK:STDOUT: %Point.ref: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %other: %Point = value_binding other, %other.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc7: %Point.elem = field_decl x, element0 [concrete]
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x [concrete = constants.%complete_type.0c6]
// CHECK:STDOUT: complete_type_witness = %complete_type
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = constants.%Point
// CHECK:STDOUT: .Get = %Point.Get.decl
// CHECK:STDOUT: .Point = <poisoned>
// CHECK:STDOUT: .First = %Point.First.decl
// CHECK:STDOUT: .x = %.loc7
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Point.Get(%self.param: %Point) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: %Point = name_ref self, %self
// CHECK:STDOUT: %x.ref: %Point.elem = name_ref x, @Point.%.loc7 [concrete = @Point.%.loc7]
// CHECK:STDOUT: %.loc4_36.1: ref %i32 = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc4_36.2: %i32 = acquire_value %.loc4_36.1
// CHECK:STDOUT: %impl.elem0: %.7a6 = impl_witness_access constants.%Copy.impl_witness.0e0, element0 [concrete = constants.%Int.as.Copy.impl.Op.4f6]
// CHECK:STDOUT: %bound_method.loc4_36.1: <bound method> = bound_method %.loc4_36.2, %impl.elem0
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
// CHECK:STDOUT: %bound_method.loc4_36.2: <bound method> = bound_method %.loc4_36.2, %specific_fn
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc4_36.2(%.loc4_36.2)
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Point.First(%self.param: %Point, %other.param: %Point) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %self.ref: %Point = name_ref self, %self
// CHECK:STDOUT: %x.ref: %Point.elem = name_ref x, @Point.%.loc7 [concrete = @Point.%.loc7]
// CHECK:STDOUT: %.loc5_59.1: ref %i32 = class_element_access %self.ref, element0
// CHECK:STDOUT: %.loc5_59.2: %i32 = acquire_value %.loc5_59.1
// CHECK:STDOUT: %impl.elem0: %.7a6 = impl_witness_access constants.%Copy.impl_witness.0e0, element0 [concrete = constants.%Int.as.Copy.impl.Op.4f6]
// CHECK:STDOUT: %bound_method.loc5_59.1: <bound method> = bound_method %.loc5_59.2, %impl.elem0
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
// CHECK:STDOUT: %bound_method.loc5_59.2: <bound method> = bound_method %.loc5_59.2, %specific_fn
// CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc5_59.2(%.loc5_59.2)
// CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallGet(%p.param: %Point) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Point.ref.loc14: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %Get.ref: %Point.Get.type = name_ref Get, @Point.%Point.Get.decl [concrete = constants.%Point.Get]
// CHECK:STDOUT: %p.ref: %Point = name_ref p, %p
// CHECK:STDOUT: %Point.Get.call: init %i32 = call %Get.ref(%p.ref)
// CHECK:STDOUT: return %Point.Get.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallFirst(%p.param: %Point, %q.param: %Point) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Point.ref.loc19: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %First.ref: %Point.First.type = name_ref First, @Point.%Point.First.decl [concrete = constants.%Point.First]
// CHECK:STDOUT: %p.ref: %Point = name_ref p, %p
// CHECK:STDOUT: %q.ref: %Point = name_ref q, %q
// CHECK:STDOUT: %Point.First.call: init %i32 = call %First.ref(%p.ref, %q.ref)
// CHECK:STDOUT: return %Point.First.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @CallViaAlias(%p.param: %Point) -> out %return.param: %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Point.ref.loc24: type = name_ref Point, file.%Point.decl [concrete = constants.%Point]
// CHECK:STDOUT: %Get.ref: %Point.Get.type = name_ref Get, @Point.%Point.Get.decl [concrete = constants.%Point.Get]
// CHECK:STDOUT: %A: %Point.Get.type = alias_binding A, %Get.ref [concrete = constants.%Point.Get]
// CHECK:STDOUT: %A.ref: %Point.Get.type = name_ref A, %A [concrete = constants.%Point.Get]
// CHECK:STDOUT: %p.ref: %Point = name_ref p, %p
// CHECK:STDOUT: %Point.Get.call: init %i32 = call %A.ref(%p.ref)
// CHECK:STDOUT: return %Point.Get.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -0,0 +1,60 @@
// 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/int.carbon
//
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/method/fail_call_without_method_syntax.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/method/fail_call_without_method_syntax.carbon
// --- fail_call_without_method_syntax.carbon
library "[[@TEST_NAME]]";
class Point {
fn Get(self) -> i32 { return self.x; }
var x: i32;
}
class Other {}
// When a method is called as an ordinary function, `self` is an ordinary
// argument, so the usual arity and conversion rules apply.
fn TooFew() -> i32 {
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE+7]]:10: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: return Point.Get();
// CHECK:STDERR: ^~~~~~~~~~~
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE-13]]:3: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Get(self) -> i32 { return self.x; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
return Point.Get();
}
fn TooMany(p: Point) -> i32 {
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE+7]]:10: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: return Point.Get(p, p);
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE-24]]:3: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn Get(self) -> i32 { return self.x; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
return Point.Get(p, p);
}
fn WrongSelfType(o: Other) -> i32 {
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE+10]]:20: error: cannot implicitly convert expression of type `Other` to `Point` [ConversionFailure]
// CHECK:STDERR: return Point.Get(o);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE+7]]:20: note: type `Other` does not implement interface `Core.ImplicitAs(Point)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: return Point.Get(o);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_call_without_method_syntax.carbon:[[@LINE-38]]:10: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn Get(self) -> i32 { return self.x; }
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
return Point.Get(o);
}
@@ -14,24 +14,24 @@ class I {}
class Class(T:! type) {
var a: T;
fn F[self: Self](n: T);
fn F(self, n: T);
}
// TODO: The follow-on errors here aren't great. Investigate whether we can
// enter the scope anyway if the parameters don't match.
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+15]]:17: error: type `<pattern for I>` of parameter 1 in redeclaration differs from previous parameter type `<pattern for type>` [RedeclParamDiffersType]
// CHECK:STDERR: fn Class(unused N:! I).F[unused self: Self](unused n: T) {}
// CHECK:STDERR: fn Class(unused N:! I).F(unused self, unused n: T) {}
// CHECK:STDERR: ^~~~~
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE-10]]:13: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
// CHECK:STDERR: class Class(T:! type) {
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+8]]:39: error: name `Self` not found [NameNotFound]
// CHECK:STDERR: fn Class(unused N:! I).F[unused self: Self](unused n: T) {}
// CHECK:STDERR: ^~~~
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+8]]:33: error: name `Self` not found [NameNotFound]
// CHECK:STDERR: fn Class(unused N:! I).F(unused self, unused n: T) {}
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+4]]:55: error: name `T` not found [NameNotFound]
// CHECK:STDERR: fn Class(unused N:! I).F[unused self: Self](unused n: T) {}
// CHECK:STDERR: ^
// CHECK:STDERR: fail_generic_method.carbon:[[@LINE+4]]:49: error: name `T` not found [NameNotFound]
// CHECK:STDERR: fn Class(unused N:! I).F(unused self, unused n: T) {}
// CHECK:STDERR: ^
// CHECK:STDERR:
fn Class(unused N:! I).F[unused self: Self](unused n: T) {}
fn Class(unused N:! I).F(unused self, unused n: T) {}
+9 -16
View File
@@ -12,7 +12,7 @@
class Class {
fn NoSelf();
fn WithSelf[self: Class]();
fn WithSelf(self: Class);
}
alias A = Class.WithSelf;
@@ -22,29 +22,22 @@ fn F(c: Class) {
c.WithSelf();
Class.NoSelf();
// CHECK:STDERR: fail_method.carbon:[[@LINE+7]]:3: error: missing object argument in method call [MissingObjectInMethodCall]
// CHECK:STDERR: fail_method.carbon:[[@LINE+7]]:3: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: Class.WithSelf();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_method.carbon:[[@LINE-13]]:3: note: calling function declared here [InCallToFunction]
// CHECK:STDERR: fn WithSelf[self: Class]();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_method.carbon:[[@LINE-13]]:3: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn WithSelf(self: Class);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Class.WithSelf();
// CHECK:STDERR: fail_method.carbon:[[@LINE+7]]:3: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch]
// CHECK:STDERR: Class.WithSelf(c);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_method.carbon:[[@LINE-21]]:3: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn WithSelf[self: Class]();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
Class.WithSelf(c);
// CHECK:STDERR: fail_method.carbon:[[@LINE+7]]:3: error: missing object argument in method call [MissingObjectInMethodCall]
// CHECK:STDERR: fail_method.carbon:[[@LINE+7]]:3: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch]
// CHECK:STDERR: A();
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_method.carbon:[[@LINE-30]]:3: note: calling function declared here [InCallToFunction]
// CHECK:STDERR: fn WithSelf[self: Class]();
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_method.carbon:[[@LINE-23]]:3: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn WithSelf(self: Class);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
A();
}
@@ -13,47 +13,47 @@
class FinalClass {
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE+7]]:3: error: `abstract` not allowed; requires `abstract` class scope [ModifierAbstractNotAllowed]
// CHECK:STDERR: abstract fn Abstract[self: Self]();
// CHECK:STDERR: abstract fn Abstract(self);
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE-5]]:1: note: containing definition here [ModifierNotInContext]
// CHECK:STDERR: class FinalClass {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
abstract fn Abstract[self: Self]();
abstract fn Abstract(self);
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE+7]]:3: error: `virtual` not allowed; requires `abstract` or `base` class scope [ModifierVirtualNotAllowed]
// CHECK:STDERR: virtual fn Virtual[self: Self]();
// CHECK:STDERR: virtual fn Virtual(self);
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE-14]]:1: note: containing definition here [ModifierNotInContext]
// CHECK:STDERR: class FinalClass {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
virtual fn Virtual[self: Self]();
virtual fn Virtual(self);
}
abstract class AbstractClass {
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE+4]]:3: error: `default` not allowed; requires interface scope [ModifierRequiresInterface]
// CHECK:STDERR: default fn Default[self: Self]();
// CHECK:STDERR: default fn Default(self);
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
default fn Default[self: Self]();
default fn Default(self);
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE+4]]:3: error: `final` not allowed; requires interface scope [ModifierRequiresInterface]
// CHECK:STDERR: final fn Final[self: Self]();
// CHECK:STDERR: final fn Final(self);
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
final fn Final[self: Self]();
final fn Final(self);
}
base class BaseClass {
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE+7]]:3: error: `abstract` not allowed; requires `abstract` class scope [ModifierAbstractNotAllowed]
// CHECK:STDERR: abstract fn Abstract[self: Self]();
// CHECK:STDERR: abstract fn Abstract(self);
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR: fail_method_modifiers.carbon:[[@LINE-5]]:1: note: containing definition here [ModifierNotInContext]
// CHECK:STDERR: base class BaseClass {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
abstract fn Abstract[self: Self]();
abstract fn Abstract(self);
}
+23 -22
View File
@@ -14,10 +14,11 @@
class Class(T:! type) {
var a: T;
fn F[self: Self](n: T);
fn F(self, n: T);
}
fn Class(T:! type).F[unused self: Self](unused n: T) {}
fn Class(T:! type).F(unused self, unused n: T) {}
// CHECK:STDOUT: --- generic_method.carbon
// CHECK:STDOUT:
@@ -63,10 +64,10 @@ fn Class(T:! type).F[unused self: Self](unused n: T) {}
// CHECK:STDOUT: %T.loc15_14.2: type = symbolic_binding T, 0 [symbolic = %T.loc15_14.1 (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %Class.F.decl: %Class.F.type = fn_decl @Class.F [symbolic = constants.%Class.F] {
// CHECK:STDOUT: %self.param_patt: @Class.F.%pattern_type.loc17_12 (%pattern_type.36e) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.F.%pattern_type.loc17_12 (%pattern_type.36e) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %n.param_patt: @Class.F.%pattern_type.loc17_21 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %n.patt: @Class.F.%pattern_type.loc17_21 (%pattern_type.51d) = at_binding_pattern n, %n.param_patt [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.F.%pattern_type.loc17_8 (%pattern_type.36e) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.F.%pattern_type.loc17_8 (%pattern_type.36e) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %n.param_patt: @Class.F.%pattern_type.loc17_15 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %n.patt: @Class.F.%pattern_type.loc17_15 (%pattern_type.51d) = at_binding_pattern n, %n.param_patt [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc20_14.1: type = splice_block %.loc20_14.2 [concrete = type] {
// CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
@@ -74,9 +75,9 @@ fn Class(T:! type).F[unused self: Self](unused n: T) {}
// CHECK:STDOUT: }
// CHECK:STDOUT: %T.loc20: type = symbolic_binding T, 0 [symbolic = @Class.%T.loc15_14.1 (constants.%T)]
// CHECK:STDOUT: %self.param.loc20: @Class.F.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc20_35.1: type = splice_block %Self.ref.loc20 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc20_35.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc20: type = name_ref Self, %.loc20_35.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc20_29.1: type = splice_block %Self.ref.loc20 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc20_29.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc20: type = name_ref Self, %.loc20_29.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc20: @Class.F.%Class (%Class) = value_binding self, %self.param.loc20
// CHECK:STDOUT: %n.param.loc20: @Class.F.%T.loc17 (%T) = value_param call_param1
@@ -100,15 +101,15 @@ fn Class(T:! type).F[unused self: Self](unused n: T) {}
// CHECK:STDOUT: class {
// CHECK:STDOUT: %.loc16: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [concrete]
// CHECK:STDOUT: %Class.F.decl: @Class.%Class.F.type (%Class.F.type) = fn_decl @Class.F [symbolic = @Class.%Class.F (constants.%Class.F)] {
// CHECK:STDOUT: %self.param_patt: @Class.F.%pattern_type.loc17_12 (%pattern_type.36e) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.F.%pattern_type.loc17_12 (%pattern_type.36e) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %n.param_patt: @Class.F.%pattern_type.loc17_21 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %n.patt: @Class.F.%pattern_type.loc17_21 (%pattern_type.51d) = at_binding_pattern n, %n.param_patt [concrete]
// CHECK:STDOUT: %self.param_patt: @Class.F.%pattern_type.loc17_8 (%pattern_type.36e) = value_param_pattern [concrete]
// CHECK:STDOUT: %self.patt: @Class.F.%pattern_type.loc17_8 (%pattern_type.36e) = at_binding_pattern self, %self.param_patt [concrete]
// CHECK:STDOUT: %n.param_patt: @Class.F.%pattern_type.loc17_15 (%pattern_type.51d) = value_param_pattern [concrete]
// CHECK:STDOUT: %n.patt: @Class.F.%pattern_type.loc17_15 (%pattern_type.51d) = at_binding_pattern n, %n.param_patt [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %self.param.loc17: @Class.F.%Class (%Class) = value_param call_param0
// CHECK:STDOUT: %.loc17_14.1: type = splice_block %Self.ref.loc17 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc17_14.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, %.loc17_14.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %.loc17_8.1: type = splice_block %Self.ref.loc17 [symbolic = %Class (constants.%Class)] {
// CHECK:STDOUT: %.loc17_8.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %Self.ref.loc17: type = name_ref Self, %.loc17_8.2 [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %self.loc17: @Class.F.%Class (%Class) = value_binding self, %self.param.loc17
// CHECK:STDOUT: %n.param.loc17: @Class.F.%T.loc17 (%T) = value_param call_param1
@@ -129,12 +130,12 @@ fn Class(T:! type).F[unused self: Self](unused n: T) {}
// CHECK:STDOUT: generic fn @Class.F(@Class.%T.loc15_14.2: type) {
// CHECK:STDOUT: %T.loc17: type = symbolic_binding T, 0 [symbolic = %T.loc17 (constants.%T)]
// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.loc17) [symbolic = %Class (constants.%Class)]
// CHECK:STDOUT: %pattern_type.loc17_12: type = pattern_type %Class [symbolic = %pattern_type.loc17_12 (constants.%pattern_type.36e)]
// CHECK:STDOUT: %pattern_type.loc17_21: type = pattern_type %T.loc17 [symbolic = %pattern_type.loc17_21 (constants.%pattern_type.51d)]
// CHECK:STDOUT: %pattern_type.loc17_8: type = pattern_type %Class [symbolic = %pattern_type.loc17_8 (constants.%pattern_type.36e)]
// CHECK:STDOUT: %pattern_type.loc17_15: type = pattern_type %T.loc17 [symbolic = %pattern_type.loc17_15 (constants.%pattern_type.51d)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete.loc20_33: <witness> = require_complete_type %Class [symbolic = %require_complete.loc20_33 (constants.%require_complete.4d9)]
// CHECK:STDOUT: %require_complete.loc20_49: <witness> = require_complete_type %T.loc17 [symbolic = %require_complete.loc20_49 (constants.%require_complete.944)]
// CHECK:STDOUT: %require_complete.loc20_29: <witness> = require_complete_type %Class [symbolic = %require_complete.loc20_29 (constants.%require_complete.4d9)]
// CHECK:STDOUT: %require_complete.loc20_43: <witness> = require_complete_type %T.loc17 [symbolic = %require_complete.loc20_43 (constants.%require_complete.944)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%self.param.loc20: @Class.F.%Class (%Class), %n.param.loc20: @Class.F.%T.loc17 (%T)) {
// CHECK:STDOUT: !entry:
@@ -158,7 +159,7 @@ fn Class(T:! type).F[unused self: Self](unused n: T) {}
// CHECK:STDOUT: specific @Class.F(constants.%T) {
// CHECK:STDOUT: %T.loc17 => constants.%T
// CHECK:STDOUT: %Class => constants.%Class
// CHECK:STDOUT: %pattern_type.loc17_12 => constants.%pattern_type.36e
// CHECK:STDOUT: %pattern_type.loc17_21 => constants.%pattern_type.51d
// CHECK:STDOUT: %pattern_type.loc17_8 => constants.%pattern_type.36e
// CHECK:STDOUT: %pattern_type.loc17_15 => constants.%pattern_type.51d
// CHECK:STDOUT: }
// CHECK:STDOUT:
+3 -3
View File
@@ -13,15 +13,15 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/method/method.carbon
class Class {
fn F[self: Self]() -> i32;
fn G[ref self: Self]() -> i32;
fn F(self) -> i32;
fn G(ref self) -> i32;
alias A = F;
var k: i32;
}
fn Class.F[self: Self]() -> i32 {
fn Class.F(self) -> i32 {
return self.k;
}
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -15,10 +15,10 @@
class Class;
class Class {
fn F[self: Self](b: ());
fn F(self, b: ());
}
fn Class.F[unused self: Self](unused b: ()) {}
fn Class.F(unused self, unused b: ()) {}
// CHECK:STDOUT: --- redeclaration.carbon
// CHECK:STDOUT:
@@ -59,9 +59,9 @@ fn Class.F[unused self: Self](unused b: ()) {}
// CHECK:STDOUT: %Self.ref.loc21: type = name_ref Self, constants.%Class [concrete = constants.%Class]
// CHECK:STDOUT: %self.loc21: %Class = value_binding self, %self.param.loc21
// CHECK:STDOUT: %b.param.loc21: %empty_tuple.type = value_param call_param1
// CHECK:STDOUT: %.loc21_42.1: type = splice_block %.loc21_42.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc21_42.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc21_42.3: type = converted %.loc21_42.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc21_36.1: type = splice_block %.loc21_36.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc21_36.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc21_36.3: type = converted %.loc21_36.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.loc21: %empty_tuple.type = value_binding b, %b.param.loc21
// CHECK:STDOUT: }
@@ -78,9 +78,9 @@ fn Class.F[unused self: Self](unused b: ()) {}
// CHECK:STDOUT: %Self.ref.loc18: type = name_ref Self, constants.%Class [concrete = constants.%Class]
// CHECK:STDOUT: %self.loc18: %Class = value_binding self, %self.param.loc18
// CHECK:STDOUT: %b.param.loc18: %empty_tuple.type = value_param call_param1
// CHECK:STDOUT: %.loc18_24.1: type = splice_block %.loc18_24.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc18_24.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc18_24.3: type = converted %.loc18_24.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc18_18.1: type = splice_block %.loc18_18.3 [concrete = constants.%empty_tuple.type] {
// CHECK:STDOUT: %.loc18_18.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc18_18.3: type = converted %.loc18_18.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.loc18: %empty_tuple.type = value_binding b, %b.param.loc18
// CHECK:STDOUT: }
+3 -3
View File
@@ -13,7 +13,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/self/fail_ref_self.carbon
class Class {
fn F[ref self: Self]();
fn F(ref self);
}
fn Make() -> Class;
@@ -23,8 +23,8 @@ fn F(c: Class, p: Class*) {
// CHECK:STDERR: c.F();
// CHECK:STDERR: ^
// CHECK:STDERR: fail_ref_self.carbon:[[@LINE-9]]:8: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: fn F[ref self: Self]();
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: fn F(ref self);
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
c.F();

Some files were not shown because too many files have changed in this diff Show More