Changeset 207725 in webkit
- Timestamp:
- Oct 22, 2016 10:06:19 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207724 r207725 1 2016-10-22 Chris Dumez <cdumez@apple.com> 2 3 [Web IDL] Two types are distinguishable for overload resolution if at most one of the two includes a nullable type 4 https://bugs.webkit.org/show_bug.cgi?id=163791 5 6 Reviewed by Sam Weinig. 7 8 Update overload resolution in the bindings generator so that 2 nullable types 9 are no longer considered as distinguishable, as per Web IDL: 10 - https://heycam.github.io/webidl/#dfn-distinguishable 11 12 * bindings/scripts/CodeGeneratorJS.pm: 13 (AreTypesDistinguishableForOverloadResolution): 14 * bindings/scripts/test/JS/JSTestObj.cpp: 15 (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1): 16 (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1Caller): 17 (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2): 18 (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2Caller): 19 (WebCore::jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter): 20 * bindings/scripts/test/TestObj.idl: 21 1 22 2016-10-22 Chris Dumez <cdumez@apple.com> 2 23 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207716 r207725 1974 1974 }; 1975 1975 1976 # FIXME: The WebIDL mandates this but this currently does not work because some of our IDL is wrong.1977 #return 0 if $idlTypeA->isNullable && $idlTypeB->isNullable;1976 # Two types are distinguishable for overload resolution if at most one of the two includes a nullable type. 1977 return 0 if $idlTypeA->isNullable && $idlTypeB->isNullable; 1978 1978 1979 1979 # Union types: idlTypeA and idlTypeB are distinguishable if: -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207711 r207725 963 963 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadWithNullableUnion(JSC::ExecState*); 964 964 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadWithOptionalUnion(JSC::ExecState*); 965 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter(JSC::ExecState*); 965 966 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(JSC::ExecState*); 966 967 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional(JSC::ExecState*); … … 1586 1587 { "overloadWithNullableUnion", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadWithNullableUnion), (intptr_t) (1) } }, 1587 1588 { "overloadWithOptionalUnion", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadWithOptionalUnion), (intptr_t) (0) } }, 1589 { "overloadWithNullableNonDistinguishingParameter", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter), (intptr_t) (2) } }, 1588 1590 { "classMethodWithClamp", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithClamp), (intptr_t) (2) } }, 1589 1591 { "classMethodWithEnforceRange", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionClassMethodWithEnforceRange), (intptr_t) (2) } }, … … 7156 7158 } 7157 7159 7160 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1Caller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&); 7161 7162 static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1(ExecState* state) 7163 { 7164 return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1Caller>(state, "overloadWithNullableNonDistinguishingParameter"); 7165 } 7166 7167 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1Caller(JSC::ExecState* state, JSTestObj* castedThis, JSC::ThrowScope& throwScope) 7168 { 7169 UNUSED_PARAM(state); 7170 UNUSED_PARAM(throwScope); 7171 auto& impl = castedThis->wrapped(); 7172 if (UNLIKELY(state->argumentCount() < 2)) 7173 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); 7174 TestObj* obj = nullptr; 7175 if (!state->uncheckedArgument(0).isUndefinedOrNull()) { 7176 obj = JSTestObj::toWrapped(state->uncheckedArgument(0)); 7177 if (UNLIKELY(!obj)) 7178 return throwArgumentTypeError(*state, throwScope, 0, "obj", "TestObject", "overloadWithNullableNonDistinguishingParameter", "TestObj"); 7179 } 7180 auto node = JSTestNode::toWrapped(state->uncheckedArgument(1)); 7181 if (UNLIKELY(!node)) 7182 return throwArgumentTypeError(*state, throwScope, 1, "node", "TestObject", "overloadWithNullableNonDistinguishingParameter", "TestNode"); 7183 impl.overloadWithNullableNonDistinguishingParameter(WTFMove(obj), *node); 7184 return JSValue::encode(jsUndefined()); 7185 } 7186 7187 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2Caller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&); 7188 7189 static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2(ExecState* state) 7190 { 7191 return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2Caller>(state, "overloadWithNullableNonDistinguishingParameter"); 7192 } 7193 7194 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2Caller(JSC::ExecState* state, JSTestObj* castedThis, JSC::ThrowScope& throwScope) 7195 { 7196 UNUSED_PARAM(state); 7197 UNUSED_PARAM(throwScope); 7198 auto& impl = castedThis->wrapped(); 7199 if (UNLIKELY(state->argumentCount() < 2)) 7200 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); 7201 TestNode* node = nullptr; 7202 if (!state->uncheckedArgument(0).isUndefinedOrNull()) { 7203 node = JSTestNode::toWrapped(state->uncheckedArgument(0)); 7204 if (UNLIKELY(!node)) 7205 return throwArgumentTypeError(*state, throwScope, 0, "node", "TestObject", "overloadWithNullableNonDistinguishingParameter", "TestNode"); 7206 } 7207 auto index = convert<IDLLong>(*state, state->uncheckedArgument(1), NormalConversion); 7208 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7209 impl.overloadWithNullableNonDistinguishingParameter(WTFMove(node), WTFMove(index)); 7210 return JSValue::encode(jsUndefined()); 7211 } 7212 7213 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter(ExecState* state) 7214 { 7215 VM& vm = state->vm(); 7216 auto throwScope = DECLARE_THROW_SCOPE(vm); 7217 UNUSED_PARAM(throwScope); 7218 size_t argsCount = std::min<size_t>(2, state->argumentCount()); 7219 if (argsCount == 2) { 7220 JSValue distinguishingArg = state->uncheckedArgument(1); 7221 if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSTestNode::info())) 7222 return jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter1(state); 7223 if (distinguishingArg.isNumber()) 7224 return jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2(state); 7225 return jsTestObjPrototypeFunctionOverloadWithNullableNonDistinguishingParameter2(state); 7226 } 7227 return argsCount < 2 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); 7228 } 7229 7158 7230 EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod(ExecState* state) 7159 7231 { -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r207705 r207725 314 314 void overloadWithOptionalUnion(optional (DOMString or boolean) objectOrNode = true); 315 315 void overloadWithOptionalUnion(long index); 316 317 void overloadWithNullableNonDistinguishingParameter(TestObj? obj, TestNode node); 318 void overloadWithNullableNonDistinguishingParameter(TestNode? node, long index); 316 319 #endif 317 320
Note: See TracChangeset
for help on using the changeset viewer.