diff --git a/src/com/google/javascript/jscomp/TypedScopeCreator.java b/src/com/google/javascript/jscomp/TypedScopeCreator.java index 4e9fa5c1c93..b144ce0bbda 100644 --- a/src/com/google/javascript/jscomp/TypedScopeCreator.java +++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java @@ -1806,22 +1806,6 @@ private ObjectType getObjectSlot(String slotName) { return null; } - /** - * When a class has a stub for a property, and the property exists on a super interface, - * use that type. - */ - private JSType getInheritedInterfacePropertyType(ObjectType obj, String propName) { - if (obj != null && obj.isPrototypeObject()) { - FunctionType f = obj.getOwnerFunction(); - for (ObjectType i : f.getImplementedInterfaces()) { - if (i.hasProperty(propName)) { - return i.getPropertyType(propName); - } - } - } - return null; - } - /** * Resolve any stub declarations to unknown types if we could not * find types for them during traversal. @@ -1842,19 +1826,17 @@ void resolveStubDeclarations() { // If we see a stub property, make sure to register this property // in the type registry. ObjectType ownerType = getObjectSlot(ownerName); - JSType inheritedType = getInheritedInterfacePropertyType(ownerType, propName); - JSType stubType = inheritedType == null ? unknownType : inheritedType; - defineSlot(n, parent, stubType, true); + defineSlot(n, parent, unknownType, true); if (ownerType != null && (isExtern || ownerType.isFunctionPrototypeType())) { // If this is a stub for a prototype, just declare it // as an unknown type. These are seen often in externs. ownerType.defineInferredProperty( - propName, stubType, n); + propName, unknownType, n); } else { typeRegistry.registerPropertyOnType( - propName, ownerType == null ? stubType : ownerType); + propName, ownerType == null ? unknownType : ownerType); } } } diff --git a/test/com/google/javascript/jscomp/TypeCheckTest.java b/test/com/google/javascript/jscomp/TypeCheckTest.java index 7cd322bc3b1..10f72fa8d27 100644 --- a/test/com/google/javascript/jscomp/TypeCheckTest.java +++ b/test/com/google/javascript/jscomp/TypeCheckTest.java @@ -2951,47 +2951,6 @@ public void testStubFunctionDeclaration10() { "function(number): number"); } - - public void testStubMethodDeclarationDoesntBlockTypechecking_1() { - testTypes( - lines( - "/** @interface */", - "function Foo() {}", - "/** @return {number} */", - "Foo.prototype.method = function() {};", - "/**", - " * @constructor", - " * @implements {Foo}", - " */", - "function Bar() {}", - "Bar.prototype.method;", - "var /** null */ n = (new Bar).method();"), - lines( - "initializing variable", - "found : number", - "required: null")); - } - - public void testStubMethodDeclarationDoesntBlockTypechecking_2() { - testTypes( - lines( - "/** @constructor */", - "function Foo() {}", - "/** @return {number} */", - "Foo.prototype.method = function() {};", - "/**", - " * @constructor", - " * @extends {Foo}", - " */", - "function Bar() {}", - "Bar.prototype.method;", - "var /** null */ n = (new Bar).method();"), - lines( - "initializing variable", - "found : number", - "required: null")); - } - public void testNestedFunctionInference1() { String nestedAssignOfFooAndBar = "/** @constructor */ function f() {};" +