A parameterized event type is considered assignable to a parameterized observed event type if
they have identical raw type and for each parameter:
191537
private boolean parametersMatch(Type observedParameter, Type eventParameter) {
        if (Types.isActualType(observedParameter) && Types.isActualType(eventParameter)) {
            /*
             * the observed event type parameter is an actual type with identical raw type to the event type
             * parameter, and, if the type is parameterized, the event type parameter is assignable to the
             * observed event type parameter according to these rules, or
             */
            return matches(observedParameter, eventParameter);
        }
        if (observedParameter instanceof WildcardType && eventParameter instanceof WildcardType) {
            /*
             * both the observed event type parameter and the event type parameter are wildcards, and the event type parameter is assignable to the observed event
             * type
             */
            return CovariantTypes.isAssignableFrom(observedParameter, eventParameter);
        }
        if (observedParameter instanceof WildcardType) {
            /*
             * the observed event type parameter is a wildcard and the event type parameter is assignable
             * to the upper bound, if any, of the wildcard and assignable from the lower bound, if any, of the
             * wildcard, or
             */
            return parametersMatch((WildcardType) observedParameter, eventParameter);
        }
        if (observedParameter instanceof TypeVariable<?>) {
            /*
             * the observed event type parameter is a type variable and the event type parameter is assignable
             * to the upper bound, if any, of the type variable.
             */
            return parametersMatch((TypeVariable<?>) observedParameter, eventParameter);
        }
        return false;
    }
311678
@CheckReturnValue
  @SuppressWarnings("ReferenceEquality") // unknownType is a singleton
  private FlowScope updateNamedParameter(
      Node paramName, boolean hasDefaultValue, JSType inferredType, FlowScope entryFlowScope) {
    TypedVar var = containerScope.getVar(paramName.getString());
    checkNotNull(var, "Missing var for parameter %s", paramName);

    paramName.setJSType(inferredType);

    if (var.isTypeInferred()) {
      var.setType(inferredType);
    } else if (hasDefaultValue) {
      // If this is a declared type with a default value, update the LinkedFlowScope slots but not
      // the actual TypedVar. This is similar to what would happen if the default value was moved
      // into an assignment in the fn body
      entryFlowScope = redeclareSimpleVar(entryFlowScope, paramName, inferredType);
    }
    return entryFlowScope;
  }
723849
function isDefined(value, message, id) {
    if (message === void 0) { message = ''; }
    if (id === void 0) { id = ''; }
    if (this.enabled && value === undefined) {
        throw TypeException.expectedType(assertionTypes.IS_DEFINED, value, '<undefined>', message, id);
    }
}
660506
private boolean customComparatorAvailable(Class<?> providerClass) {
        if (providerComparator != null) {
            Type type = ((ParameterizedType)providerComparator.getClass()
                .getGenericInterfaces()[0]).getActualTypeArguments()[0];
            if (type instanceof ParameterizedType) {
                ParameterizedType pt = (ParameterizedType)type;
                if (pt.getRawType() == ProviderInfo.class) {
                    Type type2 = pt.getActualTypeArguments()[0];
                    if (type2 == providerClass
                        || type2 instanceof WildcardType
                        || type2 instanceof ParameterizedType
                           && ((ParameterizedType)type2).getRawType() == providerClass) {
                        return true;
                    }
                }
            } else if (type == Object.class) {
                return true;
            }
        }
        return false;
    }
770460
function (observer) {
            var observers = this.observers, i;
            for (i = observers.length - 1; i >= 0; --i) {
                /*
             If multiple identical EventListeners are registered on the same EventTarget
             with the same parameters the duplicate instances are discarded.
             They do not cause the EventListener to be called twice
             and since they are discarded
             they do not need to be removed with the removeEventListener method.
             */
                if (observer.equals(observers[i])) {
                    return i;
                }
            }
            return -1;
        }
