todo dk: think about specific method versions for each allowed type
765794
public void setValue(Object newValue) {
        Object checkedValue = checkValue(newValue);
        setDirty(isDifferent(baseValue, checkedValue));
        if (isDifferent(value, checkedValue)){ // firePropertyChange doesn't do this check sufficiently
            firePropertyChange(VALUE, value, value = checkedValue); // set inline to avoid recursion
        }
    }
394627
def setAllowedTypes(self, allowed_types):
        """"""
        for (assoc_type, session_type) in allowed_types:
            checkSessionType(assoc_type, session_type)

        self.allowed_types = allowed_types
156724
@SuppressWarnings("all")
    public static Method findMethodOrThrowException(Class<?> type, String methodName, Class<?>... parameterTypes) {
        Method methodToMock = findMethod(type, methodName, parameterTypes);
        throwExceptionIfMethodWasNotFound(type, methodName, methodToMock, (Object[]) parameterTypes);
        return methodToMock;
    }
1088275
protected void checkNonGenericParameter(Method executeMethod, Parameter parameter) {
        if (isNonGenericCheckTargetType(parameter.getType())) { // e.g. List
            final Type paramedType = parameter.getParameterizedType();
            if (paramedType == null) { // no way? no check just in case
                return;
            }
            if (paramedType instanceof ParameterizedType) {
                final Type[] typeArgs = ((ParameterizedType) paramedType).getActualTypeArguments();
                if (typeArgs != null && typeArgs.length > 0 && "?".equals(typeArgs[0].getTypeName())) { // e.g. List<?>
                    throwActionFormWildcardOnlyListParameterException(executeMethod, parameter);
                }
            } else {
                throwActionFormNonGenericListParameterException(executeMethod, parameter);
            }
        }
    }
432480
function permittedOptions(methodName) {
        var options = ghostBookshelf.Model.permittedOptions.call(this, methodName),

            // whitelists for the `options` hash argument on methods, by method name.
            // these are the only options that can be passed to Bookshelf / Knex.
            validOptions = {
                findOne: ['withRelated']
            };

        if (validOptions[methodName]) {
            options = options.concat(validOptions[methodName]);
        }

        return options;
    }
805288
function couldContainTypeParameters(type) {
            return !!(type.flags & 16384 /* TypeParameter */ ||
                type.flags & 131072 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
                type.flags & 2097152 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) ||
                type.flags & 1572864 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type));
        }
621008
private static boolean implementsMethod(ClassNode classNode, String methodName, Class[] argTypes) {
        List methods = classNode.getMethods();
        if (argTypes == null || argTypes.length ==0) {
            for (Iterator i = methods.iterator(); i.hasNext();) {
                MethodNode mn = (MethodNode) i.next();
                boolean methodMatch = mn.getName().equals(methodName);
                if(methodMatch)return true;
                // TODO Implement further parameter analysis
            }
        }
        return false;
    }
530620
function getType(type, method) {
    var generics = [];
    switch (type) {
      case 'Array':
        type = 'T[]';
        generics.push('T');
        break;
      case 'New Array':
        type = 'U[]';
        generics.push('T');
        generics.push('U');
        break;
      case 'ArrayElement':
        type = 'T';
        generics.push('T');
        break;
      case 'Mixed':
        type = 'T';
        generics.push('T');
        break;
      case 'Property':
        type = 'T';
        generics.push('T');
        break;
      case 'NewArrayElement':
        type = 'U';
        generics.push('T');
        generics.push('U');
        break;
      case 'NewProperty':
        type = 'U';
        generics.push('T');
        generics.push('U');
        break;
      case 'RangeElement':
        type = 'T';
        generics.push('T');
        break;
      case 'String':
      case 'Number':
      case 'Boolean':
        type = type.toLowerCase();
        break;
    }
    if (method && generics) {
      addMethodGenerics(method, generics);
    }
    return type;
  }
