---
generated: true
model: claude-sonnet-4-6
generated_at: 2026-06-02T07:02:06+00:00
source_commit: 9c1a6a00ef413932805da5b813465a7a9d517fb9
watched_paths_digest: 4529ccef8fa4b669c0103000293e0d37e98c6300a29e3b6f81b5227c3dea82ab
source_doc: docs/language-reference/types-interface.md
source_doc_digest: 2ed61530bd334a97114c08a34024c5fb9ccf09620d7a60bd6a64f9d345223014
warning: "Auto-generated. May drift from source. Do not edit by hand."
---

# Tests for conformance/types-interface

## Intent

Tests verify interface-type claims in the **language reference** at
[`docs/language-reference/types-interface.md`](../../../../language-reference/types-interface.md).
The bundle exercises: interface declaration syntax and requirement kinds (methods, properties,
constructors, subscripts, call operators, associated types, static const members), conformance
via `struct : IFoo`, interface inheritance, default method implementations, the `override`
modifier, method compatibility rules, visibility rules, generic parameterized interfaces,
interface-typed function parameter specialization, and negative cases for missing requirements
and type restrictions. Functional correctness is verified via `INTERPRET` and `COMPARE_COMPUTE -cpu`;
emission patterns are pinned via `SIMPLE -target` for `hlsl`, `glsl`, `spirv-asm`, `metal`, `wgsl`,
`cuda`, and `cpp` on target-dependent claims (interface dispatch specialization, override dispatch,
generic-interface concrete method names, interface-inheritance concrete methods).

## Claims

### §Syntax / §Description — Interface members

- **C1** An interface may declare any number of member function prototypes without a body; a conforming struct must provide compatible implementations with the same names.
- **C2** An interface may declare member functions _with_ a body (default implementations); the conforming struct inherits these without needing to override them.
- **C3** Inheriting types may override a default member function using the `override` modifier.
- **C4** An interface may declare constructor requirements (`__init(...)`); the conforming struct must provide a matching constructor.
- **C5** An interface may declare property requirements with `get;` and/or `set;` without bodies; the conforming struct provides compatible get/set implementations.
- **C6** A property requirement may alternatively be satisfied by declaring a compatible variable with a matching name in the conforming struct.
- **C7** An interface may declare subscript operator requirements without bodies; the conforming struct provides compatible get/set implementations.
- **C8** An interface may declare function call operator requirements; the conforming struct provides a compatible implementation.
- **C9** An interface may declare associated named types (`associatedtype`); a conforming struct satisfies the requirement by providing a `typealias` with the same name.
- **C10** An associated named type requirement may also be satisfied by declaring a nested struct with the same name in the conforming struct.
- **C11** An associated named type may carry a conformance constraint (`associatedtype T : IFoo`); the provided type must conform to that interface.
- **C12** An interface may declare `static const int` data members without initializers; the conforming struct provides matching static const members.
- **C13** An interface may declare `static const bool` data members; the conforming struct provides matching static const bool members.
- **C14** The type of a `static const` interface requirement must be `int` or `bool`; using `float` is rejected with E30306.
- **C15** Interface member functions may be static or non-static.

### §Description — Compatibility rules

- **C16** A member function implementation is compatible with an interface requirement when the impl function can be called with the interface parameter types and the return type can be converted to the interface return type (Remark 1).
- **C17** A member function whose return type is not convertible to the interface return type is rejected with E38106.
- **C18** A struct that declares conformance to an interface but fails to provide a required method is rejected with E38100.
- **C19** A struct that fails to provide a required associated type is rejected with E38100 naming the missing type.
- **C20** A struct that fails to provide a required static const data member is rejected with E38100 naming the missing member.

### §Description — Visibility

- **C21** Interface member visibility may be declared `public` or `internal`; the default is the same as the interface visibility.
- **C22** When a struct implements an interface member, the implementation's visibility may not be _higher_ than the requirement (higher visibility causes an error); it may be lower.

### §Description — Interface inheritance

- **C23** An interface may inherit from another interface using `:` in the declaration; inherited members add to the inheriting interface.
- **C24** A struct conforming to a child interface must satisfy all requirements from both the child and parent interfaces.

### §Remark 2 — Generic interface

- **C25** An interface may be parameterized with generics (`interface IFoo<T>`); a struct conforms by providing a concrete type argument.

### §Interface-Conforming Variants

