mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 15:30:11 +01:00
Includes support for the `impls`, `=`, and `==` requirement operators to the right of a `where`, but `and` to allow multiple requirements is still a TODO. --------- Co-authored-by: Josh L <josh11b@users.noreply.github.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk>
58 lines
3.2 KiB
Plaintext
58 lines
3.2 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
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/where_expr/impl_where.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/where_expr/impl_where.carbon
|
|
|
|
interface Interface {
|
|
let T:! type;
|
|
}
|
|
|
|
impl i32 as Interface where .T = () {
|
|
}
|
|
|
|
impl bool as Interface where .T = i32;
|
|
|
|
// CHECK:STDOUT: - filename: impl_where.carbon
|
|
// CHECK:STDOUT: parse_tree: [
|
|
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
|
// CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'},
|
|
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'Interface'},
|
|
// CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3},
|
|
// CHECK:STDOUT: {kind: 'LetIntroducer', text: 'let'},
|
|
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'T'},
|
|
// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'},
|
|
// CHECK:STDOUT: {kind: 'CompileTimeBindingPattern', text: ':!', subtree_size: 3},
|
|
// CHECK:STDOUT: {kind: 'LetDecl', text: ';', subtree_size: 5},
|
|
// CHECK:STDOUT: {kind: 'InterfaceDefinition', text: '}', subtree_size: 9},
|
|
// CHECK:STDOUT: {kind: 'ImplIntroducer', text: 'impl'},
|
|
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
|
|
// CHECK:STDOUT: {kind: 'TypeImplAs', text: 'as', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Interface'},
|
|
// CHECK:STDOUT: {kind: 'WhereOperand', text: 'where', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'T'},
|
|
// CHECK:STDOUT: {kind: 'DesignatorExpr', text: '.', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('},
|
|
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'RequirementEqual', text: '=', subtree_size: 5},
|
|
// CHECK:STDOUT: {kind: 'WhereExpr', text: 'where', subtree_size: 8},
|
|
// CHECK:STDOUT: {kind: 'ImplDefinitionStart', text: '{', subtree_size: 12},
|
|
// CHECK:STDOUT: {kind: 'ImplDefinition', text: '}', subtree_size: 13},
|
|
// CHECK:STDOUT: {kind: 'ImplIntroducer', text: 'impl'},
|
|
// CHECK:STDOUT: {kind: 'BoolTypeLiteral', text: 'bool'},
|
|
// CHECK:STDOUT: {kind: 'TypeImplAs', text: 'as', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Interface'},
|
|
// CHECK:STDOUT: {kind: 'WhereOperand', text: 'where', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'IdentifierName', text: 'T'},
|
|
// CHECK:STDOUT: {kind: 'DesignatorExpr', text: '.', subtree_size: 2},
|
|
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
|
|
// CHECK:STDOUT: {kind: 'RequirementEqual', text: '=', subtree_size: 4},
|
|
// CHECK:STDOUT: {kind: 'WhereExpr', text: 'where', subtree_size: 7},
|
|
// CHECK:STDOUT: {kind: 'ImplDecl', text: ';', subtree_size: 11},
|
|
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
|
// CHECK:STDOUT: ]
|