Skip to content

Commit fb0b4a8

Browse files
chloestefantsovaCommit Queue
authored and
Commit Queue
committed
[cfe] Allow records on the RHS of typedefs
Part of #49713 Closes #50133 Change-Id: I482280599487a3539f88c715e5a92e78f810b264 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262962 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 682567f commit fb0b4a8

10 files changed

+79
-14
lines changed

pkg/front_end/lib/src/fasta/source/source_type_alias_builder.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import 'package:kernel/class_hierarchy.dart';
99

1010
import '../builder/builder.dart';
1111
import '../builder/class_builder.dart';
12-
import '../builder/fixed_type_builder.dart';
13-
import '../builder/function_type_builder.dart';
1412
import '../builder/library_builder.dart';
1513
import '../builder/member_builder.dart';
1614
import '../builder/metadata_builder.dart';
17-
import '../builder/named_type_builder.dart';
1815
import '../builder/type_alias_builder.dart';
1916
import '../builder/type_builder.dart';
2017
import '../builder/type_declaration_builder.dart';
@@ -88,17 +85,6 @@ class SourceTypeAliasBuilder extends TypeAliasBuilderImpl {
8885

8986
Typedef build() {
9087
buildThisType();
91-
92-
TypeBuilder type = this.type;
93-
if (type is FunctionTypeBuilder ||
94-
type is NamedTypeBuilder ||
95-
type is FixedTypeBuilder) {
96-
// No error, but also no additional setup work.
97-
// ignore: unnecessary_null_comparison
98-
} else if (type != null) {
99-
unhandled("${type.fullNameForErrors}", "build", charOffset, fileUri);
100-
}
101-
10288
return typedef;
10389
}
10490

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
typedef Foo = (int, int);
6+
7+
test() {
8+
Foo x = (1, 2);
9+
}
10+
11+
main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic {
7+
(core::int, core::int) x = (1, 2);
8+
}
9+
static method main() → dynamic {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic {
7+
(core::int, core::int) x = (1, 2);
8+
}
9+
static method main() → dynamic {}
10+
11+
12+
Extra constant evaluation status:
13+
Evaluated: RecordLiteral @ org-dartlang-testcase:///issue50133.dart:8:11 -> RecordConstant(const (1, 2))
14+
Extra constant evaluation: evaluated: 1, effectively constant: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef Foo = (int, int);
2+
test() {}
3+
main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic {
7+
(core::int, core::int) x = (1, 2);
8+
}
9+
static method main() → dynamic {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic {
7+
(core::int, core::int) x = (1, 2);
8+
}
9+
static method main() → dynamic {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic
7+
;
8+
static method main() → dynamic
9+
;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
typedef Foo = (core::int, core::int);
6+
static method test() → dynamic {
7+
(core::int, core::int) x = (1, 2);
8+
}
9+
static method main() → dynamic {}
10+
11+
12+
Extra constant evaluation status:
13+
Evaluated: RecordLiteral @ org-dartlang-testcase:///issue50133.dart:8:11 -> RecordConstant(const (1, 2))
14+
Extra constant evaluation: evaluated: 1, effectively constant: 1

pkg/front_end/testcases/textual_outline.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ rasta/malformed_const_constructor: FormatterCrash
146146
rasta/mandatory_parameter_initializer: FormatterCrash
147147
records/access_through_type_variable: FormatterCrash
148148
records/const_record_literal: FormatterCrash
149+
records/issue50133: FormatterCrash
149150
records/record_literal_errors: FormatterCrash
150151
records/record_type: FormatterCrash
151152
records/record_type_errors: FormatterCrash

0 commit comments

Comments
 (0)