mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 21:08:10 +00:00
Note that this code still results in a compilation error pending the merge of #2628, this just prevents the assertion from happening. Closes #2583.
42 lines
975 B
Plaintext
42 lines
975 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
// RUN: %{not} %{explorer-run}
|
|
// RUN: %{not} %{explorer-run-trace}
|
|
|
|
package ExplorerTest api;
|
|
|
|
interface Printable {
|
|
fn PrintIt[self: Self]();
|
|
}
|
|
|
|
impl String as Printable {
|
|
fn PrintIt[self: String]() {
|
|
Print(self);
|
|
}
|
|
}
|
|
|
|
class Vector(T:! type) {
|
|
var x: T;
|
|
|
|
alias PrintIt = Printable.PrintIt;
|
|
}
|
|
|
|
// Conditionally implement the API for certain `T`s.
|
|
impl forall [U:! Printable] Vector(U) as Printable {
|
|
fn PrintIt[self: Self]() {
|
|
Print("{ ");
|
|
self.x.PrintIt();
|
|
Print(" }");
|
|
}
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
var v: Vector(String) = {.x = "test"};
|
|
// CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/alias/interface_method_as_class_member.carbon:[[@LINE+1]]: Member access to aliases is not yet supported.
|
|
v.PrintIt();
|
|
return 42;
|
|
}
|