Kapt: Support type aliases in correctErrorTypes mode (KT-19402)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.javac
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.sun.tools.javac.tree.JCTree
|
||||
import com.sun.tools.javac.util.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
@@ -141,4 +142,9 @@ class KaptJavaLog(
|
||||
|
||||
fun KaptContext<*>.kaptError(text: String): JCDiagnostic {
|
||||
return JCDiagnostic.Factory.instance(context).error(null, null, "proc.messager", text)
|
||||
}
|
||||
|
||||
fun KaptContext<*>.kaptError(text: String, target: PsiElement): JCDiagnostic {
|
||||
//TODO provide source binding
|
||||
return JCDiagnostic.Factory.instance(context).error(null, null, "proc.messager", text)
|
||||
}
|
||||
+9
-7
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.kapt3.*
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptTreeMaker
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.kapt3.javac.kaptError
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ErrorTypeCorrector.TypeKind.*
|
||||
import org.jetbrains.kotlin.kapt3.util.*
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -385,7 +386,7 @@ class ClassFileToSourceStubConverter(
|
||||
treeMaker.SimpleName(treeMaker.getQualifiedName(type).substringAfterLast('.'))
|
||||
else
|
||||
anonymousTypeHandler.getNonAnonymousType(descriptor) {
|
||||
getNonErrorType((descriptor as? CallableDescriptor)?.returnType,
|
||||
getNonErrorType((descriptor as? CallableDescriptor)?.returnType, RETURN_TYPE,
|
||||
ktTypeProvider = { (kaptContext.origins[field]?.element as? KtVariableDeclaration)?.typeReference },
|
||||
ifNonError = { signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type)) })
|
||||
}
|
||||
@@ -515,12 +516,12 @@ class ClassFileToSourceStubConverter(
|
||||
method.signature, parameters, exceptionTypes, jcReturnType,
|
||||
nonErrorParameterTypeProvider = { index, lazyType ->
|
||||
if (descriptor is PropertySetterDescriptor && valueParametersFromDescriptor.size == 1 && index == 0) {
|
||||
getNonErrorType(descriptor.correspondingProperty.returnType,
|
||||
getNonErrorType(descriptor.correspondingProperty.returnType, METHOD_PARAMETER_TYPE,
|
||||
ktTypeProvider = { (kaptContext.origins[method]?.element as? KtVariableDeclaration)?.typeReference },
|
||||
ifNonError = { lazyType() })
|
||||
}
|
||||
else if (descriptor is FunctionDescriptor && valueParametersFromDescriptor.size == parameters.size) {
|
||||
getNonErrorType(valueParametersFromDescriptor[index].type,
|
||||
getNonErrorType(valueParametersFromDescriptor[index].type, METHOD_PARAMETER_TYPE,
|
||||
ktTypeProvider = {
|
||||
(kaptContext.origins[method]?.element as? KtFunction)?.valueParameters?.get(index)?.typeReference
|
||||
},
|
||||
@@ -532,7 +533,7 @@ class ClassFileToSourceStubConverter(
|
||||
})
|
||||
|
||||
val returnType = anonymousTypeHandler.getNonAnonymousType(descriptor) {
|
||||
getNonErrorType(descriptor.returnType,
|
||||
getNonErrorType(descriptor.returnType, RETURN_TYPE,
|
||||
ktTypeProvider = {
|
||||
val element = kaptContext.origins[method]?.element
|
||||
when (element) {
|
||||
@@ -549,6 +550,7 @@ class ClassFileToSourceStubConverter(
|
||||
|
||||
private inline fun <T : JCExpression?> getNonErrorType(
|
||||
type: KotlinType?,
|
||||
kind: ErrorTypeCorrector.TypeKind,
|
||||
ktTypeProvider: () -> KtTypeReference?,
|
||||
ifNonError: () -> T
|
||||
): T {
|
||||
@@ -557,10 +559,10 @@ class ClassFileToSourceStubConverter(
|
||||
}
|
||||
|
||||
if (type?.containsErrorTypes() == true) {
|
||||
val ktType = ktTypeProvider()
|
||||
if (ktType != null) {
|
||||
val typeFromSource = ktTypeProvider()?.typeElement
|
||||
if (typeFromSource != null) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return convertKtType(ktType, this) as T
|
||||
return ErrorTypeCorrector(this, kind).convert(typeFromSource, emptyMap()) as T
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.stubs
|
||||
|
||||
import com.sun.tools.javac.code.BoundKind
|
||||
import com.sun.tools.javac.tree.JCTree
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.codegen.state.updateArgumentModeFromAnnotations
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.kapt3.javac.kaptError
|
||||
import org.jetbrains.kotlin.kapt3.mapJList
|
||||
import org.jetbrains.kotlin.kapt3.mapJListIndexed
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ErrorTypeCorrector.TypeKind.METHOD_PARAMETER_TYPE
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ErrorTypeCorrector.TypeKind.RETURN_TYPE
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
private typealias SubstitutionMap = Map<String, Pair<KtTypeParameter, KtTypeProjection>>
|
||||
|
||||
class ErrorTypeCorrector(
|
||||
private val converter: ClassFileToSourceStubConverter,
|
||||
private val typeKind: TypeKind
|
||||
) {
|
||||
private val defaultType = converter.treeMaker.FqName(Object::class.java.name)
|
||||
|
||||
private val bindingContext get() = converter.kaptContext.bindingContext
|
||||
private val treeMaker get() = converter.treeMaker
|
||||
|
||||
enum class TypeKind {
|
||||
RETURN_TYPE, METHOD_PARAMETER_TYPE
|
||||
}
|
||||
|
||||
fun convert(type: KtTypeElement, substitutions: SubstitutionMap): JCTree.JCExpression {
|
||||
return when (type) {
|
||||
is KtUserType -> convertUserType(type, substitutions)
|
||||
is KtNullableType -> convert(type.innerType ?: return defaultType, substitutions)
|
||||
is KtFunctionType -> convertFunctionType(type, substitutions)
|
||||
else -> defaultType
|
||||
}
|
||||
}
|
||||
|
||||
private fun convert(typeReference: KtTypeReference?, substitutions: SubstitutionMap): JCTree.JCExpression {
|
||||
val type = typeReference?.typeElement ?: return defaultType
|
||||
return convert(type, substitutions)
|
||||
}
|
||||
|
||||
private fun convert(type: SimpleType): JCTree.JCExpression {
|
||||
// TODO now the raw Java type is returned. In future we need to properly convert all type parameters
|
||||
return treeMaker.Type(converter.kaptContext.generationState.typeMapper.mapType(type))
|
||||
}
|
||||
|
||||
private fun convertUserType(type: KtUserType, substitutions: SubstitutionMap): JCTree.JCExpression {
|
||||
val target = bindingContext[BindingContext.REFERENCE_TARGET, type.referenceExpression]
|
||||
|
||||
val baseExpression: JCTree.JCExpression
|
||||
|
||||
if (target is TypeAliasDescriptor) {
|
||||
val typeAlias = target.source.getPsi() as? KtTypeAlias
|
||||
val actualType = typeAlias?.getTypeReference() ?: return convert(target.expandedType)
|
||||
return convert(actualType, typeAlias.getSubstitutions(type))
|
||||
} else if (target is ClassDescriptor) {
|
||||
// We only get here if some type were an error type. In other words, 'type' is either an error type or its argument,
|
||||
// so it's impossible it to be unboxed primitive.
|
||||
val asmType = converter.kaptContext.generationState.typeMapper.mapType(target.defaultType, null, TypeMappingMode.GENERIC_ARGUMENT)
|
||||
baseExpression = converter.treeMaker.Type(asmType)
|
||||
} else {
|
||||
val referencedName = type.referencedName ?: return defaultType
|
||||
val qualifier = type.qualifier
|
||||
|
||||
if (qualifier == null && referencedName in substitutions) {
|
||||
val (typeParameter, projection) = substitutions.getValue(referencedName)
|
||||
return convertTypeProjection(projection, typeParameter.variance, emptyMap())
|
||||
}
|
||||
|
||||
baseExpression = when {
|
||||
qualifier != null -> {
|
||||
val qualifierType = convertUserType(qualifier, substitutions)
|
||||
if (qualifierType === defaultType) return defaultType // Do not allow to use 'defaultType' as a qualifier
|
||||
treeMaker.Select(qualifierType, treeMaker.name(referencedName))
|
||||
}
|
||||
else -> treeMaker.SimpleName(referencedName)
|
||||
}
|
||||
}
|
||||
|
||||
val arguments = type.typeArguments
|
||||
if (arguments.isEmpty()) return baseExpression
|
||||
|
||||
val typeReference = type.getParentOfType<KtTypeReference>(strict = true)
|
||||
val kotlinType = bindingContext[BindingContext.TYPE, typeReference] ?: ErrorUtils.createErrorType("Kapt error type")
|
||||
|
||||
val typeMappingMode = when (typeKind) {
|
||||
//TODO figure out if the containing method is an annotation method
|
||||
RETURN_TYPE -> TypeMappingMode.getOptimalModeForReturnType(kotlinType, false)
|
||||
METHOD_PARAMETER_TYPE -> TypeMappingMode.getOptimalModeForValueParameter(kotlinType)
|
||||
}.updateArgumentModeFromAnnotations(kotlinType)
|
||||
|
||||
val typeParameters = (target as? ClassifierDescriptor)?.typeConstructor?.parameters
|
||||
return treeMaker.TypeApply(baseExpression, mapJListIndexed(arguments) { index, projection ->
|
||||
val typeParameter = typeParameters?.getOrNull(index)
|
||||
val typeArgument = kotlinType.arguments.getOrNull(index)
|
||||
|
||||
val variance = if (typeArgument != null && typeParameter != null) {
|
||||
KotlinTypeMapper.getVarianceForWildcard(typeParameter, typeArgument, typeMappingMode)
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
|
||||
convertTypeProjection(projection, variance, substitutions)
|
||||
})
|
||||
}
|
||||
|
||||
private fun convertTypeProjection(
|
||||
projection: KtTypeProjection,
|
||||
variance: Variance?,
|
||||
substitutions: SubstitutionMap
|
||||
): JCTree.JCExpression {
|
||||
fun unbounded() = treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.UNBOUND), null)
|
||||
|
||||
// Use unbounded wildcard when a generic argument can't be resolved
|
||||
val argumentType = projection.typeReference ?: return unbounded()
|
||||
val argumentExpression by lazy { convert(argumentType, substitutions) }
|
||||
|
||||
if (variance === Variance.INVARIANT) {
|
||||
return argumentExpression
|
||||
}
|
||||
|
||||
val projectionKind = projection.projectionKind
|
||||
|
||||
return when {
|
||||
projectionKind === KtProjectionKind.STAR -> treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.UNBOUND), null)
|
||||
projectionKind === KtProjectionKind.IN || variance === Variance.IN_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.SUPER), argumentExpression)
|
||||
projectionKind === KtProjectionKind.OUT || variance === Variance.OUT_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.EXTENDS), argumentExpression)
|
||||
else -> argumentExpression // invariant
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertFunctionType(type: KtFunctionType, substitutions: SubstitutionMap): JCTree.JCExpression {
|
||||
val receiverType = type.receiverTypeReference
|
||||
var parameterTypes = mapJList(type.parameters) { convert(it.typeReference, substitutions) }
|
||||
val returnType = convert(type.returnTypeReference, substitutions)
|
||||
|
||||
if (receiverType != null) {
|
||||
parameterTypes = parameterTypes.prepend(convert(receiverType, substitutions))
|
||||
}
|
||||
|
||||
parameterTypes = parameterTypes.append(returnType)
|
||||
|
||||
val treeMaker = converter.treeMaker
|
||||
return treeMaker.TypeApply(treeMaker.SimpleName("Function" + (parameterTypes.size - 1)), parameterTypes)
|
||||
}
|
||||
|
||||
private fun KtTypeParameterListOwner.getSubstitutions(actualType: KtUserType): SubstitutionMap {
|
||||
val arguments = actualType.typeArguments
|
||||
|
||||
if (typeParameters.size != arguments.size) {
|
||||
val kaptContext = converter.kaptContext
|
||||
kaptContext.compiler.log.report(
|
||||
kaptContext.kaptError("${typeParameters.size} parameters are expected but ${arguments.size} passed", actualType))
|
||||
return emptyMap()
|
||||
}
|
||||
|
||||
val substitutionMap = mutableMapOf<String, Pair<KtTypeParameter, KtTypeProjection>>()
|
||||
|
||||
typeParameters.forEachIndexed { index, typeParameter ->
|
||||
val name = typeParameter.name ?: return@forEachIndexed
|
||||
substitutionMap[name] = Pair(typeParameter, arguments[index])
|
||||
}
|
||||
|
||||
return substitutionMap
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinType.containsErrorTypes(allowedDepth: Int = 10): Boolean {
|
||||
// Need to limit recursion depth in case of complex recursive generics
|
||||
if (allowedDepth <= 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.isError) return true
|
||||
if (this.arguments.any { !it.isStarProjection && it.type.containsErrorTypes(allowedDepth - 1) }) return true
|
||||
return false
|
||||
}
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.stubs
|
||||
|
||||
import com.sun.tools.javac.code.BoundKind
|
||||
import com.sun.tools.javac.tree.JCTree
|
||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.codegen.state.updateArgumentModeFromAnnotations
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.kapt3.mapJList
|
||||
import org.jetbrains.kotlin.kapt3.mapJListIndexed
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
|
||||
internal fun convertKtType(
|
||||
reference: KtTypeReference?,
|
||||
converter: ClassFileToSourceStubConverter,
|
||||
shouldBeBoxed: Boolean = false,
|
||||
gotTypeElement: KtTypeElement? = null
|
||||
): JCTree.JCExpression {
|
||||
val type = gotTypeElement ?: reference?.typeElement
|
||||
|
||||
if (reference != null) {
|
||||
val kotlinType = converter.kaptContext.bindingContext[BindingContext.TYPE, reference]
|
||||
if (kotlinType != null && !kotlinType.containsErrorTypes()) {
|
||||
val signatureWriter = BothSignatureWriter(BothSignatureWriter.Mode.TYPE)
|
||||
converter.kaptContext.generationState.typeMapper.mapType(kotlinType, signatureWriter,
|
||||
if (shouldBeBoxed) TypeMappingMode.GENERIC_ARGUMENT else TypeMappingMode.DEFAULT)
|
||||
|
||||
return SignatureParser(converter.treeMaker).parseFieldSignature(
|
||||
signatureWriter.toString(), getDefaultTypeForUnknownType(converter))
|
||||
}
|
||||
}
|
||||
|
||||
return when (type) {
|
||||
is KtUserType -> convertUserType(type, converter, reference)
|
||||
is KtNullableType -> {
|
||||
// Prevent infinite recursion
|
||||
val innerType = type.innerType ?: return getDefaultTypeForUnknownType(converter)
|
||||
convertKtType(reference, converter, shouldBeBoxed = true, gotTypeElement = innerType)
|
||||
}
|
||||
is KtFunctionType -> convertFunctionType(type, converter)
|
||||
else -> getDefaultTypeForUnknownType(converter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDefaultTypeForUnknownType(converter: ClassFileToSourceStubConverter) = converter.treeMaker.FqName("error.NonExistentClass")
|
||||
|
||||
private fun convertUserType(type: KtUserType, converter: ClassFileToSourceStubConverter, reference: KtTypeReference?): JCTree.JCExpression {
|
||||
val qualifierExpression = type.qualifier?.let { convertUserType(it, converter, null) }
|
||||
val referencedName = type.referencedName ?: "error"
|
||||
val treeMaker = converter.treeMaker
|
||||
|
||||
val baseExpression = if (qualifierExpression == null) {
|
||||
// This could be List<SomeErrorType> or similar. List should be converted to java.util.List in this case.
|
||||
val referenceTarget = converter.kaptContext.bindingContext[BindingContext.REFERENCE_TARGET, type.referenceExpression]
|
||||
if (referenceTarget is ClassDescriptor) {
|
||||
treeMaker.FqName(converter.kaptContext.generationState.typeMapper.mapType(referenceTarget.defaultType).internalName)
|
||||
}
|
||||
else {
|
||||
treeMaker.SimpleName(referencedName)
|
||||
}
|
||||
} else {
|
||||
treeMaker.Select(qualifierExpression, treeMaker.name(referencedName))
|
||||
}
|
||||
|
||||
val arguments = type.typeArguments
|
||||
if (arguments.isEmpty()) {
|
||||
return baseExpression
|
||||
}
|
||||
|
||||
val baseType = reference?.let { converter.kaptContext.bindingContext[BindingContext.TYPE, it] }
|
||||
|
||||
return treeMaker.TypeApply(baseExpression, mapJListIndexed(arguments) { index, projection ->
|
||||
val argumentType = projection.typeReference?.let { converter.kaptContext.bindingContext[BindingContext.TYPE, it] }
|
||||
val typeParameter = argumentType?.constructor?.parameters?.getOrNull(index)
|
||||
val argument = baseType?.arguments?.getOrNull(index)
|
||||
|
||||
val variance = if (argument != null && typeParameter != null) {
|
||||
val argumentMode = TypeMappingMode.GENERIC_ARGUMENT.updateArgumentModeFromAnnotations(argument.type)
|
||||
KotlinTypeMapper.getVarianceForWildcard(typeParameter, argument, argumentMode)
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
|
||||
convertTypeProjection(projection, variance, converter)
|
||||
})
|
||||
}
|
||||
|
||||
private fun convertTypeProjection(type: KtTypeProjection, variance: Variance?, converter: ClassFileToSourceStubConverter): JCTree.JCExpression {
|
||||
val reference = type.typeReference
|
||||
val treeMaker = converter.treeMaker
|
||||
val projectionKind = type.projectionKind
|
||||
|
||||
if (variance === Variance.INVARIANT) {
|
||||
return convertKtType(reference, converter, shouldBeBoxed = true)
|
||||
}
|
||||
|
||||
return when {
|
||||
projectionKind === KtProjectionKind.STAR -> treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.UNBOUND), null)
|
||||
projectionKind === KtProjectionKind.IN || variance === Variance.IN_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.SUPER), convertKtType(reference, converter, shouldBeBoxed = true))
|
||||
projectionKind === KtProjectionKind.OUT || variance === Variance.OUT_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.EXTENDS), convertKtType(reference, converter, shouldBeBoxed = true))
|
||||
else -> convertKtType(reference, converter, shouldBeBoxed = true) // invariant
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertFunctionType(type: KtFunctionType, converter: ClassFileToSourceStubConverter): JCTree.JCExpression {
|
||||
val receiverType = type.receiverTypeReference
|
||||
var parameterTypes = mapJList(type.parameters) { convertKtType(it.typeReference, converter) }
|
||||
val returnType = convertKtType(type.returnTypeReference, converter)
|
||||
|
||||
if (receiverType != null) {
|
||||
parameterTypes = parameterTypes.prepend(convertKtType(receiverType, converter))
|
||||
}
|
||||
|
||||
parameterTypes = parameterTypes.append(returnType)
|
||||
|
||||
val treeMaker = converter.treeMaker
|
||||
return treeMaker.TypeApply(treeMaker.SimpleName("Function" + (parameterTypes.size - 1)), parameterTypes)
|
||||
}
|
||||
|
||||
fun KotlinType.containsErrorTypes(allowedDepth: Int = 10): Boolean {
|
||||
// Need to limit recursion depth in case of complex recursive generics
|
||||
if (allowedDepth <= 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.isError) return true
|
||||
if (this.arguments.any { !it.isStarProjection && it.type.containsErrorTypes(allowedDepth - 1) }) return true
|
||||
return false
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public final class NonExistentType {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private static final Function1<ABCDEF, kotlin.Unit> c = null;
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private static final ABCDEF<java.lang.String, ? extends Function1<java.util.List<ABCDEF>, kotlin.Unit>> d = null;
|
||||
private static final ABCDEF<java.lang.String, Function1<java.util.List<ABCDEF>, kotlin.Unit>> d = null;
|
||||
public static final NonExistentType INSTANCE = null;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
@@ -27,7 +27,7 @@ public final class NonExistentType {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public final ABCDEF<java.lang.String, ? extends Function1<java.util.List<ABCDEF>, kotlin.Unit>> getD() {
|
||||
public final ABCDEF<java.lang.String, Function1<java.util.List<ABCDEF>, kotlin.Unit>> getD() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+17
-2
@@ -3,12 +3,19 @@
|
||||
// NO_VALIDATION
|
||||
// WITH_RUNTIME
|
||||
|
||||
@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE")
|
||||
import java.util.Calendar
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE")
|
||||
typealias Coocoo = ABC
|
||||
typealias Coocoo2<T> = ABC<T>
|
||||
typealias Coocoo3<X> = ABC<String, X>
|
||||
|
||||
typealias Nested1 = ABC
|
||||
typealias Nested2 = Nested1
|
||||
|
||||
@Anno(Blah::class, arrayOf(NoFoo1::class, NoBar1::class), [NoFoo2::class, String::class], Boolean::class, NoBar3::class)
|
||||
class Test {
|
||||
class Test<G> {
|
||||
lateinit var a: ABC
|
||||
val b: ABC? = null
|
||||
val c: List<ABC>? = null
|
||||
@@ -23,6 +30,14 @@ class Test {
|
||||
|
||||
lateinit var l: ABC.BCD.EFG
|
||||
|
||||
lateinit var coocoo: Coocoo
|
||||
lateinit var coocoo2: Coocoo2<String>
|
||||
lateinit var coocoo21: Coocoo2<Coocoo>
|
||||
lateinit var coocoo3: Coocoo3<String>
|
||||
lateinit var coocoo31: Coocoo3<Coocoo2<Coocoo>>
|
||||
|
||||
lateinit var nested: Nested2
|
||||
|
||||
val m = ABC()
|
||||
val n = "".toString()
|
||||
|
||||
|
||||
+86
-10
@@ -35,9 +35,19 @@ import java.util.Calendar;
|
||||
import kotlin.reflect.KClass;
|
||||
|
||||
@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE"})
|
||||
@kotlin.Metadata()
|
||||
public final class NonExistentClassTypesConversionKt {
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.util.Calendar;
|
||||
import kotlin.reflect.KClass;
|
||||
|
||||
@kotlin.Metadata()
|
||||
@Anno(a = Blah.class, b = {NoFoo1.class, NoBar1.class}, c = {NoFoo2.class, String.class}, d = {Boolean.class, NoBar3.class})
|
||||
public final class Test {
|
||||
public final class Test<G extends java.lang.Object> {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC a;
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
@@ -45,9 +55,9 @@ public final class Test {
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private final java.util.List<ABC> c = null;
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private final java.util.List<java.util.Map<BCD, ABC<? extends java.util.List<BCD>>>> d = null;
|
||||
private final java.util.List<java.util.Map<BCD, ABC<java.util.List<BCD>>>> d = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.List<? extends java.util.Map<? extends ABC, ? extends BCD>> e;
|
||||
public java.util.List<java.util.Map<? extends ABC, BCD>> e;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC<?> f;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
@@ -63,13 +73,25 @@ public final class Test {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC.BCD.EFG l;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC coocoo;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC<java.lang.String> coocoo2;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC<ABC> coocoo21;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC<java.lang.String, java.lang.String> coocoo3;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC<java.lang.String, ABC<ABC>> coocoo31;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public ABC nested;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final error.NonExistentClass m = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String n = "";
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends error.NonExistentClass>>>>>>>>>> o11;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<ABC>>>>>>>>> o10;
|
||||
public java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<ABC>>>>>>>>> o10;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.Calendar.Builder p;
|
||||
|
||||
@@ -93,12 +115,12 @@ public final class Test {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public final java.util.List<java.util.Map<BCD, ABC<? extends java.util.List<BCD>>>> getD() {
|
||||
public final java.util.List<java.util.Map<BCD, ABC<java.util.List<BCD>>>> getD() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.util.List<? extends java.util.Map<? extends ABC, ? extends BCD>> getE() {
|
||||
public final java.util.List<java.util.Map<? extends ABC, BCD>> getE() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -139,7 +161,7 @@ public final class Test {
|
||||
}
|
||||
|
||||
public final void setI(@org.jetbrains.annotations.NotNull()
|
||||
Function2<ABC, java.util.List<BCD>, CDE> p0) {
|
||||
Function2<ABC, java.util.List<? extends BCD>, CDE> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
@@ -157,7 +179,7 @@ public final class Test {
|
||||
}
|
||||
|
||||
public final void setK(@org.jetbrains.annotations.NotNull()
|
||||
Function2<ABC, java.util.List<BCD>, CDE> p0) {
|
||||
Function2<ABC, java.util.List<? extends BCD>, CDE> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
@@ -169,6 +191,60 @@ public final class Test {
|
||||
ABC.BCD.EFG p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC getCoocoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo(@org.jetbrains.annotations.NotNull()
|
||||
ABC p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC<java.lang.String> getCoocoo2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo2(@org.jetbrains.annotations.NotNull()
|
||||
ABC<java.lang.String> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC<ABC> getCoocoo21() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo21(@org.jetbrains.annotations.NotNull()
|
||||
ABC<ABC> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC<java.lang.String, java.lang.String> getCoocoo3() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo3(@org.jetbrains.annotations.NotNull()
|
||||
ABC<java.lang.String, java.lang.String> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC<java.lang.String, ABC<ABC>> getCoocoo31() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo31(@org.jetbrains.annotations.NotNull()
|
||||
ABC<java.lang.String, ABC<ABC>> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final ABC getNested() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setNested(@org.jetbrains.annotations.NotNull()
|
||||
ABC p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getM() {
|
||||
return null;
|
||||
@@ -189,12 +265,12 @@ public final class Test {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<ABC>>>>>>>>> getO10() {
|
||||
public final java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<java.util.List<ABC>>>>>>>>> getO10() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setO10(@org.jetbrains.annotations.NotNull()
|
||||
java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<ABC>>>>>>>>> p0) {
|
||||
java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends java.util.List<? extends ABC>>>>>>>>> p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
|
||||
+15
-1
@@ -1,13 +1,27 @@
|
||||
// NON_EXISTENT_CLASS
|
||||
// NO_VALIDATION
|
||||
|
||||
@Suppress("UNRESOLVED_REFERENCE")
|
||||
@file:Suppress("UNRESOLVED_REFERENCE")
|
||||
|
||||
typealias String2 = String
|
||||
typealias Coocoo = ABC
|
||||
typealias Coocoo2<T> = ABC<T>
|
||||
typealias Coocoo3<X> = ABC<String, X>
|
||||
|
||||
object NonExistentType {
|
||||
val a: ABCDEF? = null
|
||||
val b: List<ABCDEF>? = null
|
||||
val c: (ABCDEF) -> Unit = { f -> }
|
||||
val d: ABCDEF<String, (List<ABCDEF>) -> Unit>? = null
|
||||
|
||||
lateinit var string2: String2
|
||||
|
||||
lateinit var coocoo: Coocoo
|
||||
lateinit var coocoo2: Coocoo2<String>
|
||||
lateinit var coocoo21: Coocoo2<Coocoo>
|
||||
lateinit var coocoo3: Coocoo3<String>
|
||||
lateinit var coocoo31: Coocoo3<Coocoo2<Coocoo>>
|
||||
|
||||
fun a(a: ABCDEF, s: String): ABCDEF {}
|
||||
fun b(s: String): ABCDEF {}
|
||||
}
|
||||
+73
@@ -1,4 +1,11 @@
|
||||
@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE"})
|
||||
@kotlin.Metadata()
|
||||
public final class NonExistentClassWIthoutCorrectionKt {
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class NonExistentType {
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
@@ -9,6 +16,18 @@ public final class NonExistentType {
|
||||
private static final kotlin.jvm.functions.Function1<error.NonExistentClass, kotlin.Unit> c = null;
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private static final error.NonExistentClass d = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static java.lang.String string2;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static error.NonExistentClass coocoo;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static error.NonExistentClass coocoo2;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static error.NonExistentClass coocoo21;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static error.NonExistentClass coocoo3;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static error.NonExistentClass coocoo31;
|
||||
public static final NonExistentType INSTANCE = null;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
@@ -31,6 +50,60 @@ public final class NonExistentType {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getString2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setString2(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getCoocoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getCoocoo2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo2(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getCoocoo21() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo21(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getCoocoo3() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo3(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass getCoocoo31() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setCoocoo31(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final error.NonExistentClass a(@org.jetbrains.annotations.NotNull()
|
||||
error.NonExistentClass a, @org.jetbrains.annotations.NotNull()
|
||||
|
||||
Reference in New Issue
Block a user