Index: lib/runtime/dart/_runtime.js |
diff --git a/lib/runtime/dart/_runtime.js b/lib/runtime/dart/_runtime.js |
index 8a986bce275276f0102decb8e2f3f7ba3c1925a4..585431c59158939e89f70fa981d5e530ad55006a 100644 |
--- a/lib/runtime/dart/_runtime.js |
+++ b/lib/runtime/dart/_runtime.js |
@@ -173,6 +173,9 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
defineProperty(clazz, name, {value: ctor, configurable: true}); |
} |
const _extensionType = Symbol("extensionType"); |
+ function getExtensionType(obj) { |
+ return obj[_extensionType]; |
+ } |
const dartx = {}; |
function getExtensionSymbol(name) { |
let sym = dartx[name]; |
@@ -182,16 +185,18 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
function defineExtensionNames(names) { |
return names.forEach(getExtensionSymbol); |
} |
+ function _installProperties(jsProto, extProto) { |
+ if (extProto !== core.Object.prototype && extProto !== jsProto) { |
+ _installProperties(jsProto, extProto.__proto__); |
+ } |
+ copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); |
+ } |
function registerExtension(jsType, dartExtType) { |
let extProto = dartExtType.prototype; |
let jsProto = jsType.prototype; |
assert_(jsProto[_extensionType] === void 0); |
- jsProto[_extensionType] = extProto; |
- let dartObjProto = core.Object.prototype; |
- while (extProto !== dartObjProto && extProto !== jsProto) { |
- copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); |
- extProto = extProto.__proto__; |
- } |
+ jsProto[_extensionType] = dartExtType; |
+ _installProperties(jsProto, extProto); |
let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; |
assert_(originalSigFn); |
defineMemoizedGetter(jsType, _methodSig, originalSigFn); |
@@ -220,6 +225,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
} |
function setType(obj, type) { |
obj.__proto__ = type.prototype; |
+ obj.__proto__[_extensionType] = type; |
return obj; |
} |
function list(obj, elementType) { |
@@ -476,7 +482,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
} |
function strongInstanceOf(obj, type, ignoreFromWhiteList) { |
let actual = realRuntimeType(obj); |
- if (isSubtype(actual, type) || actual == jsobject) return true; |
+ if (isSubtype(actual, type) || actual == jsobject || actual == core.int && type == core.double) return true; |
if (ignoreFromWhiteList == void 0) return false; |
if (isGroundType(type)) return false; |
if (_ignoreTypeFailure(actual, type)) return true; |
@@ -685,7 +691,11 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
function runtimeType(obj) { |
let result = checkPrimitiveType(obj); |
if (result !== null) return result; |
- return obj.runtimeType; |
+ result = obj.runtimeType; |
+ if (result) return result; |
+ result = obj[_extensionType]; |
+ if (result) return result; |
+ return null; |
} |
function getFunctionType(obj) { |
let args = Array(obj.length).fill(dynamicR); |
@@ -696,6 +706,8 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
if (result !== null) return result; |
result = obj[_runtimeType]; |
if (result) return result; |
+ result = obj[_extensionType]; |
+ if (result) return result; |
result = obj.constructor; |
if (result == Function) { |
return jsobject; |
@@ -1199,6 +1211,7 @@ dart_library.library('dart/_runtime', null, /* Imports */[ |
exports.hasMethod = hasMethod; |
exports.virtualField = virtualField; |
exports.defineNamedConstructor = defineNamedConstructor; |
+ exports.getExtensionType = getExtensionType; |
exports.dartx = dartx; |
exports.getExtensionSymbol = getExtensionSymbol; |
exports.defineExtensionNames = defineExtensionNames; |