318803
function (types) {

    that.logger.logEnter('callback in loadEventTypes, types:\n' + JSON.stringify(types));

    // The "raw" event type data has a deeply-nested structure and it
    // contains a bunch of stuff we're not interested in.  We'll just
    // store the names of each type's properties.
    Object.keys(types).forEach(function (typeName) {
      if (types[typeName].properties) {
        eventTypes[typeName] = Object.keys(types[typeName].properties);
      }
    });

    that.logger.log('eventTypes:\n' + JSON.stringify(eventTypes));

    if (process.env.TESTONLY_EMIT_INTERNAL_EVENTS) {
      that.emit(that.CONSTANT.internal_event_load_types_done);
    }

    // Now the event buffer can begin processing events.
    eventBuffer.ready();

    that.logger.logExit('callback in loadEventTypes');
  }
108276
function(sortedInputEvents, protoIRs) {
      var handledEvents = [];
      protoIRs.forEach(function(protoIR) {
        protoIR.associatedEvents.forEach(function(event) {
          if (handledEvents.indexOf(event) >= 0) {
            console.error('double-handled event', event.typeName,
                parseInt(event.start), parseInt(event.end), protoIR);
            return;
          }
          handledEvents.push(event);
        });
      });

      sortedInputEvents.forEach(function(event) {
        if (handledEvents.indexOf(event) < 0) {
          console.error('UNHANDLED INPUT EVENT!',
              event.typeName, parseInt(event.start), parseInt(event.end));
        }
      });
    }
1277742
function(eventType, listener) {
    var i, len, foundIndex, events, perEventHandlers;
    if (arguments.length === 0) {
      events = _keys(_handlers);
    } else if (typeof eventType === "string" && eventType) {
      events = eventType.toLowerCase().split(/\s+/);
    } else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
      _keys(eventType).forEach(function(key) {
        var listener = eventType[key];
        if (typeof listener === "function") {
          ZeroClipboard.off(key, listener);
        }
      });
    }
    if (events && events.length) {
      for (i = 0, len = events.length; i < len; i++) {
        eventType = events[i].replace(/^on/, "");
        perEventHandlers = _handlers[eventType];
        if (perEventHandlers && perEventHandlers.length) {
          if (listener) {
            foundIndex = perEventHandlers.indexOf(listener);
            while (foundIndex !== -1) {
              perEventHandlers.splice(foundIndex, 1);
              foundIndex = perEventHandlers.indexOf(listener, foundIndex);
            }
          } else {
            perEventHandlers.length = 0;
          }
        }
      }
    }
    return ZeroClipboard;
  }