849009
private Optional<SoyType> soyTypeForProtoOrEnum(Class<?> type, Method method) {
    // Message isn't supported because we can't get a descriptor from it.
    if (type == Message.class) {
      reporter.invalidReturnType(Message.class, method);
      return Optional.absent();
    }
    Optional<String> fullName = nameFromDescriptor(type);
    if (!fullName.isPresent()) {
      reporter.incompatibleReturnType(type, method);
      return Optional.absent();
    }
    SoyType returnType = registry.getType(fullName.get());
    if (returnType == null) {
      reporter.incompatibleReturnType(type, method);
      return Optional.absent();
    }
    return Optional.of(returnType);
  }
1003564
function getCurrentActiveType (version) {
  let typelist = TypeList
  for (let i = 0; i < typelist.length; i++) {
    if (semver[typelist[i]](version)) {
      return typelist[i]
    }
  }
}
908921
function krillPrimValidateTypes(fieldtypes, pred)
{
	var func = function (ent, key) {
	    return (krillPrimValidateFieldType(fieldtypes, ent, key));
	};

	krillPrimWalk(func, pred);
}
945089
Env<AttrContext> methodEnv(JCMethodDecl tree, Env<AttrContext> env) {
        Env<AttrContext> localEnv =
            env.dup(tree, env.info.dup(env.info.scope.dupUnshared(tree.sym)));
        localEnv.enclMethod = tree;
        if (tree.sym.type != null) {
            //when this is called in the enter stage, there's no type to be set
            localEnv.info.returnResult = attr.new ResultInfo(KindSelector.VAL,
                                                             tree.sym.type.getReturnType());
        }
        if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++;
        return localEnv;
    }
893021
public static Function<Object,Double> d(final String methodName, final Object... optionalParameters) {
        return methodForDouble(methodName, optionalParameters);
    }
931406
private static void checkTypeAdapterForParam( SQLiteModelMethod method,
			String methodParamName, Class<? extends Annotation> annotation) {
		
		TypeName paramType=method.findParameterType(methodParamName);
		if (method.isSpreadParameter(methodParamName)) {
			if (paramType instanceof ArrayTypeName) {				
				paramType = ((ArrayTypeName) paramType).componentType;
			} else if (paramType instanceof ParameterizedTypeName) {				
				paramType = ((ParameterizedTypeName) paramType).typeArguments.get(0);
			} 
		}
		
		TypeName adapterType = method.getAdapterForParam(methodParamName);
		
		
		TypeName sourceType = TypeUtility.typeName(TypeAdapterHelper.detectSourceType(method, adapterType));
		TypeName uboxSourceType=sourceType;
		
		if (TypeUtility.isTypeWrappedPrimitive(sourceType)) {
			uboxSourceType=sourceType.unbox();
		}
		
		boolean expr=uboxSourceType.toString().equals(paramType.toString()) || sourceType.toString().equals(paramType.toString());
		
		
		AssertKripton.fail(!expr,
				"In DAO '%s', method '%s' has parameter '%s' uses @%s that manages type '%s' instead of '%s'", method.getParent().getName(), method.getName(),
				methodParamName, annotation.getSimpleName(),sourceType, paramType);

	}
