Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions LanguageFeatures/Patterns/object_A02_t12.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion objectPattern ::= typeName typeArguments? '(' patternFields? ')'
/// ...
/// As with record patterns, the getter name can be omitted and inferred from
/// the variable pattern in the field subpattern which may be wrapped in a unary
/// pattern
///
/// @description Check that it is a compile-time error if an object pattern with
/// the omitted getter name in a declaration context declares a variable that
/// already exists
/// @author [email protected]

// SharedOptions=--enable-experiment=patterns,records

import "patterns_lib.dart";

main() {
int areaAsInt = 1, sizeAsInt = 1;
var Square(:areaAsInt) = Square(1);
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

var Square(: int sizeAsInt) = Square(2);
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified}
}
7 changes: 1 addition & 6 deletions LanguageFeatures/Patterns/pattern_assignment_A01_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// @description Check an object pattern in a pattern assignment
/// @author [email protected]

// SharedOptions=--enable-experiment=patterns
// SharedOptions=--enable-experiment=patterns,records

import "../../Utils/expect.dart";
import "patterns_lib.dart";
Expand All @@ -31,9 +31,4 @@ main() {
Square(areaAsInt: a2, sizeAsInt: b2) = Square(2);
Expect.equals(4, a2);
Expect.equals(2, b2);

int areaAsInt = 5, sizeAsInt = 6;
var Square(:areaAsInt,: int sizeAsInt) = Square(3);
Expect.equals(9, areaAsInt);
Expect.equals(3, sizeAsInt);
}