Skip to content

Commit c50fcf8

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Show "any" for type args of package js types
Ensures that `toString()` of types that contain embedded js types will appear the same in the old and new runtime type systems. Issue: #48585 Change-Id: I71ec0e13943281e745bcf05e10aa36d093cbc0c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334003 Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Srujan Gaddam <[email protected]>
1 parent 57ece5b commit c50fcf8

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646

4747
[lints-3-0]: https://pub.dev/packages/lints/changelog#300
4848

49+
#### Development JavaScript compiler (DDC)
50+
51+
- Type arguments of `package:js` interop types are now printed as `any` instead
52+
of being omitted. This is simply a change to the textual representation of
53+
package js types that have type arguments. These type arguments are still
54+
completely ignored by the type system at runtime.
55+
4956
## 3.2.0
5057

5158
### Language

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,6 +3519,13 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
35193519
? getLocalClassName(c)
35203520
: _emitJsNameWithoutGlobal(c);
35213521
if (jsName != null) {
3522+
if (type.typeArguments.isNotEmpty) {
3523+
// This does not handle the type arguments as such, it simply includes
3524+
// them in the textual representation of this type so you can see them
3525+
// when printed. They are not used as part of the type system at all.
3526+
jsName =
3527+
'$jsName<${type.typeArguments.map((_) => 'any').join(', ')}>';
3528+
}
35223529
typeRep = runtimeCall('packageJSType(#)', [js.escapedString(jsName)]);
35233530
}
35243531
}

tests/dartdevc/debugger/debugger_test_golden.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7091,7 +7091,7 @@ Value:
70917091
{
70927092
"style": "background-color: #d9edf7;color: black"
70937093
},
7094-
"Instance of 'TestGenericClass<ExampleJSClass, int>'"
7094+
"Instance of 'TestGenericClass<ExampleJSClass<any>, int>'"
70957095
]
70967096
-----------------------------------
70977097
Test: TestGenericClassJSInterop instance body
@@ -7188,7 +7188,7 @@ Value:
71887188
{
71897189
"style": "background-color: #d9edf7;color: black"
71907190
},
7191-
"TestGenericClass<ExampleJSClass, int>"
7191+
"TestGenericClass<ExampleJSClass<any>, int>"
71927192
]
71937193
-----------------------------------
71947194
Test: TestGenericClassJSInterop definition formatting body

tests/dartdevc_2/debugger/debugger_test_golden.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7091,7 +7091,7 @@ Value:
70917091
{
70927092
"style": "background-color: #d9edf7;color: black"
70937093
},
7094-
"Instance of 'TestGenericClass<ExampleJSClass, int>'"
7094+
"Instance of 'TestGenericClass<ExampleJSClass<any>, int>'"
70957095
]
70967096
-----------------------------------
70977097
Test: TestGenericClassJSInterop instance body
@@ -7188,7 +7188,7 @@ Value:
71887188
{
71897189
"style": "background-color: #d9edf7;color: black"
71907190
},
7191-
"TestGenericClass<ExampleJSClass, int>"
7191+
"TestGenericClass<ExampleJSClass<any>, int>"
71927192
]
71937193
-----------------------------------
71947194
Test: TestGenericClassJSInterop definition formatting body

0 commit comments

Comments
 (0)