1310631
function makeTypeChecker(freeTypeVars) {
		if (!freeTypeVars)
			freeTypeVars = []

		var bound_type_params = new Map
		var bound_nodes = []
		freeTypeVars.forEach(function(tp) {
			bound_type_params.put(tp.name, [])
		})

		var callSigMatches = []

		function isPrtyCompatibleWithType(prty, type, path, receiver) {
			if (prty.type === 'node') {
				return isNodeCompatibleWithType(prty.node, type, path, receiver)
			} else {
				var ok = prty.types.some(function(t) {
					return isTypeCompatibleWithType(t, type, null)
				})
				if (!ok) {
					reportError(path, 'expected ' + formatType(type) + ' but found ' + formatUnion(prty.types))
				}
				return ok
			}
		}
		var node_prty_compatible = Object.create(null)
		function isNodeCompatibleWithProperty(node, k, prty, path, receiver) {
			if (prty.meta.origin === LIB_ORIGIN) // there are too many non-portable properties in lib.d.ts
				return true
			if (!receiver)
				receiver = node
			node = node.rep()
			if (node.isAny)
				return true
			if (node.isFree) {
				bound_nodes.push({type: 'type', node: node, bound: prty.type})
				return true
			}
			var name = node.translateName(k)
			var dst = node.properties.get(name)
			if (dst) {
				return isPrtyCompatibleWithType(dst, prty.type, path, receiver)
			} else {
				var protoWithPrty = node.prototypes.filter(function(proto) {
					return proto.properties.has(name)
				})
				protoWithPrty = protoWithPrty.unique(function(proto) { return proto.rep().id })
				if (protoWithPrty.length === 0) {
					if (!prty.optional) {
						reportError(path, 'expected ' + formatType(prty.type) + ' but found nothing')
						return false
					}
					return true
				} else if (protoWithPrty.length === 1) {
					return isPrtyCompatibleWithType(protoWithPrty[0].properties.get(name), prty.type, path, receiver)
				} else {
					var h = node.id + '~' + k + '~' + prty.optional + '.' + canonicalizeType(prty.type)
					if (h in node_prty_compatible)
						return node_prty_compatible[h]
					node_prty_compatible[h] = false	
					var ok = node.prototypes.some(function(proto) {
						return isNodeCompatibleWithProperty(proto, k, prty, null, receiver)
					})
					if (!ok) {
						reportError(path, 'expected ' + prty.type + ' but found [complex type]')
					}
					node_prty_compatible[h] = ok
					return ok
				}
			}
		}
		var node_type_compatible = Object.create(null)
		function isNodeCompatibleWithType(node, type, path, receiver, continueOnError) {
			node = node.rep()
			if (node.isAny) {
				return true
			}
			if (node.isFree) {
				bound_nodes.push({type: 'type', node: node, bound: type})
				return true
			}
			var h = canonicalizeType(type) + "~" + node.id // TODO: include receiver??
			if (h in node_type_compatible) {
				return node_type_compatible[h]
			}
			node_type_compatible[h] = true
			return node_type_compatible[h] = isNodeCompatibleWithTypeX(node, type, path, receiver, continueOnError)
		}
		function isNodeCompatibleWithTypeX(node, type, path, receiver, continueOnError) {
			node = node.rep()
			if (node.isAny || node.primitives.has({type:'value', value:null}))
				return true
			var originalType = type
			if (type.type === 'reference')
				type = resolveTypeRef(type)
			switch (type.type) {
				case 'object':
					var ok = true
					if (!node.isObject) {
						reportError(path, 'expected ' + formatType(originalType) + ' but found ' + formatNodeAsPrimitive(node))
						ok = false
						return false
					}
					if (type.brand && isValidBrand(type.brand)) {
						var hasBrand = !node.brands.isEmpty()
						ok = node.brands.some(type.brand)
						if (!ok) {
							ok = node.prototypes.some(function(proto) {
								return hasBrand |= proto.brands.some(type.brand)
							})
						}
						if (!ok) {
							if (hasBrand) {
								reportError(path, 'expected ' + type.brand + ' but found ' + formatNode(node) + ' [BRAND]')
							} else {
								reportError(path, 'missing prototype for branded type ' + type.brand)
							}
						}
						if (!continueOnError)
							return ok // defer checking of other properties to the constructor check
					}
					for (var k in type.properties) {
						if (!isNodeCompatibleWithProperty(node, k, type.properties[k], qualify(path,k))) {
							ok = false 
							if (!continueOnError) return false
						}
					}
					if (type.numberIndexer) {
						ok &= node.properties.all(function(name,dst) {
							if (!isNumberString(name))
								return true
							return isPrtyCompatibleWithType(dst, type.numberIndexer, qualify(path,'[' + name + ']'), node)
						})
						if (!ok && !continueOnError) return false
					}
					if (type.stringIndexer) {
						ok &= node.properties.all(function(name,dst) {
							// FIXME: enumerability check?
							return isPrtyCompatibleWithType(dst, type.stringIndexer, qualify(path, "['" + name + "']"), node)
						})
						if (!ok && !continueOnError) return false
					}
					if (type.calls.length > 0 && node.functions.isEmpty() && node.call_sigs.isEmpty()) {
						reportError(path, 'expected ' + formatTypeCall(type.calls[0]) + ' but found non-function object')
						ok = false
						if (!continueOnError) return false
					}
					type.calls.forEach(function(sig) {
						callSigMatches.push({
							callsig: sig,
							node: node,
							receiver: receiver,
							path: path
						})
					})
					return ok
				case 'enum':
					var enum_vals = enum_values.get(type.name)
					if (enum_vals.length === 0) {
						return true
					}
					var ok = enum_vals.some(function(v) {
						return isNodeCompatibleWithValue(node, v)
					})
					if (!ok) {
						reportError(path, 'expected ' + type.name + ' but found ' + formatNodeAsPrimitive(node))
					}
					return ok
				case 'any':
				case 'void':
					return true
				case 'number':
				case 'string':
				case 'boolean':
					if (node.primitives.has({type: type.type}))
						return true
					var ok = node.primitives.some(function(t) {
						return t.type === 'value' && typeof t.value === type.type
					})
					if (!ok) {
						reportError(path, 'expected ' + formatType(type) + ' but found ' + formatNodeAsPrimitive(node))
					}
					return ok
				case 'string-const':
					if (node.primitives.has({type: 'value', value: type.value}))
						return true
					if (node.primitives.has({type: 'string'}))
						return true
					reportError(path, 'expected ' + formatType(type) + ' but found ' + formatNodeAsPrimitive(node))
					return false
				case 'node':
					bound_nodes.push({type: 'node', node: type.node, bound: node})
					return true
				case 'type-param':
					if (!bound_type_params.has(type.name))
						throw new Error("Unbound type parameter " + type.name)
					// TODO: check constraint
					bound_type_params.push(type.name, {type: 'node', node: node})
					return true
				case 'opaque-type':
					if (node.primitives.has(type)) {
						return true
					} else {
						reportError(path, "expected generic type " + type.name + " but found " + formatNode(node))
						return false
					}
				default:
					throw new Error("Unexpected type: " + util.inspect(type))
			}
			return true
		}
		function isNodeCompatibleWithValue(node, v) {
			node = node.rep()
			if (v === null)
				return true
			if (v && typeof v === 'object')
				return node === getConcreteObject(v.key)
			if (node.primitives.has({type:'value', value:v}))
				return true
			switch (typeof v) {
				case 'number':
					return node.primitives.has({type:'number'})
				case 'string':
					return node.primitives.has({type:'string'})
				case 'boolean':
					return node.primitives.has({type:'boolean'})
				case 'undefined':
					return node.primitives.has({type:'void'})
				default:
					throw new Error("Unexpected value: " + util.inspect(v))
			}
		}
		var type2type_compatible = Object.create(null)
		function isTypeCompatibleWithType(t1, t2, path, continueOnError) {
			if (t1.type === 'reference' || t2.type === 'reference') {
				var h = canonicalizeType(t1) + '~' + canonicalizeType(t2)
				if (h in type2type_compatible)
					return type2type_compatible[h]
				type2type_compatible[h] = true
				return type2type_compatible[h] = isTypeCompatibleWithTypeX(t1, t2, path, continueOnError)
			}
			return isTypeCompatibleWithTypeX(t1, t2, path, continueOnError)
		}
		function isTypeCompatibleWithTypeX(t1, t2, path, continueOnError) {
			if (t1.type === 'any' || t2.type === 'any')
				return true
			if (t1.type === 'node')
				return isNodeCompatibleWithType(t1.node, t2, path)
			if (t1.type === 'reference' && t2.type === 'reference' && t1.name === t2.name) {
				// Approximate compatibility check on references by simply checking type arguments
				// This not technically not a compatibility check between structural types, but
				// I will expect it will produce more useful error messages, 
				// e.g. "expected string[] but found number[]" 
				var ok = t1.typeArguments.all(function(p1, i) {
					return isTypeCompatibleWithType(p1, t2.typeArguments[i], null)
				})
				if (!ok) {
					reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
				}
				return ok
			}
			if (t1.type === 'reference' && t2.type === 'reference') {
				// expand both references, but cut off the path here, so we don't report
				// a complicated message describing why the two references are incompatible
				// e.g. "expected Promise but found HttpRequest" instead of unfolding both types in the error message
				var ok = isTypeCompatibleWithType(resolveTypeRef(t1), resolveTypeRef(t2), null)
				if (!ok) {
					reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
				}
				return ok
			}
			if (t2.type === 'reference')
				t2 = resolveTypeRef(t2)
			if (t2.type === 'object' && (t1.type !== 'object' && t1.type !== 'reference')) {
				// Coerce t1 to an object. If the compatibility check fails, report the error
				// as simply "expected XX but found number" instead of a complicated message resulting from
				// a structural compatibility check
				var t1o = coerceTypeToObject(t1)
				if (t1o.type === 'object' || t1o.type === 'reference') {
					var ok = isTypeCompatibleWithType(t1o, t2, null)
					if (!ok) {
						reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
					}
					return ok
				}
			}
			switch (t2.type) {
				case 'object':
					var original_t1 = t1
					if (t1.type === 'opaque-type' && t1.constraint)
						t1 = t1.constraint
					if (t1.type === 'reference')
						t1 = resolveTypeRef(t1)
					if (t1.type !== 'object') {
						reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(original_t1))
						return false
					}
					var ok = true
					for (var k in t2.properties) {
						if (t1.properties.hasOwnProperty(k)) {
							if (!isTypeCompatibleWithType(t1.properties[k].type, t2.properties[k].type, qualify(path,k))) {
								ok = false
								if (!continueOnError) {
									return false
								}
							}
						}
						else if (t1.numberIndexer && isNumberString(k)) {
							if (!isTypeCompatibleWithType(t1.numberIndexer, t2.properties[k].type, qualify(path, k))) {
								ok = false
								if (!continueOnError)
									return false
							}
						}
						else if (t1.stringIndexer) {
							if (!isTypeCompatibleWithType(t1.stringIndexer, t2.properties[k].type, qualify(path, k))) {
								ok = false
								if (!continueOnError)
									return false
							}	
						}
						else {
							if (!t2.properties[k].optional) {
								reportError(qualify(path,k), 'expected ' + formatType(t2) + ' but found nothing')
								ok = false
								if (!continueOnError)
									return false
							}
						}
					}
					if (t2.numberIndexer) {
						for (var k in t1.properties) {
							if (isNumberString(k)) {
								if (!isTypeCompatibleWithType(t1.properties[k].type, t2.numberIndexer, qualify(path, k))) {
									ok = false
									if (!continueOnError)
										return false
								}
							}
						}
						if (t1.numberIndexer) {
							if (!isTypeCompatibleWithType(t1.numberIndexer, t2.numberIndexer, qualify(path, '[number]'))) {
								ok = false
								if (!continueOnError)
									return false
							}
						}
					}
					if (t2.stringIndexer) {
						for (var k in t1.properties) {
							// TODO: enumerability check?
							if (!isTypeCompatibleWithType(t1.properties[k].type, t2.stringIndexer, qualify(path, k))) {
								ok = false
								if (!continueOnError)
									return false
							}
						}
						if (t1.stringIndexer) {
							if (!isTypeCompatibleWithType(t1.stringIndexer, t2.stringIndexer, qualify(path, '[number]'))) {
								ok = false
								if (!continueOnError)
									return false
							}
						}
					}
					// TODO: calls, brands?
					return ok
				case 'number':
				case 'string':
				case 'boolean':
					var ok = t1.type === t2.type || (t1.type === 'value' && typeof t1.value === t2.type)
					if (!ok) {
						reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
					}
					return ok
				case 'string-const':
					var ok = t1.type === 'string' || (t1.type === 'value' && t1.value === t2.value)
					if (!ok) {
						reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
					}
					return ok
				case 'value':
					var ok = (t1.type === typeof t2.value) || (t1.type === 'value' && t1.value === t2.value)
					if (!ok) {
						reportError(path, 'expected ' + formatType(t2) + ' but found ' + formatType(t1))
					}
					return ok
				case 'enum':
					return true // TODO: check enum type properly
				case 'void':
					return true
				case 'node':
					bound_nodes.push({type: 'type', node: t2.node, bound: t1})
					return true
				case 'type-param':
					if (!bound_type_params.has(t2.name))
						throw new Error("Unbound type parameter " + t2.name)
					// TODO: check constraint
					bound_type_params.push(t2.name, {type: 'type', bound: t1})
					return true
				case 'opaque-type':
					if (t1.type === 'opaque-type' && t1.name === t2.name)
						return true
					reportError(path, 'expected generic type ' + t2.name + ' but found ' + formatType(t1))
					return false
				case 'type-param':
					throw new Error
				default:
					throw new Error("Unexpected type: " + t2.type)
			}
		}
		function isCallCompatibleWithCall(incall, outcall) {
			// TODO: variadic
			incall = widenPolymorphicCallSig(incall) // just approximate tests for polymorphic functions (TODO: proper type check)
			outcall = widenPolymorphicCallSig(outcall)

			// Check that the parameters to outcall can be used in a valid call to incall
			for (var i=0; i<incall.parameters.length; ++i) {
				var iparm = incall.parameters[i]
				if (i < outcall.parameters.length) {
					var oparm = outcall.parameters[i]
					if (!isTypeCompatibleWithType(oparm.type, iparm.type, null, false)) {
						return false
					}
				} else if (!iparm.optional) {
					return false
				}
			}

			// Check that return type from incall is a valid return type from outcall
			return isTypeCompatibleWithType(incall.returnType, outcall.returnType, null, false)
		}
		return {
			isTypeCompatibleWithType: isTypeCompatibleWithType,
			isNodeCompatibleWithType: isNodeCompatibleWithType,
			isPrtyCompatibleWithType: isPrtyCompatibleWithType,
			isNodeCompatibleWithProperty: isNodeCompatibleWithProperty,
			isCallCompatibleWithCall: isCallCompatibleWithCall,
			getBoundTypeParams: function() { return bound_type_params },
			getBoundNodes: function() { return bound_nodes },
			getCallSigMatches: function() { return callSigMatches },
		}
	}
785351
def _generate_standard_methods(cls):
        """"""
        for state in cls.context.states_enum:
            getter_name = 'is_{name}'.format(name=state.value)
            cls.context.new_methods[getter_name] = utils.generate_getter(state)

            setter_name = 'set_{name}'.format(name=state.value)
            cls.context.new_methods[setter_name] = utils.generate_setter(state)

            checker_name = 'can_be_{name}'.format(name=state.value)
            checker = utils.generate_checker(state)
            cls.context.new_methods[checker_name] = checker

        cls.context.new_methods['actual_state'] = utils.actual_state
        cls.context.new_methods['as_enum'] = utils.as_enum
        cls.context.new_methods['force_set'] = utils.force_set
215249
private void validateExternalCallback(Method method, CallbackType callbackType) {
    Class<?>[] parameters = method.getParameterTypes();
    if (!parameters[0].isAssignableFrom(entityClass)) {
      String message = String.format("Method %s in class %s is not valid for entity %s",
          method.getName(), method.getDeclaringClass().getName(), entityClass.getName());
      throw new EntityManagerException(message);
    }
    CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.EXTERNAL,
        callbackType, method);
    metadata.put(callbackType, callbackMetadata);
  }