- **C26** A variable declared with an interface type is an interface-conforming variant; it may hold any conforming type.
- **C27** Interface-typed function parameters do not impose the variant restrictions when invoked with compile-time-known types.
- **C28** When a function with an interface-typed parameter is called with a compile-time-known concrete type, the function is specialized for that concrete type (no dynamic dispatch overhead).

### §Non-Normative (informational only)

- **C29** Memory layout and dispatch mechanism of interface-conforming variants are explicitly unspecified and non-normative.

## Functional coverage

| Claim                                                                                                                                                                                              | Intent     | Anchor                                                                                                            | Tests                                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| C1 — Method prototype requirement satisfied by conforming struct method.                                                                                                                           | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-basic-declaration.slang`](interface-basic-declaration.slang)                                                                                                                                                                           |
| C2 — Default method body inherited by conforming struct without overriding.                                                                                                                        | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-default-method.slang`](interface-default-method.slang)                                                                                                                                                                                 |
| C3 — `override` modifier on a struct method replaces the interface default; overriding impl is called.                                                                                             | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-override-method.slang`](interface-override-method.slang), [`interface-inheritance-override-example.slang`](interface-inheritance-override-example.slang), [`interface-override-emission.slang`](interface-override-emission.slang)     |
| C4 — Constructor requirement (`__init`) satisfied by a matching constructor in the conforming struct.                                                                                              | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-constructor-requirement.slang`](interface-constructor-requirement.slang)                                                                                                                                                               |
| C5 — Property requirement with get/set satisfied by property accessors in the conforming struct.                                                                                                   | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-property-requirement.slang`](interface-property-requirement.slang)                                                                                                                                                                     |
| C6 — Property requirement satisfied by a plain data member with the same name.                                                                                                                     | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-property-var-satisfy.slang`](interface-property-var-satisfy.slang)                                                                                                                                                                     |
| C7 — Subscript operator requirement satisfied by a `__subscript` with get/set in the conforming struct.                                                                                            | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-subscript-requirement.slang`](interface-subscript-requirement.slang)                                                                                                                                                                   |
| C8 — Call operator requirement satisfied by `operator()` implementation in the conforming struct.                                                                                                  | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-call-op-requirement.slang`](interface-call-op-requirement.slang)                                                                                                                                                                       |
| C9 — `associatedtype` requirement satisfied by `typealias` with the same name.                                                                                                                     | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-associated-type-typealias.slang`](interface-associated-type-typealias.slang)                                                                                                                                                           |
| C10 — `associatedtype` requirement satisfied by a nested struct with the same name.                                                                                                                | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-associated-type-nested-struct.slang`](interface-associated-type-nested-struct.slang)                                                                                                                                                   |
| C11 — `associatedtype T : IFoo` constraint forces the provided type to conform to `IFoo`.                                                                                                          | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-associated-type-with-constraint.slang`](interface-associated-type-with-constraint.slang)                                                                                                                                               |
| C12–C13 — `static const int` and `static const bool` requirements provided by matching static const members; both are callable.                                                                    | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-static-const-member.slang`](interface-static-const-member.slang)                                                                                                                                                                       |
| C14 — `static const float` in interface requirement is rejected with E30306.                                                                                                                       | negative   | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-static-const-type-restriction-diagnostic.slang`](interface-static-const-type-restriction-diagnostic.slang)                                                                                                                             |
| C15 — Static method requirement satisfied by a static method on the conforming struct.                                                                                                             | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-static-method-requirement.slang`](interface-static-method-requirement.slang)                                                                                                                                                           |
| C16 — Method compatibility: impl with wider parameter types and narrower return type satisfies the interface requirement (Remark 1).                                                               | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-method-compat-covariant.slang`](interface-method-compat-covariant.slang)                                                                                                                                                               |
| C17 — Return type not convertible to interface return type is rejected with E38106.                                                                                                                | negative   | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-return-type-mismatch-diagnostic.slang`](interface-return-type-mismatch-diagnostic.slang)                                                                                                                                               |
| C18 — Missing required method causes E38100 naming the member.                                                                                                                                     | negative   | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-missing-method-diagnostic.slang`](interface-missing-method-diagnostic.slang)                                                                                                                                                           |
| C19 — Missing required associated type causes E38100 naming the associated type.                                                                                                                   | negative   | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-missing-assoc-type-diagnostic.slang`](interface-missing-assoc-type-diagnostic.slang)                                                                                                                                                   |
| C20 — Missing required static const data member causes E38100 naming the member.                                                                                                                   | negative   | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-missing-static-const-diagnostic.slang`](interface-missing-static-const-diagnostic.slang)                                                                                                                                               |
| C22 — Implementation visibility lower than requirement is accepted (internal implements public).                                                                                                   | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-member-visibility-lower.slang`](interface-member-visibility-lower.slang)                                                                                                                                                               |
| C23–C24 — Interface may inherit from another interface; a conforming struct satisfies all requirements from both.                                                                                  | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-inheritance.slang`](interface-inheritance.slang), [`interface-inheritance-override-example.slang`](interface-inheritance-override-example.slang), [`interface-inheritance-emission.slang`](interface-inheritance-emission.slang)       |
| C25 — Generic parameterized interface (`interface IFoo<T>`); struct conforms with a concrete type argument.                                                                                        | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-generic-parameterized.slang`](interface-generic-parameterized.slang), [`interface-generic-specialization-emission.slang`](interface-generic-specialization-emission.slang)                                                             |
| C26–C27 — Interface-typed variable declared, methods callable at runtime; interface-typed function parameter with compile-time-known concrete type is specialized.                                 | functional | [#interface-conforming-variants](../../../../language-reference/types-interface.md#interface-conforming-variants) | [`interface-typed-param-specialization.slang`](interface-typed-param-specialization.slang), [`interface-variant-declaration.slang`](interface-variant-declaration.slang), [`interface-dispatch-compute.slang`](interface-dispatch-compute.slang)   |
| C28 — Compile-time-known concrete type passed to interface-typed parameter emits the concrete method name on all targets (hlsl, glsl, spirv-asm, metal, wgsl, cuda, cpp) with no virtual dispatch. | functional | [#interface-conforming-variants](../../../../language-reference/types-interface.md#interface-conforming-variants) | [`interface-typed-param-emission.slang`](interface-typed-param-emission.slang), [`interface-conform-emission-hlsl.slang`](interface-conform-emission-hlsl.slang), [`interface-conform-emission-glsl.slang`](interface-conform-emission-glsl.slang) |
| All requirement types together — full ITest/TestClass example from the doc.                                                                                                                        | functional | [#description](../../../../language-reference/types-interface.md#description)                                     | [`interface-full-example-functional.slang`](interface-full-example-functional.slang)                                                                                                                                                               |

## Untested claims

| Claim                                                                                                    | Reason                | Anchor                                                                                                                          | Why untested                                                                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| C21 — Interface member visibility declared `public` or `internal`; default matches interface visibility. | out-of-bundle         | [#description](../../../../language-reference/types-interface.md#description)                                                   | Visibility semantics are partially observable via E30601 which fires when a member exceeds its parent's visibility, but the "default matches interface visibility" rule is an internal propagation with no clear observable CHECK. The positive lower-visibility case is covered in C22. |
| C22 (higher-visibility negative) — Implementation visibility _higher_ than requirement is rejected.      | out-of-bundle         | [#description](../../../../language-reference/types-interface.md#description)                                                   | E30601 fires but the constraint attaches to the parent struct's visibility rather than the interface requirement directly, making the claim ambiguous. The design/cross-cutting/diagnostics-catalog bundle covers E30601 directly.                                                       |
| C29 — Memory layout and dispatch mechanism of interface-conforming variants are unspecified.             | implementation-detail | [#memory-layout-and-dispatch-mechanism](../../../../language-reference/types-interface.md#memory-layout-and-dispatch-mechanism) | Explicitly marked non-normative in the doc; the section carries no testable behavioral claims — the layout is unspecified and subject to change.                                                                                                                                         |
| Interface-conforming variant restrictions (no opaque/non-copyable/unsized member types).                 | gpu-other             | [#interface-conforming-variants](../../../../language-reference/types-interface.md#interface-conforming-variants)               | The restrictions require GPU textures (opaque types) to produce observable diagnostics. Not testable locally on CPU-only runner.                                                                                                                                                         |
| Deprecated default-initialization of interface variants (Remark 2).                                      | deprecated            | [#interface-conforming-variants](../../../../language-reference/types-interface.md#interface-conforming-variants)               | Deprecated in Slang 2025 and disallowed in 2026; no test should perpetuate deprecated behavior.                                                                                                                                                                                          |

## Doc gaps observed

NA
