mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Explorer: Include self pattern in method type (#2935)
This fixes a bug where Explorer would not detect when: - an implementation used a method to implement a class function in an interface - an implementation used a class function to implement a method in an interface - an implementation method used `addr self` when the interface method did not - an interface method used `addr self` when the implementation method did not at type checking time. This would then cause a crash at runtime. Closes #2857 --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// 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 I {
|
||||
fn G[self: Self]();
|
||||
}
|
||||
|
||||
class C {
|
||||
impl as I {
|
||||
// CHECK:STDERR: COMPILATION ERROR: fail_impl_missing_self.carbon:[[@LINE+3]]: type error in member of implementation
|
||||
// CHECK:STDERR: expected: fn [self: class C]() -> ()
|
||||
// CHECK:STDERR: actual: fn () -> ()
|
||||
fn G() { }
|
||||
}
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user