Files
carbon-lang/explorer/testdata/interface/fail_extend_with_self.carbon
T
2023-06-15 08:42:14 -07:00

29 lines
641 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
package ExplorerTest api;
interface Z {
fn Zero() -> Self;
}
class Point {
var x: i32;
var y: i32;
// `Self` not allowed after `extend impl`.
// CHECK:STDERR: SYNTAX ERROR: fail_extend_with_self.carbon:[[@LINE+1]]: syntax error, unexpected SELF, expecting AS
extend impl Self as Z {
fn Zero() -> Self {
return {.x = 0, .y = 0};
}
}
}
fn Main() -> i32 {
var a: Point = Point.Zero();
return p.x;
}