Skip to content

Commit

Permalink
Fix for prototype check on arrow function/method. Fixes rbuckton#17
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Jan 6, 2016
1 parent 1affc8f commit 6da1e43
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions Reflect.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace Reflect {
const _Map: typeof Map = typeof Map === "function" ? Map : CreateMapPolyfill();
const _Set: typeof Set = typeof Set === "function" ? Set : CreateSetPolyfill();
const _WeakMap: typeof WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();

// [[Metadata]] internal slot
const __Metadata__ = new _WeakMap<Object, Map<string | symbol, Map<any, any>>>();

Expand All @@ -100,15 +100,15 @@ namespace Reflect {
* @param decorators An array of decorators.
* @param target The target object.
* @param targetKey The property key to decorate.
* @param descriptor A property descriptor
* @param descriptor A property descriptor
* @remarks Decorators are applied in reverse order.
* @example
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
*
* static staticMethod() { }
* method() { }
* }
Expand All @@ -120,13 +120,13 @@ namespace Reflect {
* Reflect.decorate(decoratorsArray, C.prototype, "property");
*
* // method (on constructor)
* Object.defineProperty(C, "staticMethod",
* Reflect.decorate(decoratorsArray, C, "staticMethod",
* Object.defineProperty(C, "staticMethod",
* Reflect.decorate(decoratorsArray, C, "staticMethod",
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
*
* // method (on prototype)
* Object.defineProperty(C.prototype, "method",
* Reflect.decorate(decoratorsArray, C.prototype, "method",
* Object.defineProperty(C.prototype, "method",
* Reflect.decorate(decoratorsArray, C.prototype, "method",
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
*
*/
Expand All @@ -143,12 +143,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand All @@ -161,13 +161,13 @@ namespace Reflect {
* Reflect.decorate(decoratorsArray, C.prototype, "property");
*
* // method (on constructor)
* Object.defineProperty(C, "staticMethod",
* Reflect.decorate(decoratorsArray, C, "staticMethod",
* Object.defineProperty(C, "staticMethod",
* Reflect.decorate(decoratorsArray, C, "staticMethod",
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
*
* // method (on prototype)
* Object.defineProperty(C.prototype, "method",
* Reflect.decorate(decoratorsArray, C.prototype, "method",
* Object.defineProperty(C.prototype, "method",
* Reflect.decorate(decoratorsArray, C.prototype, "method",
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
*
*/
Expand Down Expand Up @@ -217,8 +217,8 @@ namespace Reflect {
* @param metadataKey The key for the metadata entry.
* @param metadataValue The value for the metadata entry.
* @returns A decorator function.
* @remarks
* If `metadataKey` is already defined for the target and target key, the
* @remarks
* If `metadataKey` is already defined for the target and target key, the
* metadataValue for that key will be overwritten.
* @example
*
Expand Down Expand Up @@ -275,7 +275,7 @@ namespace Reflect {

return decorator;
}

/**
* Define a unique metadata entry on the target.
* @param metadataKey A key used to store and retrieve metadata.
Expand Down Expand Up @@ -307,11 +307,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -344,12 +344,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace Reflect {

return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
}

/**
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
* @param metadataKey A key used to store and retrieve metadata.
Expand All @@ -410,11 +410,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -442,12 +442,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -503,11 +503,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -535,12 +535,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -596,11 +596,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -628,12 +628,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -689,11 +689,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -721,12 +721,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -780,11 +780,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand All @@ -811,12 +811,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -870,11 +870,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand All @@ -901,12 +901,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -962,11 +962,11 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // property (on constructor)
Expand Down Expand Up @@ -994,12 +994,12 @@ namespace Reflect {
*
* class C {
* // property declarations are not part of ES6, though they are valid in TypeScript:
* // static staticProperty;
* // static staticProperty;
* // property;
*
* constructor(p) { }
* static staticMethod(p) { }
* method(p) { }
* method(p) { }
* }
*
* // constructor
Expand Down Expand Up @@ -1252,7 +1252,7 @@ namespace Reflect {
return proto;
}

// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
// Try to determine the superclass constructor. Compatible implementations
// must either set __proto__ on a subclass constructor to the superclass constructor,
// or ensure each class has a valid `constructor` property on its prototype that
Expand All @@ -1266,7 +1266,7 @@ namespace Reflect {

// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
let prototype = O.prototype;
let prototypeProto = Object.getPrototypeOf(prototype);
let prototypeProto = prototype && Object.getPrototypeOf(prototype);
if (prototypeProto == null || prototypeProto === Object.prototype) {
return proto;
}
Expand Down

0 comments on commit 6da1e43

Please sign in to comment.