Class OverloadSelectionTck

java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.OverloadSelectionTck

public abstract class OverloadSelectionTck extends AbstractByteCodeWriterTck
Overload selection: the phases of strict, loose and variable arity invocation, the most specific method, accessibility of candidates and explicit descriptors. Each generated call must choose the overload javac chooses for the same call on a compiled fixture.

A backend runs these tests by extending this class and implementing AbstractByteCodeWriterTck.write(io.micronaut.sourcegen.model.ObjectDef).

Since:
2.3
  • Constructor Details

    • OverloadSelectionTck

      public OverloadSelectionTck()
  • Method Details

    • reflectedOverloadCallChoosesJavacsOverload

      @ParameterizedTest(name="{0}") @MethodSource("reflectedOverloadCalls") public void reflectedOverloadCallChoosesJavacsOverload(String method, ExpressionDef argument, String expected) throws Exception
      A call by name of a reflected overloaded method chooses the overload javac chooses for the same argument.
      Parameters:
      method - The overloaded method of OverloadSelectionTck.Overloads
      argument - The argument of the call
      expected - The overload javac chooses, as the value it returns
      Throws:
      Exception - If the generated call cannot be loaded or invoked
    • explicitDescriptorSelectsRequestedOverload

      @Test public void explicitDescriptorSelectsRequestedOverload() throws Exception
      Throws:
      Exception
    • choosesMostSpecificConstructor

      @Test public void choosesMostSpecificConstructor() throws Exception
      Throws:
      Exception
    • generatedOverloadChoosesMostSpecificSupertype

      @Test public void generatedOverloadChoosesMostSpecificSupertype() throws Exception
      Throws:
      Exception
    • generatedOverloadChoosesPrimitiveWidening

      @Test public void generatedOverloadChoosesPrimitiveWidening() throws Exception
      Throws:
      Exception
    • parameterizedReceiverParticipatesInOverloadSelection

      @Test public void parameterizedReceiverParticipatesInOverloadSelection() throws Exception
      Throws:
      Exception
    • genericIntersectionConstrainsOverloadApplicability

      @Test public void genericIntersectionConstrainsOverloadApplicability() throws Exception
      Throws:
      Exception
    • parameterizedArgumentsConstrainOverloadApplicability

      @Test public void parameterizedArgumentsConstrainOverloadApplicability() throws Exception
      Throws:
      Exception
    • inaccessibleMethodIsNotAnOverloadCandidate

      @Test public void inaccessibleMethodIsNotAnOverloadCandidate() throws Exception
      Throws:
      Exception
    • secondaryBoundOverloadsUseTheFullDescriptor

      @Test public void secondaryBoundOverloadsUseTheFullDescriptor() throws Exception
      Throws:
      Exception
    • generatedConstructorChoosesMostSpecificSupertype

      @Test public void generatedConstructorChoosesMostSpecificSupertype() throws Exception
      Throws:
      Exception
    • inaccessibleConstructorIsNotAnOverloadCandidate

      @Test public void inaccessibleConstructorIsNotAnOverloadCandidate() throws Exception
      Throws:
      Exception
    • reflectedVarargsChooseMostSpecificWithNoArguments

      @Test public void reflectedVarargsChooseMostSpecificWithNoArguments() throws Exception
      Throws:
      Exception
    • reflectedVarargsPackPrimitiveArguments

      @Test public void reflectedVarargsPackPrimitiveArguments() throws Exception
      Throws:
      Exception
    • fixedArrayMethodReceivesNullWithoutPacking

      @Test public void fixedArrayMethodReceivesNullWithoutPacking() throws Exception
      Throws:
      Exception
    • reflectedOverloadAcceptsCovariantArrays

      @Test public void reflectedOverloadAcceptsCovariantArrays() throws Exception
      Throws:
      Exception
    • typedNullUsesItsDeclaredTypeForOverloadSelection

      @Test public void typedNullUsesItsDeclaredTypeForOverloadSelection() throws Exception
      Throws:
      Exception
    • generatedPrivateOverloadIsNotCallableFromAnotherClass

      @Test public void generatedPrivateOverloadIsNotCallableFromAnotherClass() throws Exception
      Throws:
      Exception
    • intersectionReceiverChoosesMatchingReturnDescriptor

      @Test public void intersectionReceiverChoosesMatchingReturnDescriptor() throws Exception
      Throws:
      Exception
    • generatedPrivateConstructorIsNotCallableFromAnotherClass

      @Test public void generatedPrivateConstructorIsNotCallableFromAnotherClass() throws Exception
      Throws:
      Exception
    • generatedBoundedOverloadRetainsCalleeVariables

      @Test public void generatedBoundedOverloadRetainsCalleeVariables() throws Exception
      Throws:
      Exception
    • primitiveWideningAndBoxingRemainOrdered

      @Test public void primitiveWideningAndBoxingRemainOrdered() throws Exception
      Throws:
      Exception
    • packagePrivateReflectedOverloadIsNotAccessible

      @Test public void packagePrivateReflectedOverloadIsNotAccessible() throws Exception
      Throws:
      Exception
    • protectedReflectedOverloadIsNotAccessible

      @Test public void protectedReflectedOverloadIsNotAccessible() throws Exception
      Throws:
      Exception
    • packagePrivateOverloadAmbiguousWithAnAccessibleOneIsNotAccessible

      @Test public void packagePrivateOverloadAmbiguousWithAnAccessibleOneIsNotAccessible() throws Exception
      Throws:
      Exception
    • packagePrivateConstructorIsNotAccessibleToASuperCall

      @Test public void packagePrivateConstructorIsNotAccessibleToASuperCall() throws Exception
      Throws:
      Exception
    • protectedConstructorIsAccessibleToASuperCall

      @Test public void protectedConstructorIsAccessibleToASuperCall() throws Exception
      Throws:
      Exception
    • packagePrivateConstructorIsNotAccessible

      @Test public void packagePrivateConstructorIsNotAccessible() throws Exception
      Throws:
      Exception
    • protectedConstructorIsNotAccessible

      @Test public void protectedConstructorIsNotAccessible() throws Exception
      Throws:
      Exception
    • concreteOverloadOutranksAWiderReceiverInstantiation

      @Test public void concreteOverloadOutranksAWiderReceiverInstantiation() throws Exception
      Throws:
      Exception
    • requestedGenericReturnKeepsTheMostSpecificOverload

      @Test public void requestedGenericReturnKeepsTheMostSpecificOverload() throws Exception
      Throws:
      Exception
    • parameterizedClassArgumentsChooseTheGenericConstructorOverload

      @Test public void parameterizedClassArgumentsChooseTheGenericConstructorOverload() throws Exception
      Throws:
      Exception
    • inheritedGenericOverloadDoesNotHideTheSpecializedDeclaration

      @Test public void inheritedGenericOverloadDoesNotHideTheSpecializedDeclaration() throws Exception
      Throws:
      Exception
    • generatedInterfaceMethodsParticipateInOverloads

      @Test public void generatedInterfaceMethodsParticipateInOverloads() throws Exception
      Throws:
      Exception
    • generatedDependentBoundsDoNotCollapseOverloadDescriptors

      @ParameterizedTest(name="with the {0} overload declared first, the dependent bound keeps its own descriptor") @ValueSource(strings={"bounded","object"}) public void generatedDependentBoundsDoNotCollapseOverloadDescriptors(String order) throws Exception
      Generic overloads in generated definitions are distinguished by the complete bound chain. Both declaration orders are checked, to detect accidental first-candidate selection.
      Parameters:
      order - Which overload the generated class declares first
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • boundedArgumentCanSelectAnOverloadOnItsSecondaryBound

      @Test public void boundedArgumentCanSelectAnOverloadOnItsSecondaryBound() throws Exception
      Throws:
      Exception
    • generatedMethodOverloadsHaveDistinctBoundedDescriptors

      @Test public void generatedMethodOverloadsHaveDistinctBoundedDescriptors() throws Exception
      Throws:
      Exception
    • generatedClassOverloadsHaveDistinctBoundedDescriptors

      @Test public void generatedClassOverloadsHaveDistinctBoundedDescriptors() throws Exception
      Throws:
      Exception
    • mostSpecificMethodResolvesDependentVariableBounds

      @Test public void mostSpecificMethodResolvesDependentVariableBounds() throws Exception
      Throws:
      Exception
    • generatedOverloadsKeepLongDependentBounds

      @ParameterizedTest(name="an overload bounded through a chain of {0} variables is more specific than Object") @ValueSource(ints={4,8,16,32}) public void generatedOverloadsKeepLongDependentBounds(int length) throws Exception
      A generated overload whose parameter is bounded through a long chain of dependent variables stays more specific than an overload taking Object.
      Parameters:
      length - The number of variables in the chain
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • unrelatedGenericMethodDoesNotMakeSpecificOverloadAmbiguous

      @Test public void unrelatedGenericMethodDoesNotMakeSpecificOverloadAmbiguous() throws Exception
      Throws:
      Exception
    • inheritedCovariantInterfaceMethodsAreOneOverload

      @Test public void inheritedCovariantInterfaceMethodsAreOneOverload() throws Exception
      Throws:
      Exception
    • secondaryMethodBoundConstrainsMostSpecificOverload

      @Test public void secondaryMethodBoundConstrainsMostSpecificOverload() throws Exception
      Throws:
      Exception
    • differentVarargsAritiesChooseTheMostSpecificElement

      @Test public void differentVarargsAritiesChooseTheMostSpecificElement() throws Exception
      Throws:
      Exception
    • primitiveArgumentChoosesJavacsOverload

      @ParameterizedTest(name="{0}") @MethodSource("primitiveArgumentCalls") public void primitiveArgumentChoosesJavacsOverload(String method, TypeDef type, Object argument, Object expected) throws Exception
      A single primitive or boxed argument converts to the parameter of the overload javac chooses: primitive widening in the strict phase, and unboxing followed by widening in the loose phase.
      Parameters:
      method - The overloaded method of OverloadFixtures.Calls
      type - The type of the argument
      argument - The argument
      expected - javac's own call of the same overload with the same argument
      Throws:
      Exception - If the generated call cannot be loaded or invoked
    • nullPrefersCharArrayOverObject

      @Test public void nullPrefersCharArrayOverObject() throws Exception
      Throws:
      Exception
    • variableArityCallChoosesJavacsOverload

      @ParameterizedTest(name="{0}") @MethodSource("variableArityCalls") public void variableArityCallChoosesJavacsOverload(String method, List<TypeDef> types, List<?> arguments, Object expected) throws Exception
      A variable arity call chooses the overload javac chooses and packs, widens or boxes its elements as javac does, while an array argument is passed as the array itself by strict invocation.
      Parameters:
      method - The overloaded method of OverloadFixtures.Calls
      types - The types of the arguments
      arguments - The arguments
      expected - javac's own call of the same overload with the same arguments
      Throws:
      Exception - If the generated call cannot be loaded or invoked
    • nonGenericOverloadIsMoreSpecificThanAGenericOne

      @Test public void nonGenericOverloadIsMoreSpecificThanAGenericOne() throws Exception
      Throws:
      Exception
    • protectedOverloadIsMoreSpecificFromASubclass

      @Test public void protectedOverloadIsMoreSpecificFromASubclass() throws Exception
      Throws:
      Exception
    • packagePrivateOverloadIsMoreSpecificFromTheSamePackage

      @Test public void packagePrivateOverloadIsMoreSpecificFromTheSamePackage() throws Exception
      Throws:
      Exception
    • protectedOverloadIsMoreSpecificThroughAReceiverOfTheSubclass

      @Test public void protectedOverloadIsMoreSpecificThroughAReceiverOfTheSubclass() throws Exception
      Throws:
      Exception
    • genuinelyAmbiguousCallIsRejected

      @Test public void genuinelyAmbiguousCallIsRejected()
    • intersectionReceiverChoosesTheMostSpecificOverloadOfAnyBound

      @Test public void intersectionReceiverChoosesTheMostSpecificOverloadOfAnyBound() throws Exception
      Throws:
      Exception
    • intersectionReceiverSkipsAnInapplicableFirstBound

      @Test public void intersectionReceiverSkipsAnInapplicableFirstBound() throws Exception
      Throws:
      Exception
    • overloadsOfASuperclassAndAnInterfaceCompete

      @Test public void overloadsOfASuperclassAndAnInterfaceCompete() throws Exception
      Throws:
      Exception