mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-26 18:41:33 +00:00
This removes the builtin FunctionType, replacing it with a FunctionType instruction. The constant for a FunctionDecl is now a StructValue with type of FunctionType. Note this means a function declaration produces _both_ a type, and a value of the type. This has some consequences in terms of circularity, and makes the importing of function declarations a little more complex. It'll get particularly peculiar for imports because of the behavior of the reference, but that's a known issue due to other things such as `alias`. The impact will hopefully be contained to ResolvePrevInstForMerge (and ImportRefs). To note a small formatting change in diagnostics: ``` - // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. - // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. ``` --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
122 lines
4.3 KiB
Plaintext
122 lines
4.3 KiB
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
|
|
|
|
class Class {
|
|
fn F();
|
|
fn H();
|
|
fn I() {}
|
|
}
|
|
|
|
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE+7]]:1: ERROR: Redefinition of `class Class`.
|
|
// CHECK:STDERR: class Class {
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE-9]]:1: Previously defined here.
|
|
// CHECK:STDERR: class Class {
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
class Class {
|
|
fn G();
|
|
fn H();
|
|
fn I() {}
|
|
}
|
|
|
|
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE+4]]:10: ERROR: Out-of-line declaration requires a declaration in scoped entity.
|
|
// CHECK:STDERR: fn Class.F() {}
|
|
// CHECK:STDERR: ^
|
|
// CHECK:STDERR:
|
|
fn Class.F() {}
|
|
fn Class.G() {}
|
|
fn Class.H() {}
|
|
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE+6]]:1: ERROR: Redefinition of `fn I`.
|
|
// CHECK:STDERR: fn Class.I() {}
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
|
// CHECK:STDERR: fail_redefinition.carbon:[[@LINE-13]]:3: Previously defined here.
|
|
// CHECK:STDERR: fn I() {}
|
|
// CHECK:STDERR: ^~~~~~~~
|
|
fn Class.I() {}
|
|
|
|
// CHECK:STDOUT: --- fail_redefinition.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Class: type = class_type @Class [template]
|
|
// CHECK:STDOUT: %F.1: type = fn_type @F.1 [template]
|
|
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
|
// CHECK:STDOUT: %struct.1: F = struct_value () [template]
|
|
// CHECK:STDOUT: %H.1: type = fn_type @H.1 [template]
|
|
// CHECK:STDOUT: %struct.2: H = struct_value () [template]
|
|
// CHECK:STDOUT: %I.1: type = fn_type @I.1 [template]
|
|
// CHECK:STDOUT: %struct.3: I = struct_value () [template]
|
|
// CHECK:STDOUT: %.2: type = struct_type {} [template]
|
|
// CHECK:STDOUT: %G: type = fn_type @G [template]
|
|
// CHECK:STDOUT: %struct.4: G = struct_value () [template]
|
|
// CHECK:STDOUT: %H.2: type = fn_type @H.2 [template]
|
|
// CHECK:STDOUT: %struct.5: H = struct_value () [template]
|
|
// CHECK:STDOUT: %I.2: type = fn_type @I.2 [template]
|
|
// CHECK:STDOUT: %struct.6: I = struct_value () [template]
|
|
// CHECK:STDOUT: %F.2: type = fn_type @F.2 [template]
|
|
// CHECK:STDOUT: %struct.7: F = struct_value () [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .Class = %Class.decl.loc7
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %Class.decl.loc7: type = class_decl @Class [template = constants.%Class] {}
|
|
// CHECK:STDOUT: %Class.decl.loc20: type = class_decl @Class [template = constants.%Class] {}
|
|
// CHECK:STDOUT: %F.decl: F = fn_decl @F.2 [template = constants.%struct.7] {}
|
|
// CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.4] {}
|
|
// CHECK:STDOUT: %H.decl: H = fn_decl @H.2 [template = constants.%struct.5] {}
|
|
// CHECK:STDOUT: %I.decl: I = fn_decl @I.2 [template = constants.%struct.6] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Class {
|
|
// CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.4] {}
|
|
// CHECK:STDOUT: %H.decl: H = fn_decl @H.2 [template = constants.%struct.5] {}
|
|
// CHECK:STDOUT: %I.decl: I = fn_decl @I.2 [template = constants.%struct.6] {}
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Class
|
|
// CHECK:STDOUT: .G = %G.decl
|
|
// CHECK:STDOUT: .H = %H.decl
|
|
// CHECK:STDOUT: .I = %I.decl
|
|
// CHECK:STDOUT: .F = file.%F.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F.1();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @H.1();
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @I.1() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @G() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @H.2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @I.2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !.loc39:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F.2() {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|