Class InferenceTck
java.lang.Object
io.micronaut.sourcegen.bytecode.tck.AbstractByteCodeWriterTck
io.micronaut.sourcegen.bytecode.tck.InferenceTck
Inference of method type arguments: wildcard capture and containment, bound checks, least upper bounds,
generic variable arity calls and the requested return type. Each generated call must behave as javac's
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplements the markers in declaration order.static classImplements the markers in declaration order.static classA common varargs superclass.static classVarargs whose component belongs to the class.static classConstructor overload oracle.static classInferenceTck.ConsumerBox<T extends Number>Capture conversion oracle.static classA varargs input.static classGeneric receiver whose erased result differs from its parameterized result.static classGeneric receiver with a method variable bounded by its class variable.static classGeneric variable arity inference.static interfaceMarker of a higher rank.static classInferenceTck.Receiver<T extends CharSequence>Wildcard receiver oracle.static classInferenceTck.ReceiverMethodVarargs<T extends Number>A varargs method whose variable is bounded by its generic receiver.static classSecond unrelated implementation.static classAnother varargs input.static classInherited specialization of class varargs.static interfaceMarker.static classConstructor inference oracle.static classA class with a distinct Comparable argument.static classImplements the markers in declaration order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidchainedBoundsKeepTheirRuntimeIdentity(int length) A call through a chain of type variables, each bounded by the next, returns the value it is given.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidVerifies an erased invocation preserves arrays whose elements have intersection bounds.voidA bounded generic call returns the very array it is given, whatever the rank of the array.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidVerifies array invocation preserves the caller's generic arguments across scopes.voidvoidvoidvoidvoidvoidvoidlexicalVarargsKeepTheInferredArrayType(String declaration) A variable arity call whose argument is typed by a method type variable, named or declared inline, packs the array javac infers for it.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidVerifies null remains a valid value for a nullable array with intersection-bounded elements.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidAn unbounded wildcard of a class that declares its parameter with a bound is captured with that bound: aBoundedBoxFixtures.NumberBox<?>holds Numbers, so<T extends Number> boxed(BoundedBoxFixtures.NumberBox<T>)applies and is more specific thanboxed(Object).voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidMethods 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
-
InferenceTck
public InferenceTck()
-
-
Method Details
-
genericArrayCallsPreserveValuesAcrossRanks
@ParameterizedTest(name="an array of rank {0} keeps its identity through a bounded generic call") @ValueSource(ints={1,2,3}) public void genericArrayCallsPreserveValuesAcrossRanks(int rank) throws Exception A bounded generic call returns the very array it is given, whatever the rank of the array.- Parameters:
rank- The rank of the array- Throws:
Exception- If the generated program cannot be loaded or invoked- Since:
- 2.3
-
chainedBoundsKeepTheirRuntimeIdentity
@ParameterizedTest(name="a chain of {0} dependent bounds returns the value it is given") @ValueSource(ints={1,2,8,9}) public void chainedBoundsKeepTheirRuntimeIdentity(int length) throws Exception A call through a chain of type variables, each bounded by the next, returns the value it is given.- Parameters:
length- The number of variables in the chain- Throws:
Exception- If the generated program cannot be loaded or invoked- Since:
- 2.3
-
genericArrayCallsPreserveIntersectionBoundValues
-
intersectionArraysPreserveCallerTypeArguments
-
nullableIntersectionArraysPreserveNull
-
genericVarargsInferTheRuntimeComponentType
-
upperWildcardConstrainsApplicability
-
lowerWildcardConstrainsApplicability
-
recursiveBoundConstrainsItsTypeArgument
-
repeatedMethodVariableUnifiesAcrossArguments
-
dependentMethodBoundIsResolvedBeforeApplicability
-
genericVarargsKeepNullElementInference
-
genericVarargsComputeCommonSuperclass
-
genericVarargsInferenceIncludesFixedParameters
-
primitiveArrayIsPackedAsOneSerializableVararg
-
constructorWildcardConstrainsApplicability
-
multiDimensionalGenericVarargsInferComponentRank
-
admissibleWildcardsStillSelectTheSpecificOverload
-
capturedUpperWildcardDoesNotAcceptAnArbitrarySubtypeOfItsBound
-
independentWildcardCapturesCannotBeEquated
-
wildcardUpperAndLowerConstraintsMustAgree
-
compatibleWildcardTransferStillSelectsGenericOverload
-
lowerWildcardCaptureAcceptsValuesWithinItsLowerBound
-
wildcardReceiverDoesNotAcceptValuesOfItsUpperBound
-
compatibleRecursiveBoundsStillSelectGenericOverload
-
nestedLowerWildcardConstrainsItsTypeArgument
-
compatibleNestedLowerWildcardStillSelectsGenericOverload
-
genericVarargsRespectAllBoundsWhenChoosingTheArrayComponent
-
genericArrayInferencePreservesDifferentRanks
-
methodBoundToAnotherVariableRetainsItsParameterErasure
-
genericConstructorUsesTheSameCaptureRulesAsMethods
-
parameterizedReceiverSpecializesTheRequestedReturnType
-
genericMethodSpecializesTheRequestedReturnType
-
classAndMethodVariablesSpecializeTheRequestedReturnType
-
targetTypeSelectsAGenericMethodWithNoArguments
-
explicitInstanceMethodReturningTheSpecializedTypeInvokesTheDeclaration
-
explicitStaticMethodReturningTheTargetTypeInvokesTheDeclaration
-
nestedWildcardInferencePropagatesTheCapturedUpperBound
-
upperOnlyInferenceConstraintsMustSatisfyTheDeclaredBound
-
incompatibleUpperOnlyInferenceConstraintsExcludeAnOverload
-
nestedGenericArraysInferTheRemainingDimensions
-
emptyVarargsUseTheMethodBoundSpecializedByTheReceiver
-
nonemptyVarargsUseTheMethodBoundSpecializedByTheReceiver
-
lowerWildcardContributesAnUpperInferenceConstraint
-
compatibleLowerWildcardStillSelectsGenericOverload
-
nestedWildcardPropagatesItsTypeArgumentConstraint
-
invariantGenericArrayArgumentsConstrainInference
-
wildcardArgumentIsContainedByAnotherUpperWildcard
-
wildcardArgumentIsContainedByAnotherLowerWildcard
-
dependentVariableBoundsPropagateLowerConstraints
-
boundedVarargsInferACommonInterfaceArray
-
unboundedVarargsInferACommonInterfaceArray
-
varargsInferencePreservesArrayLeastUpperBound
-
genericVarargsUseParameterizedReceiverComponent
-
emptyGenericVarargsUseParameterizedReceiverComponent
-
inheritedGenericVarargsUseSpecializedReceiverComponent
-
genericVarargsWithOneArrayUsesFixedArity
-
unboundedWildcardRemainsApplicable
-
invariantGenericArrayArgumentCanInferItsComponent
-
wildcardCaptureRespectsMethodVariableBounds
-
genericArrayTypeArgumentsRemainInvariant
-
primitiveMultidimensionalArraysRetainTheirLeastUpperBoundRank
-
lowerWildcardCaptureAllowsBoxing
-
lexicalVarargsKeepTheInferredArrayType
@ParameterizedTest(name="an argument of a method variable written {0} packs the inferred array") @ValueSource(strings={"named","inline"}) public void lexicalVarargsKeepTheInferredArrayType(String declaration) throws Exception A variable arity call whose argument is typed by a method type variable, named or declared inline, packs the array javac infers for it.- Parameters:
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
-
lowerWildcardStillContributesItsObjectUpperBound
-
upperWildcardWithNumericBoundRemainsApplicable
-
upperOnlyConstraintsRejectIncompatibleGenericBounds
-
upperOnlyConstraintsAcceptCompatibleGenericBounds
-
upperOnlyConstraintsRejectConflictingInterfaceArguments
-
nestedGenericEqualityChecksRawTypes
-
methodInferenceUsesTheCallerVariablesBounds
-
wildcardArgumentUsesTheCallerVariablesBounds
-
genericInferenceAcceptsRecursiveWildcardBound
-
genericInferenceRejectsRecursiveWildcardBound
-
leastUpperBoundOfIntegerAndStringIsSerializable
-
leastUpperBoundOrdersInterfacesByName
-
leastUpperBoundOrdersInterfacesByRank
-
arrayArgumentsInferAnArrayComponent
-
primitiveArrayArgumentIsOneElement
-
collectionsMaxErasesToObjectAndIsTypedAsRequested
-
collectionsMaxOfARecursiveBoundThroughASuperinterface
-
enumSetOfPacksTheVariableArityTail
-
streamCollectResolvesTheCollectorOverload
-
leastUpperBoundOfIntegerAndDoubleIsNumber
-
recursiveBoundAcceptsASubclassOfAComparable
-
recursiveBoundAcceptsAClassComparableThroughASuperinterface
-
unboundedWildcardIsCapturedWithTheDeclaredBound
-
unboundedWildcardOfABoundedClassSelectsTheGenericOverload
An unbounded wildcard of a class that declares its parameter with a bound is captured with that bound: aBoundedBoxFixtures.NumberBox<?>holds Numbers, so<T extends Number> boxed(BoundedBoxFixtures.NumberBox<T>)applies and is more specific thanboxed(Object). The capture took only the wildcard's own bound, so the generic overload did not apply and the call went toboxed(Object). It was right before PR 518.- Throws:
Exception
-