Class ReceiverTck


public abstract class ReceiverTck extends AbstractByteCodeWriterTck
Calls through a receiver: type variable, raw, parameterized, intersection and interface receivers, and the class scope in which a callee's type variables and inherited members are resolved.

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

Since:
2.3
  • Constructor Details

    • ReceiverTck

      public ReceiverTck()
  • Method Details

    • invokesMethodsThroughInterfaceBoundTypeVariables

      @Test public void invokesMethodsThroughInterfaceBoundTypeVariables() throws Exception
      Throws:
      Exception
    • writesDefaultMethodCallsOnAnInterfaceReceiverWithInvokeInterface

      @Test public void writesDefaultMethodCallsOnAnInterfaceReceiverWithInvokeInterface() throws Exception
      Throws:
      Exception
    • invokesInterfaceBoundClassVariable

      @Test public void invokesInterfaceBoundClassVariable() throws Exception
      Throws:
      Exception
    • invokesInlineInterfaceBoundVariable

      @Test public void invokesInlineInterfaceBoundVariable() throws Exception
      Throws:
      Exception
    • invokesGenericCalleeInItsOwnClassScope

      @Test public void invokesGenericCalleeInItsOwnClassScope() throws Exception
      Throws:
      Exception
    • generatedReceiverResolvesInheritedMethod

      @Test public void generatedReceiverResolvesInheritedMethod() throws Exception
      Throws:
      Exception
    • invokesMethodDeclaredOnSecondaryIntersectionBound

      @Test public void invokesMethodDeclaredOnSecondaryIntersectionBound() throws Exception
      Throws:
      Exception
    • readsGenericFieldInItsDeclaringClassScope

      @Test public void readsGenericFieldInItsDeclaringClassScope() throws Exception
      Throws:
      Exception
    • inheritedGenericMemberKeepsItsDeclaringClassBound

      @Test public void inheritedGenericMemberKeepsItsDeclaringClassBound() throws Exception
      Throws:
      Exception
    • inheritedGenericFieldKeepsItsDeclaringClassBound

      @Test public void inheritedGenericFieldKeepsItsDeclaringClassBound() throws Exception
      Throws:
      Exception
    • methodVariableShadowsParameterizedReceiverVariable

      @Test public void methodVariableShadowsParameterizedReceiverVariable() throws Exception
      Throws:
      Exception
    • inheritedReceiverArgumentsParticipateInOverloads

      @Test public void inheritedReceiverArgumentsParticipateInOverloads() throws Exception
      Throws:
      Exception
    • unboundedCalleeVariableDoesNotCaptureCallerBound

      @Test public void unboundedCalleeVariableDoesNotCaptureCallerBound() throws Exception
      Throws:
      Exception
    • calleeClassBoundChainDoesNotCaptureMethodShadow

      @Test public void calleeClassBoundChainDoesNotCaptureMethodShadow() throws Exception
      Throws:
      Exception
    • overloadedChildDoesNotHideDeclaringScopeOfInheritedMethod

      @Test public void overloadedChildDoesNotHideDeclaringScopeOfInheritedMethod() throws Exception
      Throws:
      Exception
    • receiverBoundChainRetainsClassScope

      @Test public void receiverBoundChainRetainsClassScope() throws Exception
      Throws:
      Exception
    • longCalleeBoundChainResolvesWithoutArbitraryDepthLimit

      @Test public void longCalleeBoundChainResolvesWithoutArbitraryDepthLimit() throws Exception
      Throws:
      Exception
    • generatedInheritedReceiverBindsSuperclassVariable

      @Test public void generatedInheritedReceiverBindsSuperclassVariable() throws Exception
      Throws:
      Exception
    • methodBoundUsesReceiverSubstitution

      @Test public void methodBoundUsesReceiverSubstitution() throws Exception
      Throws:
      Exception
    • instantiatingGenericConstructorRetainsMethodBounds

      @Test public void instantiatingGenericConstructorRetainsMethodBounds() throws Exception
      Throws:
      Exception
    • newInstanceArgumentsUseConstructedClassScope

      @Test public void newInstanceArgumentsUseConstructedClassScope() throws Exception
      Throws:
      Exception
    • superConstructorArgumentsUseSuperclassScope

      @Test public void superConstructorArgumentsUseSuperclassScope() throws Exception
      Throws:
      Exception
    • generatedSecondaryReceiverBoundIncludesInheritedMethods

      @Test public void generatedSecondaryReceiverBoundIncludesInheritedMethods() throws Exception
      Throws:
      Exception
    • overloadArgumentsRetainTheirLexicalBounds

      @ParameterizedTest(name="an argument of a {0} variable written {1} keeps its bound for overload selection") @CsvSource({"class, named","class, inline","method, named","method, inline"}) public void overloadArgumentsRetainTheirLexicalBounds(String scope, String declaration) throws Exception
      Overload lookup must interpret name-only variables in the enclosing declaration.
      Parameters:
      scope - Whether the argument's variable is declared by the class or by the method
      declaration - How the argument's type variable is written: by name or inline with its bound
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • externalBoundChainsRemainInTheCalleeScope

      @ParameterizedTest(name="a {0} chain of {1} bounds stays in the callee's scope") @CsvSource({"class, 2","class, 5","class, 10","class, 20","method, 2","method, 5","method, 10","method, 20"}) public void externalBoundChainsRemainInTheCalleeScope(String scope, int length) throws Exception
      Long bound chains are also exercised when passing an external generated method's arguments.
      Parameters:
      scope - Whether the chain is declared by the callee's class or by its method
      length - The number of variables in the chain
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • rawReceiverErasesGenericParameterApplicability

      @Test public void rawReceiverErasesGenericParameterApplicability() throws Exception
      Throws:
      Exception
    • annotatedReceiverRetainsItsOverloadInformation

      @Test public void annotatedReceiverRetainsItsOverloadInformation() throws Exception
      Throws:
      Exception
    • rawGenericReceiverStillSelectsNumericMethod

      @Test public void rawGenericReceiverStillSelectsNumericMethod() throws Exception
      Throws:
      Exception
    • rawBoundedReceiverKeepsTheErasedClassBound

      @Test public void rawBoundedReceiverKeepsTheErasedClassBound() throws Exception
      Throws:
      Exception
    • annotatedReceiverSupportsAnExplicitMethodDescriptor

      @Test public void annotatedReceiverSupportsAnExplicitMethodDescriptor() throws Exception
      Throws:
      Exception
    • annotatedInterfaceReceiverUsesInvokeinterface

      @Test public void annotatedInterfaceReceiverUsesInvokeinterface() throws Exception
      Throws:
      Exception
    • rawSubclassErasesItsParameterizedSuperclass

      @Test public void rawSubclassErasesItsParameterizedSuperclass() throws Exception
      Throws:
      Exception
    • parameterizedSubclassKeepsItsSuperclassArguments

      @Test public void parameterizedSubclassKeepsItsSuperclassArguments() throws Exception
      Throws:
      Exception
    • constructorsResolveLexicalTypeVariables

      @ParameterizedTest(name="a constructor argument of a {0} variable written {1} chooses javac's constructor") @CsvSource({"class, named","class, inline","method, named","method, inline"}) public void constructorsResolveLexicalTypeVariables(String scope, String declaration) throws Exception
      A constructor argument typed by a type variable resolves the constructor with the bound the variable has where it is declared.
      Parameters:
      scope - Whether the argument's variable is declared by the class or by the method
      declaration - How the argument's type variable is written: by name or inline with its bound
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • variableReceiversResolveOverloadsByName

      @ParameterizedTest(name="a receiver of a {0} variable written {1} chooses javac's overload") @CsvSource({"class, named","class, inline","method, named","method, inline"}) public void variableReceiversResolveOverloadsByName(String scope, String declaration) throws Exception
      A call by name on a receiver typed by a type variable resolves the overloads of the variable's bound.
      Parameters:
      scope - Whether the receiver's variable is declared by the class or by the method
      declaration - How the receiver's type variable is written: by name or inline with its bound
      Throws:
      Exception - If the generated program cannot be loaded or invoked
    • genericMethodBoundsUseTheWholeParameterizedReceiver

      @Test public void genericMethodBoundsUseTheWholeParameterizedReceiver() throws Exception
      Throws:
      Exception
    • interfaceBoundCanInvokeObjectMethods

      @Test public void interfaceBoundCanInvokeObjectMethods() throws Exception
      Throws:
      Exception
    • methodsOfAPackagePrivateSuperclassAreInvokedOnThePublicReceiver

      @Test public void methodsOfAPackagePrivateSuperclassAreInvokedOnThePublicReceiver() throws Exception
      Throws:
      Exception
    • staticMethodsOfInterfacesAreInvokedByName

      @Test public void staticMethodsOfInterfacesAreInvokedByName() throws Exception
      Throws:
      Exception
    • callByNameOnThisResolvesAnInheritedOverload

      @Test public void callByNameOnThisResolvesAnInheritedOverload() throws Exception
      Throws:
      Exception
    • callByNameOnSuperResolvesAnInheritedOverload

      @Test public void callByNameOnSuperResolvesAnInheritedOverload() throws Exception
      Throws:
      Exception
    • staticMethodCalledOnSuperIsInvokedStatically

      @Test public void staticMethodCalledOnSuperIsInvokedStatically() throws Exception
      Throws:
      Exception
    • cloneOfAnArrayReceiverIsTypedAsTheArray

      @Test public void cloneOfAnArrayReceiverIsTypedAsTheArray() throws Exception
      Throws:
      Exception
    • equalsOfAnArrayReceiverTakesAnObject

      @Test public void equalsOfAnArrayReceiverTakesAnObject() throws Exception
      Throws:
      Exception
    • staticMethodCalledOnAnInstanceIsInvokedStatically

      @Test public void staticMethodCalledOnAnInstanceIsInvokedStatically() throws Exception
      Throws:
      Exception
    • objectMethodOfAnInterfaceReceiverTakesAnObject

      @Test public void objectMethodOfAnInterfaceReceiverTakesAnObject() throws Exception
      Throws:
      Exception
    • objectMethodOfAGeneratedInterfaceReceiverTakesAnObject

      @Test public void objectMethodOfAGeneratedInterfaceReceiverTakesAnObject() throws Exception
      Throws:
      Exception
    • superCallByNameToADefaultMethodOfOneOfTwoInterfaces

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