Skip to content

Commit 30dc427

Browse files
pqCommit Queue
authored and
Commit Queue
committed
STRICT_RAW_TYPE tests for extension types
See: #53434 Change-Id: I3a94046dff920a05fd6e617c6f234c001fab6781 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326880 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 044be2a commit 30dc427

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pkg/analyzer/test/src/diagnostics/strict_raw_type_test.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ void g(C a) {}
8585
''');
8686
}
8787

88+
test_genericTypeArgument_extensionType_missingTypeArg() async {
89+
await assertErrorsInCode(r'''
90+
extension type E<T>(int i) {}
91+
92+
void f() {
93+
var e = <List<E>>[];
94+
}
95+
''', [
96+
error(WarningCode.UNUSED_LOCAL_VARIABLE, 48, 1),
97+
error(WarningCode.STRICT_RAW_TYPE, 58, 1),
98+
]);
99+
}
100+
101+
test_genericTypeArgument_extensionType_withTypeArg() async {
102+
await assertErrorsInCode(r'''
103+
extension type E<T>(int i) {}
104+
105+
void f() {
106+
var e = <List<E<int>>>[];
107+
}
108+
''', [
109+
error(WarningCode.UNUSED_LOCAL_VARIABLE, 48, 1),
110+
]);
111+
}
112+
88113
test_genericTypeArgument_missingTypeArg() async {
89114
await assertErrorsInCode(r'''
90115
void f() {
@@ -124,6 +149,31 @@ void f(dynamic x) {
124149
''');
125150
}
126151

152+
test_localVariable_extensionType_missingTypeArg() async {
153+
await assertErrorsInCode(r'''
154+
extension type E<T>(int i) {}
155+
156+
void f() {
157+
E e = E(1);
158+
}
159+
''', [
160+
error(WarningCode.STRICT_RAW_TYPE, 48, 1),
161+
error(WarningCode.UNUSED_LOCAL_VARIABLE, 50, 1),
162+
]);
163+
}
164+
165+
test_localVariable_extensionType_withTypeArg() async {
166+
await assertErrorsInCode(r'''
167+
extension type E<T>(int i) {}
168+
169+
void f() {
170+
E<int> e = E<int>(1);
171+
}
172+
''', [
173+
error(WarningCode.UNUSED_LOCAL_VARIABLE, 55, 1),
174+
]);
175+
}
176+
127177
test_localVariable_missingTypeArg() async {
128178
await assertErrorsInCode(r'''
129179
void f() {

0 commit comments

Comments
 (0)