457322
private <Y> void checkObserverMethod(EnhancedAnnotatedMethod<T, Y> annotated) {
        // Make sure exactly one and only one parameter is annotated with Observes or ObservesAsync
        List<EnhancedAnnotatedParameter<?, Y>> eventObjects = annotated.getEnhancedParameters(Observes.class);
        eventObjects.addAll(annotated.getEnhancedParameters(ObservesAsync.class));
        if (this.reception.equals(Reception.IF_EXISTS) && declaringBean.getScope().equals(Dependent.class)) {
            throw EventLogger.LOG.invalidScopedConditionalObserver(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        if (eventObjects.size() > 1) {
            throw EventLogger.LOG.multipleEventParameters(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        EnhancedAnnotatedParameter<?, Y> eventParameter = eventObjects.iterator().next();
        checkRequiredTypeAnnotations(eventParameter);
        // Check for parameters annotated with @Disposes
        List<?> disposeParams = annotated.getEnhancedParameters(Disposes.class);
        if (disposeParams.size() > 0) {
            throw EventLogger.LOG.invalidDisposesParameter(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        // Check annotations on the method to make sure this is not a producer
        // method, initializer method, or destructor method.
        if (this.observerMethod.getAnnotated().isAnnotationPresent(Produces.class)) {
            throw EventLogger.LOG.invalidProducer(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        if (this.observerMethod.getAnnotated().isAnnotationPresent(Inject.class)) {
            throw EventLogger.LOG.invalidInitializer(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
        }
        boolean containerLifecycleObserverMethod = Observers.isContainerLifecycleObserverMethod(this);
        for (EnhancedAnnotatedParameter<?, ?> parameter : annotated.getEnhancedParameters()) {
            // if this is an observer method for container lifecycle event, it must not inject anything besides BeanManager
            if (containerLifecycleObserverMethod && !parameter.isAnnotationPresent(Observes.class) && !parameter.isAnnotationPresent(ObservesAsync.class) && !BeanManager.class.equals(parameter.getBaseType())) {
                throw EventLogger.LOG.invalidInjectionPoint(this, Formats.formatAsStackTraceElement(annotated.getJavaMember()));
            }
        }

    }
73274
public static boolean isParameterizedType(final Type type) {
        return type != null && type instanceof ParameterizedType && ((ParameterizedType) type).getActualTypeArguments().length > 0;
    }
1090409
@Override
    public RuntimeEventListener register(Controllable controllable, ControllableType type)
                    throws AlreadyRegisteredException, SIBExceptionInvalidValue {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "register", new Object[] { controllable, type });

        RuntimeEventListener retValue = null;
        if (type == ControllableType.QUEUE_POINT) {
            createQueueMBean(controllable);

        }
        else if (type == ControllableType.PUBLICATION_POINT) {
            createTopicMBean(controllable);
        }
        else if (type == ControllableType.SUBSCRIPTION_POINT) {
            createSubscriberMBean(controllable);
        }
        else
        {
            String reason = "Invalid ControllableType of " + type.toString();
            final SIBExceptionInvalidValue e =
                            new SIBExceptionInvalidValue(
                                            nls.getFormattedMessage("INTERNAL_ERROR_SIAS0003", new Object[] { reason }, reason));
            FFDCFilter.processException(e, CLASS_NAME + ".register", "PROBE_ID_10", this);
            SibTr.exception(tc, e);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "register", e);
            throw e;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "register", new Object[] { retValue });
        return retValue;
    }
11960
private void checkStrictParamType(
      final TemplateNode node, final TemplateParam param, @Nullable SoyValueProvider paramValue) {
    Kind kind = param.type().getKind();
    if (kind == Kind.ANY || kind == Kind.UNKNOWN) {
      // Nothing to check.  ANY and UKNOWN match all types.
      return;
    }
    if (paramValue == null) {
      paramValue = NullData.INSTANCE;
    } else if (paramValue instanceof SoyAbstractCachingValueProvider) {
      SoyAbstractCachingValueProvider typedValue = (SoyAbstractCachingValueProvider) paramValue;
      if (!typedValue.isComputed()) {
        // in order to preserve laziness we tell the value provider to assert the type when
        // computation is triggered
        typedValue.addValueAssertion(
            new ValueAssertion() {
              @Override
              public void check(SoyValue value) {
                checkValueType(param, value, node);
              }
            });
        return;
      }
    } else if (param.hasDefault() && paramValue.resolve() instanceof UndefinedData) {
      // Default parameters are undefined if they're unset.
      return;
    }
    checkValueType(param, paramValue.resolve(), node);
  }
244466
private void setEventType(short eventType) {
      if (eventType != ADDED && eventType != REMOVED && eventType != CHANGED) {
         throw new IllegalArgumentException("Invalid eventType code "
            + eventType);
      }

      this.eventType = eventType;
   }
863801
private static Class<?> getRawType(final ParameterizedType parameterizedType) {
        final Type rawType = parameterizedType.getRawType();

        // check if raw type is a Class object
        // not currently necessary, but since the return type is Type instead of
        // Class, there's enough reason to believe that future versions of Java
        // may return other Type implementations. And type-safety checking is
        // rarely a bad idea.
        if (!(rawType instanceof Class<?>)) {
            throw new IllegalStateException("Wait... What!? Type of rawType: " + rawType);
        }

        return (Class<?>) rawType;
    }
1174474
private static boolean isAssignableFrom(Type from, ParameterizedType to,
			Map<String, Type> typeVarMap) {

		if (from == null) {
			return false;
		}

		if (to.equals(from)) {
			return true;
		}

		// First figure out the class and any type information.
		Class<?> clazz = getRawType(from);
		ParameterizedType ptype = null;
		if (from instanceof ParameterizedType) {
			ptype = (ParameterizedType) from;
		}

		// Load up parameterized variable info if it was parameterized.
		if (ptype != null) {
			Type[] tArgs = ptype.getActualTypeArguments();
			TypeVariable<?>[] tParams = clazz.getTypeParameters();
			for (int i = 0; i < tArgs.length; i++) {
				Type arg = tArgs[i];
				TypeVariable<?> var = tParams[i];
				while (arg instanceof TypeVariable) {
					TypeVariable<?> v = (TypeVariable<?>) arg;
					arg = typeVarMap.get(v.getName());
				}
				typeVarMap.put(var.getName(), arg);
			}

			// check if they are equivalent under our current mapping.
			if (typeEquals(ptype, to, typeVarMap)) {
				return true;
			}
		}

		for (Type itype : clazz.getGenericInterfaces()) {
			if (isAssignableFrom(itype, to, new HashMap<String, Type>(
					typeVarMap))) {
				return true;
			}
		}

		// Interfaces didn't work, try the superclass.
		Type sType = clazz.getGenericSuperclass();
		if (isAssignableFrom(sType, to, new HashMap<String, Type>(typeVarMap))) {
			return true;
		}

		return false;
	}
1144005
private void processEventParameter(Expression expression, NameExpr nameExpr,
      List<VariableInfo> parameters) {
    Optional<Node> parentNode = nameExpr.getParentNode();
    if (parentNode.isPresent() && parentNode.get() instanceof CastExpr) {
      CastExpr castExpr = (CastExpr) parentNode.get();
      parameters.add(new VariableInfo(castExpr.getType().toString(), "$event"));
    } else {
      logger.error(
          "\"$event\" should always be casted to it's intended type. Example: @click=\"doSomething((Event) $event)\".",
          expression.toString());
    }
  }
896513
private Method findHandlerMethod(Object target, Class<? extends IEvents> eventsClass,
            String eventName, Object[] params) {
        // Use cached method if available. Note: no further type checking is done if the
        // method has been cached. It will be checked by JRE when the method is invoked.
        Method cachedMethod = getCachedMethod(target, eventName);
        if (cachedMethod != null) {
            return cachedMethod;
        }

        // Check the event and params against the eventsClass interface object.
        Method nameMatch = null;
        Method signatureMatch = null;
        for (Method method : eventsClass.getMethods()) {
            // Match method name and event name
            if (method.getName().equals(eventName)) {
                nameMatch = method;

                // Check number of parameters
                Class<?>[] types = method.getParameterTypes();
                if (types.length != params.length)
                    continue;

                // Check parameter types
                int i = 0;
                boolean foundMatchedMethod = true;
                for (Class<?> type : types) {
                    Object param = params[i++];
                    if (!isInstanceWithAutoboxing(type, param)) {
                        foundMatchedMethod = false;
                        break;
                    }
                }

                if (foundMatchedMethod) {
                    signatureMatch = method;
                    break;
                }
            }
        }

        // Error
        if (nameMatch == null) {
            throw new RuntimeException(String.format("The interface contains no method %s", eventName));
        } else if (signatureMatch == null ){
            throw new RuntimeException(String.format("The interface contains a method %s but "
                    + "parameters don't match", eventName));
        }

        // Cache the method for the target, even if it doesn't implement the interface. This is
        // to avoid always verifying the event.
        addCachedMethod(target, eventName, signatureMatch);

        return signatureMatch;
    }