@@ -257,7 +257,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
257
257
derived.prototype.__proto__ = base.prototype;
258
258
};
259
259
dart.throwCastError = function(actual, type) {
260
- dart.throw(new _js_helper.CastErrorImplementation(actual, type));
260
+ dart.throw(new _js_helper.CastErrorImplementation(dart.typeName( actual), dart.typeName( type) ));
261
261
};
262
262
dart.throwAssertionError = function() {
263
263
dart.throw(new core.AssertionError());
@@ -520,35 +520,36 @@ dart_library.library('dart_sdk', null, /* Imports */[
520
520
return dart._callMethod(obj, 'set', null, [index, value], '[]=');
521
521
};
522
522
dart._ignoreTypeFailure = function(actual, type) {
523
- if (dart.isSubtype(type, core.Iterable) && dart.isSubtype(actual, core.Iterable) || dart.isSubtype(type, async.Future) && dart.isSubtype(actual, async.Future) || dart.isSubtype(type, core.Map) && dart.isSubtype(actual, core.Map) || dart.isSubtype(type, core.Function) && dart.isSubtype(actual, core.Function) || dart.isSubtype(type, async.Stream) && dart.isSubtype(actual, async.Stream) || dart.isSubtype(type, async.StreamSubscription) && dart.isSubtype(actual, async.StreamSubscription)) {
523
+ if (!! dart.isSubtype(type, core.Iterable) && !! dart.isSubtype(actual, core.Iterable) || !! dart.isSubtype(type, async.Future) && !! dart.isSubtype(actual, async.Future) || !! dart.isSubtype(type, core.Map) && !! dart.isSubtype(actual, core.Map) || !! dart.isSubtype(type, core.Function) && !! dart.isSubtype(actual, core.Function) || !! dart.isSubtype(type, async.Stream) && !! dart.isSubtype(actual, async.Stream) || !! dart.isSubtype(type, async.StreamSubscription) && !! dart.isSubtype(actual, async.StreamSubscription)) {
524
524
console.warn('Ignoring cast fail from ' + dart.typeName(actual) + ' to ' + dart.typeName(type));
525
525
return true;
526
526
}
527
527
return false;
528
528
};
529
529
dart.strongInstanceOf = function(obj, type, ignoreFromWhiteList) {
530
530
let actual = dart.getReifiedType(obj);
531
- if ( dart.isSubtype(actual, type) || actual == dart.jsobject || actual == core.int && type == core.double) return true ;
532
- if (ignoreFromWhiteList == void 0 ) return false ;
533
- if (dart.isGroundType(type)) return false ;
531
+ let result = dart.isSubtype(actual, type);
532
+ if (result || actual == dart.jsobject || actual == core.int && type == core.double ) return true ;
533
+ if (ignoreFromWhiteList == void 0) return result ;
534
534
if (dart._ignoreTypeFailure(actual, type)) return true;
535
- return false ;
535
+ return result ;
536
536
};
537
537
dart.instanceOfOrNull = function(obj, type) {
538
538
if (obj == null || dart.strongInstanceOf(obj, type, true)) return true;
539
539
return false;
540
540
};
541
541
dart.is = function(obj, type) {
542
- if ( dart.strongInstanceOf(obj, type)) return true ;
543
- if (dart.isGroundType(type)) return false ;
542
+ let result = dart.strongInstanceOf(obj, type);
543
+ if (result !== null) return result ;
544
544
let actual = dart.getReifiedType(obj);
545
545
dart.throwStrongModeError('Strong mode is check failure: ' + dart.typeName(actual) + ' does not soundly subtype ' + dart.typeName(type));
546
546
};
547
547
dart.as = function(obj, type) {
548
- if (dart.instanceOfOrNull(obj, type)) return obj;
548
+ if (obj == null) return obj;
549
+ let result = dart.strongInstanceOf(obj, type, true);
550
+ if (result) return obj;
549
551
let actual = dart.getReifiedType(obj);
550
- if (dart.isGroundType(type)) dart.throwCastError(actual, type);
551
- if (dart._ignoreTypeFailure(actual, type)) return obj;
552
+ if (result === false) dart.throwCastError(actual, type);
552
553
dart.throwStrongModeError('Strong mode cast failure from ' + dart.typeName(actual) + ' to ' + dart.typeName(type));
553
554
};
554
555
dart.asInt = function(obj) {
@@ -990,7 +991,12 @@ dart_library.library('dart_sdk', null, /* Imports */[
990
991
return dart._getRuntimeType(type) === core.Type;
991
992
};
992
993
dart.typeName = function(type) {
993
- if (type instanceof dart.TypeRep) return type.toString();
994
+ if (type instanceof dart.TypeRep) {
995
+ if (type instanceof dart.Typedef) {
996
+ return type.name + "(" + type.functionType.toString() + ")";
997
+ }
998
+ return type.toString();
999
+ }
994
1000
let tag = dart._getRuntimeType(type);
995
1001
if (tag === core.Type) {
996
1002
let name = type.name;
@@ -1019,41 +1025,36 @@ dart_library.library('dart_sdk', null, /* Imports */[
1019
1025
dart.isFunctionType = function(type) {
1020
1026
return type instanceof dart.AbstractFunctionType || type === core.Function;
1021
1027
};
1022
- dart.isFunctionSubType = function(ft1, ft2) {
1023
- if (ft2 == core.Function) {
1028
+ dart.isFunctionSubtype = function(ft1, ft2, covariant ) {
1029
+ if (ft2 === core.Function) {
1024
1030
return true;
1025
1031
}
1026
1032
let ret1 = ft1.returnType;
1027
1033
let ret2 = ft2.returnType;
1028
- if (!dart.isSubtype_(ret1, ret2)) {
1029
- if (ret2 != dart.void) {
1030
- return false;
1031
- }
1032
- }
1033
1034
let args1 = ft1.args;
1034
1035
let args2 = ft2.args;
1035
1036
if (args1.length > args2.length) {
1036
- return false;
1037
+ return covariant ? false : null ;
1037
1038
}
1038
1039
for (let i = 0; i < args1.length; ++i) {
1039
- if (!dart.isSubtype_(args2[i], args1[i])) {
1040
- return false ;
1040
+ if (!dart.isSubtype_(args2[i], args1[i], !covariant )) {
1041
+ return null ;
1041
1042
}
1042
1043
}
1043
1044
let optionals1 = ft1.optionals;
1044
1045
let optionals2 = ft2.optionals;
1045
1046
if (args1.length + optionals1.length < args2.length + optionals2.length) {
1046
- return false;
1047
+ return covariant ? false : null ;
1047
1048
}
1048
1049
let j = 0;
1049
1050
for (let i = args1.length; i < args2.length; ++i, ++j) {
1050
- if (!dart.isSubtype_(args2[i], optionals1[j])) {
1051
- return false ;
1051
+ if (!dart.isSubtype_(args2[i], optionals1[j], !covariant )) {
1052
+ return null ;
1052
1053
}
1053
1054
}
1054
1055
for (let i = 0; i < optionals2.length; ++i, ++j) {
1055
- if (!dart.isSubtype_(optionals2[i], optionals1[j])) {
1056
- return false ;
1056
+ if (!dart.isSubtype_(optionals2[i], optionals1[j], !covariant )) {
1057
+ return null ;
1057
1058
}
1058
1059
}
1059
1060
let named1 = ft1.named;
@@ -1064,10 +1065,17 @@ dart_library.library('dart_sdk', null, /* Imports */[
1064
1065
let n1 = named1[name];
1065
1066
let n2 = named2[name];
1066
1067
if (n1 === void 0) {
1067
- return false;
1068
+ return covariant ? false : null ;
1068
1069
}
1069
- if (!dart.isSubtype_(n2, n1)) {
1070
- return false;
1070
+ if (!dart.isSubtype_(n2, n1, !covariant)) {
1071
+ return null;
1072
+ }
1073
+ }
1074
+ let result = dart.isSubtype_(ret1, ret2, covariant);
1075
+ if (result === null) return result;
1076
+ if (!result) {
1077
+ if (ret2 !== dart.void) {
1078
+ return null;
1071
1079
}
1072
1080
}
1073
1081
return true;
@@ -1091,7 +1099,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
1091
1099
} else {
1092
1100
dart.subtypeMap.set(t1, map = new Map());
1093
1101
}
1094
- result = dart.isSubtype_(t1, t2);
1102
+ result = dart.isSubtype_(t1, t2, true );
1095
1103
map.set(t2, result);
1096
1104
return result;
1097
1105
};
@@ -1101,27 +1109,28 @@ dart_library.library('dart_sdk', null, /* Imports */[
1101
1109
dart._isTop = function(type) {
1102
1110
return type == core.Object || type == dart.dynamic;
1103
1111
};
1104
- dart.isSubtype_ = function(t1, t2) {
1112
+ dart.isSubtype_ = function(t1, t2, covariant ) {
1105
1113
t1 = dart.canonicalType(t1);
1106
1114
t2 = dart.canonicalType(t2);
1107
- if (t1 == t2) return true;
1115
+ if (t1 === t2) return true;
1108
1116
if (dart._isTop(t2) || dart._isBottom(t1)) {
1109
1117
return true;
1110
1118
}
1111
- if (dart._isTop(t1) || dart._isBottom(t2)) {
1119
+ if (dart._isBottom(t2)) return null;
1120
+ if (dart._isTop(t1)) {
1121
+ if (t1 === dart.dynamic) return null;
1112
1122
return false;
1113
1123
}
1114
- if (dart.isClassSubType(t1, t2)) {
1115
- return true;
1116
- }
1124
+ let result = dart.isClassSubType(t1, t2, covariant);
1125
+ if (result === true || result === null) return result;
1117
1126
t1 = dart.getImplicitFunctionType(t1);
1118
1127
if (!t1) return false;
1119
1128
if (dart.isFunctionType(t1) && dart.isFunctionType(t2)) {
1120
- return dart.isFunctionSubType (t1, t2);
1129
+ return dart.isFunctionSubtype (t1, t2, covariant );
1121
1130
}
1122
1131
return false;
1123
1132
};
1124
- dart.isClassSubType = function(t1, t2) {
1133
+ dart.isClassSubType = function(t1, t2, covariant ) {
1125
1134
t1 = dart.canonicalType(t1);
1126
1135
dart.assert(t2 == dart.canonicalType(t2));
1127
1136
if (t1 == t2) return true;
@@ -1136,29 +1145,41 @@ dart_library.library('dart_sdk', null, /* Imports */[
1136
1145
if (typeArguments2.length == 0) {
1137
1146
return true;
1138
1147
} else if (length == 0) {
1139
- return false;
1148
+ if (typeArguments2.every(dart._isTop)) return true;
1149
+ return null;
1140
1150
}
1141
1151
dart.assert(length == typeArguments2.length);
1142
1152
for (let i = 0; i < length; ++i) {
1143
- if (!dart.isSubtype(typeArguments1[i], typeArguments2[i])) {
1144
- return false;
1153
+ let result = dart.isSubtype_(typeArguments1[i], typeArguments2[i], covariant);
1154
+ if (!result) {
1155
+ return result;
1145
1156
}
1146
1157
}
1147
1158
return true;
1148
1159
}
1149
- if (dart.isClassSubType(t1.__proto__, t2)) return true;
1160
+ let indefinite = false;
1161
+ function definitive(t1, t2) {
1162
+ let result = dart.isClassSubType(t1, t2, covariant);
1163
+ if (result == null) {
1164
+ indefinite = true;
1165
+ return false;
1166
+ }
1167
+ return result;
1168
+ }
1169
+ if (definitive(t1.__proto__, t2)) return true;
1150
1170
let mixins = dart.getMixins(t1);
1151
1171
if (mixins) {
1152
1172
for (let m1 of mixins) {
1153
- if (m1 != null && dart.isClassSubType (m1, t2)) return true;
1173
+ if (m1 != null && definitive (m1, t2)) return true;
1154
1174
}
1155
1175
}
1156
1176
let getInterfaces = dart.getImplements(t1);
1157
1177
if (getInterfaces) {
1158
1178
for (let i1 of getInterfaces()) {
1159
- if (i1 != null && dart.isClassSubType (i1, t2)) return true;
1179
+ if (i1 != null && definitive (i1, t2)) return true;
1160
1180
}
1161
1181
}
1182
+ if (indefinite) return null;
1162
1183
return false;
1163
1184
};
1164
1185
dart.isGroundType = function(type) {
0 commit comments