Class ReceiverTck
java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.ReceiverTck
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classjavac's class of both.static classConstructor overload oracle.static classOverloads inherited by a generated class.static classjavac's calls on this and super.static classInstance overload oracle.static interfaceA default method.static classRaw inheritance oracle.static interfaceA generated interface stand-in.static classReceiverTck.MethodBounds<X extends Number>A method bound refers to the receiver's type argument.static classA raw use erases this type's entire superclass.static classOwn method variables of a raw class.static classRaw receivers erase instance member types.static classInherited generic overloads.static classReceiverTck.ReceiverBound<T extends CharSequence>Method bound depends on the receiver.static interfaceA default method of the same name.static classA method variable shadows a receiver variable.static classA superclass declaring a static method, called throughsuper.static classA specialized receiver. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidvoidconstructorsResolveLexicalTypeVariables(String scope, String declaration) A constructor argument typed by a type variable resolves the constructor with the bound the variable has where it is declared.voidvoidexternalBoundChainsRemainInTheCalleeScope(String scope, int length) Long bound chains are also exercised when passing an external generated method's arguments.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidoverloadArgumentsRetainTheirLexicalBounds(String scope, String declaration) Overload lookup must interpret name-only variables in the enclosing declaration.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvariableReceiversResolveOverloadsByName(String scope, String declaration) A call by name on a receiver typed by a type variable resolves the overloads of the variable's bound.voidMethods inherited from class AbstractByteCodeWriterTck
assertCall, caller, callWithParameter, classShape, declaredFields, declaredMethods, define, defineInPackage, genericShape, invoke, list, load, outcome, run, run, run, selection, selection, shape, write
-
Constructor Details
-
ReceiverTck
public ReceiverTck()
-
-
Method Details
-
invokesMethodsThroughInterfaceBoundTypeVariables
-
writesDefaultMethodCallsOnAnInterfaceReceiverWithInvokeInterface
-
invokesInterfaceBoundClassVariable
-
invokesInlineInterfaceBoundVariable
-
invokesGenericCalleeInItsOwnClassScope
-
generatedReceiverResolvesInheritedMethod
-
invokesMethodDeclaredOnSecondaryIntersectionBound
-
readsGenericFieldInItsDeclaringClassScope
-
inheritedGenericMemberKeepsItsDeclaringClassBound
-
inheritedGenericFieldKeepsItsDeclaringClassBound
-
methodVariableShadowsParameterizedReceiverVariable
-
inheritedReceiverArgumentsParticipateInOverloads
-
unboundedCalleeVariableDoesNotCaptureCallerBound
-
calleeClassBoundChainDoesNotCaptureMethodShadow
-
overloadedChildDoesNotHideDeclaringScopeOfInheritedMethod
-
receiverBoundChainRetainsClassScope
-
longCalleeBoundChainResolvesWithoutArbitraryDepthLimit
-
generatedInheritedReceiverBindsSuperclassVariable
-
methodBoundUsesReceiverSubstitution
-
instantiatingGenericConstructorRetainsMethodBounds
-
newInstanceArgumentsUseConstructedClassScope
-
superConstructorArgumentsUseSuperclassScope
-
generatedSecondaryReceiverBoundIncludesInheritedMethods
-
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 methoddeclaration- 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 methodlength- The number of variables in the chain- Throws:
Exception- If the generated program cannot be loaded or invoked
-
rawReceiverErasesGenericParameterApplicability
-
annotatedReceiverRetainsItsOverloadInformation
-
rawGenericReceiverStillSelectsNumericMethod
-
rawBoundedReceiverKeepsTheErasedClassBound
-
annotatedReceiverSupportsAnExplicitMethodDescriptor
-
annotatedInterfaceReceiverUsesInvokeinterface
-
rawSubclassErasesItsParameterizedSuperclass
-
parameterizedSubclassKeepsItsSuperclassArguments
-
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 methoddeclaration- 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 methoddeclaration- 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
-
interfaceBoundCanInvokeObjectMethods
-
methodsOfAPackagePrivateSuperclassAreInvokedOnThePublicReceiver
-
staticMethodsOfInterfacesAreInvokedByName
-
callByNameOnThisResolvesAnInheritedOverload
-
callByNameOnSuperResolvesAnInheritedOverload
-
staticMethodCalledOnSuperIsInvokedStatically
-
cloneOfAnArrayReceiverIsTypedAsTheArray
-
equalsOfAnArrayReceiverTakesAnObject
-
staticMethodCalledOnAnInstanceIsInvokedStatically
-
objectMethodOfAnInterfaceReceiverTakesAnObject
-
objectMethodOfAGeneratedInterfaceReceiverTakesAnObject
-
superCallByNameToADefaultMethodOfOneOfTwoInterfaces
-