File tree 4 files changed +40
-3
lines changed
4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -991,6 +991,13 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
991
991
992
992
var name = element.name;
993
993
994
+ // type literal
995
+ if (element is ClassElement ||
996
+ element is DynamicElementImpl ||
997
+ element is FunctionTypeAliasElement ) {
998
+ return _emitTypeName (fillDynamicTypeArgs (element.type, types));
999
+ }
1000
+
994
1001
// library member
995
1002
if (element.enclosingElement is CompilationUnitElement ) {
996
1003
return _maybeQualifiedName (
Original file line number Diff line number Diff line change @@ -375,9 +375,12 @@ Object getConstantField(
375
375
return (f == null || f.type != expectedType) ? null : f.value;
376
376
}
377
377
378
- ParameterizedType fillDynamicTypeArgs (ParameterizedType t, TypeProvider types) {
379
- var dyn = new List .filled (t.typeArguments.length, types.dynamicType);
380
- return t.substitute2 (dyn, t.typeArguments);
378
+ DartType fillDynamicTypeArgs (DartType t, TypeProvider types) {
379
+ if (t is ParameterizedType ) {
380
+ var dyn = new List .filled (t.typeArguments.length, types.dynamicType);
381
+ return t.substitute2 (dyn, t.typeArguments);
382
+ }
383
+ return t;
381
384
}
382
385
383
386
/// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and
Original file line number Diff line number Diff line change @@ -7,13 +7,28 @@ var core = dart.import(core);
7
7
}
8
8
}
9
9
let UNINITIALIZED = dart . const ( new _Uninitialized ( ) ) ;
10
+ let Generic$ = dart . generic ( function ( T ) {
11
+ class Generic extends core . Object {
12
+ get type ( ) {
13
+ return Generic$ ( ) ;
14
+ }
15
+ }
16
+ return Generic ;
17
+ } ) ;
18
+ let Generic = Generic$ ( ) ;
10
19
// Function main: () → dynamic
11
20
function main ( ) {
12
21
core . print ( dart . toString ( 1 ) ) ;
13
22
core . print ( dart . toString ( 1.0 ) ) ;
14
23
core . print ( dart . toString ( 1.1 ) ) ;
24
+ let x = 42 ;
25
+ core . print ( dart . equals ( x , dart . dynamic ) ) ;
26
+ core . print ( dart . equals ( x , Generic ) ) ;
27
+ core . print ( new ( Generic$ ( core . int ) ) ( ) . type ) ;
15
28
}
16
29
// Exports:
17
30
exports . UNINITIALIZED = UNINITIALIZED ;
31
+ exports . Generic$ = Generic$ ;
32
+ exports . Generic = Generic ;
18
33
exports . main = main ;
19
34
} ) ( misc , core ) ;
Original file line number Diff line number Diff line change 7
7
const UNINITIALIZED = const _Uninitialized ();
8
8
class _Uninitialized { const _Uninitialized (); }
9
9
10
+ class Generic <T > {
11
+ Type get type => Generic ;
12
+ }
13
+
10
14
main () {
11
15
// Number literals in call expressions.
12
16
print (1. toString ());
13
17
print (1.0 .toString ());
14
18
print (1.1 .toString ());
19
+
20
+ // Type literals, #184
21
+ dynamic x = 42 ;
22
+ print (x == dynamic );
23
+ print (x == Generic );
24
+
25
+ // Should be Generic<dynamic>
26
+ print (new Generic <int >().type);
15
27
}
You can’t perform that action at this time.
0 commit comments