diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassImpl.java index 39050e233d4..9bd7d799793 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassImpl.java @@ -16,10 +16,8 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiCompiledElement; -import com.intellij.psi.PsiTypeParameter; +import com.intellij.psi.*; +import com.intellij.psi.impl.PsiSubstitutorImpl; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,7 +28,9 @@ import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.*; @@ -181,4 +181,27 @@ public class JavaClassImpl extends JavaClassifierImpl implements JavaC return OriginKind.SOURCE; } } + + @NotNull + @Override + public JavaType createImmediateType(@NotNull JavaTypeSubstitutor substitutor) { + return new JavaClassifierTypeImpl( + JavaPsiFacade.getElementFactory(getPsi().getProject()).createType(getPsi(), createPsiSubstitutor(substitutor))); + } + + @NotNull + private static PsiSubstitutor createPsiSubstitutor(@NotNull JavaTypeSubstitutor substitutor) { + Map substMap = new HashMap(); + for (Map.Entry entry : substitutor.getSubstitutionMap().entrySet()) { + PsiTypeParameter key = ((JavaTypeParameterImpl) entry.getKey()).getPsi(); + if (entry.getValue() == null) { + substMap.put(key, null); + } + else { + substMap.put(key, ((JavaTypeImpl) entry.getValue()).getPsi()); + } + } + + return PsiSubstitutorImpl.createSubstitutor(substMap); + } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassifierTypeImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassifierTypeImpl.java index 13493d162c6..d91be1c9ca7 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassifierTypeImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaClassifierTypeImpl.java @@ -16,20 +16,12 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassType; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.java.structure.JavaClassifier; -import org.jetbrains.jet.lang.resolve.java.structure.JavaClassifierType; -import org.jetbrains.jet.lang.resolve.java.structure.JavaType; -import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeSubstitutor; +import org.jetbrains.jet.lang.resolve.java.structure.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import static org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementCollectionFromPsiArrayUtil.types; @@ -68,13 +60,25 @@ public class JavaClassifierTypeImpl extends JavaTypeImpl implement if (resolutionResult == null) { PsiClassType.ClassResolveResult result = getPsi().resolveGenerics(); PsiClass psiClass = result.getElement(); + PsiSubstitutor substitutor = result.getSubstitutor(); resolutionResult = new ResolutionResult( psiClass == null ? null : JavaClassifierImpl.create(psiClass), - new JavaTypeSubstitutorImpl(result.getSubstitutor()) + new JavaTypeSubstitutorImpl(convertSubstitutionMap(substitutor.getSubstitutionMap())) ); } } + @NotNull + private Map convertSubstitutionMap(@NotNull Map psiMap) { + Map substitutionMap = new HashMap(); + for (Map.Entry entry : psiMap.entrySet()) { + PsiType value = entry.getValue(); + substitutionMap.put(new JavaTypeParameterImpl(entry.getKey()), value == null ? null : JavaTypeImpl.create(value)); + } + + return substitutionMap; + } + @Override @NotNull public Collection getSupertypes() { diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeImpl.java index 680d5c53cdb..d859abdba9c 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeImpl.java @@ -39,31 +39,31 @@ public abstract class JavaTypeImpl implements JavaType { return psiType.accept(new PsiTypeVisitor>() { @Nullable @Override - public JavaTypeImpl visitType(PsiType type) { + public JavaTypeImpl visitType(@NotNull PsiType type) { throw new UnsupportedOperationException("Unsupported PsiType: " + type); } @Nullable @Override - public JavaTypeImpl visitPrimitiveType(PsiPrimitiveType primitiveType) { + public JavaTypeImpl visitPrimitiveType(@NotNull PsiPrimitiveType primitiveType) { return new JavaPrimitiveTypeImpl(primitiveType); } @Nullable @Override - public JavaTypeImpl visitArrayType(PsiArrayType arrayType) { + public JavaTypeImpl visitArrayType(@NotNull PsiArrayType arrayType) { return new JavaArrayTypeImpl(arrayType); } @Nullable @Override - public JavaTypeImpl visitClassType(PsiClassType classType) { + public JavaTypeImpl visitClassType(@NotNull PsiClassType classType) { return new JavaClassifierTypeImpl(classType); } @Nullable @Override - public JavaTypeImpl visitWildcardType(PsiWildcardType wildcardType) { + public JavaTypeImpl visitWildcardType(@NotNull PsiWildcardType wildcardType) { return new JavaWildcardTypeImpl(wildcardType); } }); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeProviderImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeProviderImpl.java index 45ad66eaf8a..6c45f61f0ad 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeProviderImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeProviderImpl.java @@ -18,10 +18,12 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiType; +import com.intellij.psi.PsiWildcardType; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.java.structure.JavaType; import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeProvider; +import org.jetbrains.jet.lang.resolve.java.structure.JavaWildcardType; public class JavaTypeProviderImpl implements JavaTypeProvider { private final PsiManager manager; @@ -35,4 +37,22 @@ public class JavaTypeProviderImpl implements JavaTypeProvider { public JavaType createJavaLangObjectType() { return JavaTypeImpl.create(PsiType.getJavaLangObject(manager, GlobalSearchScope.allScope(manager.getProject()))); } + + @NotNull + @Override + public JavaWildcardType createUpperBoundWildcard(@NotNull JavaType bound) { + return new JavaWildcardTypeImpl(PsiWildcardType.createExtends(manager, ((JavaTypeImpl) bound).getPsi())); + } + + @NotNull + @Override + public JavaWildcardType createLowerBoundWildcard(@NotNull JavaType bound) { + return new JavaWildcardTypeImpl(PsiWildcardType.createSuper(manager, ((JavaTypeImpl) bound).getPsi())); + } + + @NotNull + @Override + public JavaWildcardType createUnboundedWildcard() { + return new JavaWildcardTypeImpl(PsiWildcardType.createUnbounded(manager)); + } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeSubstitutorImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeSubstitutorImpl.java index 9983a52bcf3..146d79a5e86 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeSubstitutorImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaTypeSubstitutorImpl.java @@ -16,83 +16,170 @@ package org.jetbrains.jet.lang.resolve.java.structure.impl; -import com.intellij.psi.PsiSubstitutor; -import com.intellij.psi.PsiType; -import com.intellij.psi.PsiTypeParameter; -import com.intellij.psi.impl.PsiSubstitutorImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.java.structure.JavaType; -import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeParameter; -import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeSubstitutor; +import org.jetbrains.jet.lang.resolve.java.structure.*; +import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; public class JavaTypeSubstitutorImpl implements JavaTypeSubstitutor { - private final PsiSubstitutor psiSubstitutor; - private Map substitutionMap; + private final Map substitutionMap; - public JavaTypeSubstitutorImpl(@NotNull PsiSubstitutor psiSubstitutor) { - this.psiSubstitutor = psiSubstitutor; - } - - public JavaTypeSubstitutorImpl(@NotNull PsiSubstitutor psiSubstitutor, @NotNull Map substitutionMap) { - this(psiSubstitutor); + public JavaTypeSubstitutorImpl(@NotNull Map substitutionMap) { this.substitutionMap = substitutionMap; } @NotNull - public static JavaTypeSubstitutor create(@NotNull Map substitutionMap) { - Map psiMap = new HashMap(); - for (Map.Entry entry : substitutionMap.entrySet()) { - JavaTypeImpl value = ((JavaTypeImpl) entry.getValue()); - psiMap.put(((JavaTypeParameterImpl) entry.getKey()).getPsi(), value == null ? null : value.getPsi()); - } - PsiSubstitutor psiSubstitutor = PsiSubstitutorImpl.createSubstitutor(psiMap); - return new JavaTypeSubstitutorImpl(psiSubstitutor, substitutionMap); + @Override + public JavaType substitute(@NotNull JavaType type) { + JavaType substitutedType = substituteInternal(type); + return substitutedType != null ? substitutedType : correctSubstitutionForRawType(type); } - @Override @NotNull - public JavaType substitute(@NotNull JavaType type) { - return JavaTypeImpl.create(psiSubstitutor.substitute(((JavaTypeImpl) type).getPsi())); + // In case of raw type we get substition map like T -> null, + // in this case we should substitute upper bound of T or, + // if it does not exist, return java.lang.Object + private JavaType correctSubstitutionForRawType(@NotNull JavaType original) { + if (original instanceof JavaClassifierType) { + JavaClassifier classifier = ((JavaClassifierType) original).getClassifier(); + if (classifier instanceof JavaTypeParameter) { + return rawTypeForTypeParameter((JavaTypeParameter) classifier); + } + } + + return original; + } + + @Nullable + private JavaType substituteInternal(@NotNull JavaType type) { + if (type instanceof JavaClassifierType) { + JavaClassifierType classifierType = (JavaClassifierType) type; + JavaClassifier classifier = classifierType.getClassifier(); + + if (classifier instanceof JavaTypeParameter) { + return substitute((JavaTypeParameter) classifier); + } + else if (classifier instanceof JavaClass) { + JavaClass javaClass = (JavaClass) classifier; + Map substMap = new HashMap(); + processClass(javaClass, classifierType.getSubstitutor(), substMap); + + return javaClass.createImmediateType(new JavaTypeSubstitutorImpl(substMap)); + } + + return type; + } + else if (type instanceof JavaPrimitiveType) { + return type; + } + else if (type instanceof JavaArrayType) { + JavaType componentType = ((JavaArrayType) type).getComponentType(); + JavaType substitutedComponentType = substitute(componentType); + if (substitutedComponentType == componentType) return type; + + return substitutedComponentType.createArrayType(); + } + else if (type instanceof JavaWildcardType) { + return substituteWildcardType((JavaWildcardType) type); + } + + return type; + } + + private void processClass(@NotNull JavaClass javaClass, @NotNull JavaTypeSubstitutor substitutor, @NotNull Map substMap) { + List typeParameters = javaClass.getTypeParameters(); + for (JavaTypeParameter typeParameter : typeParameters) { + JavaType substitutedParam = substitutor.substitute(typeParameter); + if (substitutedParam == null) { + substMap.put(typeParameter, null); + } + else { + substMap.put(typeParameter, substituteInternal(substitutedParam)); + } + } + + if (javaClass.isStatic()) { + return; + } + + JavaClass outerClass = javaClass.getOuterClass(); + if (outerClass != null) { + processClass(outerClass, substitutor, substMap); + } + } + + @Nullable + private JavaType substituteWildcardType(@NotNull JavaWildcardType wildcardType) { + JavaType bound = wildcardType.getBound(); + if (bound == null) { + return wildcardType; + } + + JavaType newBound = substituteInternal(bound); + if (newBound == null) { + // This can be in case of substitution wildcard to raw type + return null; + } + + return rebound(wildcardType, newBound); + } + + @NotNull + private static JavaWildcardType rebound(@NotNull JavaWildcardType type, @NotNull JavaType newBound) { + if (type.getTypeProvider().createJavaLangObjectType().equals(newBound)) { + return type.getTypeProvider().createUnboundedWildcard(); + } + + if (type.isExtends()) { + return type.getTypeProvider().createUpperBoundWildcard(newBound); + } + else { + return type.getTypeProvider().createLowerBoundWildcard(newBound); + } + } + + @NotNull + private JavaType rawTypeForTypeParameter(@NotNull JavaTypeParameter typeParameter) { + Collection bounds = typeParameter.getUpperBounds(); + if (!bounds.isEmpty()) { + return substitute(bounds.iterator().next()); + } + + return typeParameter.getTypeProvider().createJavaLangObjectType(); } @Override @Nullable public JavaType substitute(@NotNull JavaTypeParameter typeParameter) { - PsiType psiType = psiSubstitutor.substitute(((JavaTypeParameterImpl) typeParameter).getPsi()); - return psiType == null ? null : JavaTypeImpl.create(psiType); + if (substitutionMap.containsKey(typeParameter)) { + return substitutionMap.get(typeParameter); + } + + return typeParameter.getType(); } @Override @NotNull public Map getSubstitutionMap() { - if (substitutionMap == null) { - Map psiMap = psiSubstitutor.getSubstitutionMap(); - substitutionMap = new HashMap(); - for (Map.Entry entry : psiMap.entrySet()) { - PsiType value = entry.getValue(); - substitutionMap.put(new JavaTypeParameterImpl(entry.getKey()), value == null ? null : JavaTypeImpl.create(value)); - } - } - return substitutionMap; } @Override public int hashCode() { - return psiSubstitutor.hashCode(); + return substitutionMap.hashCode(); } @Override public boolean equals(Object obj) { - return obj instanceof JavaTypeSubstitutorImpl && psiSubstitutor.equals(((JavaTypeSubstitutorImpl) obj).psiSubstitutor); + return obj instanceof JavaTypeSubstitutorImpl && substitutionMap.equals(((JavaTypeSubstitutorImpl) obj).substitutionMap); } @Override public String toString() { - return getClass().getSimpleName() + ": " + psiSubstitutor; + return getClass().getSimpleName() + ": " + substitutionMap; } -} +} \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaClass.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaClass.java index 99cb3b5107d..e5f50dd853c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaClass.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaClass.java @@ -62,6 +62,9 @@ public interface JavaClass extends JavaClassifier, JavaTypeParameterListOwner, J @NotNull OriginKind getOriginKind(); + @NotNull + JavaType createImmediateType(@NotNull JavaTypeSubstitutor substitutor); + enum OriginKind { COMPILED, SOURCE, diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaTypeProvider.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaTypeProvider.java index e29fbd2ea5e..b1d63f7e68a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaTypeProvider.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaTypeProvider.java @@ -21,4 +21,13 @@ import org.jetbrains.annotations.NotNull; public interface JavaTypeProvider { @NotNull JavaType createJavaLangObjectType(); + + @NotNull + JavaWildcardType createUpperBoundWildcard(@NotNull JavaType bound); + + @NotNull + JavaWildcardType createLowerBoundWildcard(@NotNull JavaType bound); + + @NotNull + JavaWildcardType createUnboundedWildcard(); } diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 20f8e5867ca..835a0d55f15 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -115,6 +115,7 @@ import org.jetbrains.jet.plugin.structureView.AbstractKotlinFileStructureTest import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterTest import org.jetbrains.jet.jps.build.AbstractIncrementalJpsTest import org.jetbrains.jet.asJava.AbstractKotlinLightClassTest +import org.jetbrains.jet.lang.resolve.java.AbstractJavaTypeSubstitutorTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -271,6 +272,11 @@ fun main(args: Array) { } testGroup("idea/tests", "idea/testData") { + + testClass(javaClass()) { + model("typeSubstitution", extension = "java") + } + testClass(javaClass()) { model("resolve/additionalLazyResolve", testMethod = "doTest") } diff --git a/idea/testData/typeSubstitution/arrayType.java b/idea/testData/typeSubstitution/arrayType.java new file mode 100644 index 00000000000..63c786d0e79 --- /dev/null +++ b/idea/testData/typeSubstitution/arrayType.java @@ -0,0 +1,8 @@ +interface arrayType { + interface SuperArray { + T[] typeForSubstitute(); + } + + interface MidArray extends SuperArray { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/classType.java b/idea/testData/typeSubstitution/classType.java new file mode 100644 index 00000000000..57fd4b9587d --- /dev/null +++ b/idea/testData/typeSubstitution/classType.java @@ -0,0 +1,8 @@ +interface classType { + interface SuperClass { + List typeForSubstitute(); + } + + interface MidClass extends SuperClass { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/classWithWildcard.java b/idea/testData/typeSubstitution/classWithWildcard.java new file mode 100644 index 00000000000..68e6a144c43 --- /dev/null +++ b/idea/testData/typeSubstitution/classWithWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface classWithWildcard { + interface SuperList { + List typeForSubstitute(); + } + + interface MidList extends SuperList> { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/genericArray.java b/idea/testData/typeSubstitution/genericArray.java new file mode 100644 index 00000000000..6840d9b0f05 --- /dev/null +++ b/idea/testData/typeSubstitution/genericArray.java @@ -0,0 +1,8 @@ +interface genericArray { + interface SuperGenericArray { + T typeForSubstitute(); + } + + interface MidGenericArray extends SuperGenericArray { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/innerParameter.java b/idea/testData/typeSubstitution/innerParameter.java new file mode 100644 index 00000000000..bd9050093ed --- /dev/null +++ b/idea/testData/typeSubstitution/innerParameter.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface innerParameter { + interface SuperInnerParam { + T typeForSubstitute(); + } + + interface MidInnerParam extends SuperInnerParam { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/intersectionType.java b/idea/testData/typeSubstitution/intersectionType.java new file mode 100644 index 00000000000..4aeaa7c401c --- /dev/null +++ b/idea/testData/typeSubstitution/intersectionType.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface intersectionType { + interface SuperIntersection { + & List> R typeForSubstitute(); + } + + interface MidIntersection extends SuperIntersection { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/intersectionTypeAsTypeParameter.java b/idea/testData/typeSubstitution/intersectionTypeAsTypeParameter.java new file mode 100644 index 00000000000..0a6e5912019 --- /dev/null +++ b/idea/testData/typeSubstitution/intersectionTypeAsTypeParameter.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface intersectionTypeAsTypeParameter { + interface Super { + & List> Map typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/intersectionTypeInEnum.java b/idea/testData/typeSubstitution/intersectionTypeInEnum.java new file mode 100644 index 00000000000..c4f005ce501 --- /dev/null +++ b/idea/testData/typeSubstitution/intersectionTypeInEnum.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface intersectionTypeInEnum { + interface Super { + & List> Enum typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/intersectionTypeInInterfaceDeclaration.java b/idea/testData/typeSubstitution/intersectionTypeInInterfaceDeclaration.java new file mode 100644 index 00000000000..d3984b60dd1 --- /dev/null +++ b/idea/testData/typeSubstitution/intersectionTypeInInterfaceDeclaration.java @@ -0,0 +1,8 @@ +interface intersectionTypeInInterfaceDeclaration { + interface SuperIntersection { + T typeForSubstitute(); + } + + interface MidIntersection extends SuperIntersection { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/intersectionTypeInTypeVariableClass.java b/idea/testData/typeSubstitution/intersectionTypeInTypeVariableClass.java new file mode 100644 index 00000000000..eb6bffbb236 --- /dev/null +++ b/idea/testData/typeSubstitution/intersectionTypeInTypeVariableClass.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface intersectionTypeInTypeVariableClass { + interface Super { + & List> TypeVariable typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/mapEntry.java b/idea/testData/typeSubstitution/mapEntry.java new file mode 100644 index 00000000000..ee711c4596e --- /dev/null +++ b/idea/testData/typeSubstitution/mapEntry.java @@ -0,0 +1,10 @@ +import java.util.Map; + +interface mapEntry { + interface Super { + Map.Entry typeForSubstitute(); + } + + interface Mid extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/primitiveType.java b/idea/testData/typeSubstitution/primitiveType.java new file mode 100644 index 00000000000..e28c8a1808f --- /dev/null +++ b/idea/testData/typeSubstitution/primitiveType.java @@ -0,0 +1,8 @@ +interface primitiveType { + interface SuperPrimitive { + int typeForSubstitute(); + } + + interface MidPrimitive extends SuperPrimitive { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawArrayType.java b/idea/testData/typeSubstitution/rawArrayType.java new file mode 100644 index 00000000000..18bc5e67a5c --- /dev/null +++ b/idea/testData/typeSubstitution/rawArrayType.java @@ -0,0 +1,8 @@ +interface rawArrayType { + interface SuperArray { + T[] typeForSubstitute(); + } + + interface MidArray extends SuperArray { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawArrayTypeParameterWithBound.java b/idea/testData/typeSubstitution/rawArrayTypeParameterWithBound.java new file mode 100644 index 00000000000..3c97bffd13c --- /dev/null +++ b/idea/testData/typeSubstitution/rawArrayTypeParameterWithBound.java @@ -0,0 +1,8 @@ +interface rawArrayTypeParameterWithBound { + interface Super { + T[] typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawEnum.java b/idea/testData/typeSubstitution/rawEnum.java new file mode 100644 index 00000000000..2320cbd9070 --- /dev/null +++ b/idea/testData/typeSubstitution/rawEnum.java @@ -0,0 +1,8 @@ +interface rawEnum { + interface Super> { + Enum typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawExtendsWildcard.java b/idea/testData/typeSubstitution/rawExtendsWildcard.java new file mode 100644 index 00000000000..026c9229551 --- /dev/null +++ b/idea/testData/typeSubstitution/rawExtendsWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface rawExtendsWildcard { + interface SuperRawWild { + List typeForSubstitute(); + } + + interface MidRawWildcard extends SuperRawWild { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawIntersectionType.java b/idea/testData/typeSubstitution/rawIntersectionType.java new file mode 100644 index 00000000000..3a568159dcb --- /dev/null +++ b/idea/testData/typeSubstitution/rawIntersectionType.java @@ -0,0 +1,8 @@ +interface rawIntersectionType { + interface Super { + T typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawSuperWildcard.java b/idea/testData/typeSubstitution/rawSuperWildcard.java new file mode 100644 index 00000000000..85fb61c8943 --- /dev/null +++ b/idea/testData/typeSubstitution/rawSuperWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface rawSuperWildcard { + interface SuperRawWild { + List typeForSubstitute(); + } + + interface MidRawWildcard extends SuperRawWild { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawType.java b/idea/testData/typeSubstitution/rawType.java new file mode 100644 index 00000000000..f928f813758 --- /dev/null +++ b/idea/testData/typeSubstitution/rawType.java @@ -0,0 +1,8 @@ +interface rawType { + interface Super { + T typeForSubstitute(); + } + + interface MidRaw extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawTypeInDeclaration.java b/idea/testData/typeSubstitution/rawTypeInDeclaration.java new file mode 100644 index 00000000000..e912477d946 --- /dev/null +++ b/idea/testData/typeSubstitution/rawTypeInDeclaration.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface rawTypeInDeclaration { + interface Super { + List typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawTypeWithBound.java b/idea/testData/typeSubstitution/rawTypeWithBound.java new file mode 100644 index 00000000000..e96a9e36bf4 --- /dev/null +++ b/idea/testData/typeSubstitution/rawTypeWithBound.java @@ -0,0 +1,8 @@ +interface rawTypeWithBound { + interface Super { + T typeForSubstitute(); + } + + interface MidRaw extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawTypeWithSelfReferenceBound.java b/idea/testData/typeSubstitution/rawTypeWithSelfReferenceBound.java new file mode 100644 index 00000000000..e8375c373e8 --- /dev/null +++ b/idea/testData/typeSubstitution/rawTypeWithSelfReferenceBound.java @@ -0,0 +1,8 @@ +interface rawTypeWithSelfReferenceBound { + interface Super> { + T typeForSubstitute(); + } + + interface MidRaw extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawWildcardInTypeVariableClass.java b/idea/testData/typeSubstitution/rawWildcardInTypeVariableClass.java new file mode 100644 index 00000000000..6d4c7a75042 --- /dev/null +++ b/idea/testData/typeSubstitution/rawWildcardInTypeVariableClass.java @@ -0,0 +1,10 @@ +import java.lang.reflect.TypeVariable; + +interface rawWildcardInTypeVariableClass { + interface Super { + TypeVariable typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/rawWildcardWithBound.java b/idea/testData/typeSubstitution/rawWildcardWithBound.java new file mode 100644 index 00000000000..fba6ef0157a --- /dev/null +++ b/idea/testData/typeSubstitution/rawWildcardWithBound.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface rawWildcardWithBound { + interface Super { + List typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/selfReference.java b/idea/testData/typeSubstitution/selfReference.java new file mode 100644 index 00000000000..c6958f1e916 --- /dev/null +++ b/idea/testData/typeSubstitution/selfReference.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface selfReference { + interface SuperSelfRef> { + public List typeForSubstitute(); + } + + interface MidSelfRef extends SuperSelfRef { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/twoParameters.java b/idea/testData/typeSubstitution/twoParameters.java new file mode 100644 index 00000000000..d4508cd37d5 --- /dev/null +++ b/idea/testData/typeSubstitution/twoParameters.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface twoParameters { + interface SuperTwoParams { + Map> typeForSubstitute(); + } + + interface MidTwoParams extends SuperTwoParams { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/twoParametersInSubClass.java b/idea/testData/typeSubstitution/twoParametersInSubClass.java new file mode 100644 index 00000000000..579cbfc3b8a --- /dev/null +++ b/idea/testData/typeSubstitution/twoParametersInSubClass.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface twoParametersInSubClass { + interface SuperTwoParams { + List typeForSubstitute(); + } + + interface MidTwoParams extends SuperTwoParams { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/typeVariableClass.java b/idea/testData/typeSubstitution/typeVariableClass.java new file mode 100644 index 00000000000..b738ab5e1b3 --- /dev/null +++ b/idea/testData/typeSubstitution/typeVariableClass.java @@ -0,0 +1,10 @@ +import java.lang.reflect.TypeVariable; + +interface typeVariableClass { + interface Super { + TypeVariable typeForSubstitute(); + } + + interface Mid extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/typeVariableRaw.java b/idea/testData/typeSubstitution/typeVariableRaw.java new file mode 100644 index 00000000000..37464247d2c --- /dev/null +++ b/idea/testData/typeSubstitution/typeVariableRaw.java @@ -0,0 +1,10 @@ +import java.lang.reflect.TypeVariable; + +interface typeVariableRaw { + interface Super { + TypeVariable typeForSubstitute(); + } + + interface Mid extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/unboundedWildcard.java b/idea/testData/typeSubstitution/unboundedWildcard.java new file mode 100644 index 00000000000..232230bf9d4 --- /dev/null +++ b/idea/testData/typeSubstitution/unboundedWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface unboundedWildcard { + interface Super { + List typeForSubstitute(); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/unboundedWildcardToTypeParameter.java b/idea/testData/typeSubstitution/unboundedWildcardToTypeParameter.java new file mode 100644 index 00000000000..981d5adf796 --- /dev/null +++ b/idea/testData/typeSubstitution/unboundedWildcardToTypeParameter.java @@ -0,0 +1,8 @@ +import java.util.*; + +interface unboundedWildcardToTypeParameter { + interface SupList extends List { + @Override + boolean retainAll(Collection c); // error, check that we do not fall + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargArray.java b/idea/testData/typeSubstitution/varargArray.java new file mode 100644 index 00000000000..853db136a2c --- /dev/null +++ b/idea/testData/typeSubstitution/varargArray.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargArray { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargArrayTypeParameter.java b/idea/testData/typeSubstitution/varargArrayTypeParameter.java new file mode 100644 index 00000000000..0343a15100c --- /dev/null +++ b/idea/testData/typeSubstitution/varargArrayTypeParameter.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargArrayTypeParameter { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargClass.java b/idea/testData/typeSubstitution/varargClass.java new file mode 100644 index 00000000000..371b6d1226e --- /dev/null +++ b/idea/testData/typeSubstitution/varargClass.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargClass { + interface Super { + void typeForSubstitute(List... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargClassWithWildcard.java b/idea/testData/typeSubstitution/varargClassWithWildcard.java new file mode 100644 index 00000000000..3aa87dfda7d --- /dev/null +++ b/idea/testData/typeSubstitution/varargClassWithWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargClassWithWildcard { + interface Super { + void typeForSubstitute(List... a); + } + + interface Sub extends Super> { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargRawType.java b/idea/testData/typeSubstitution/varargRawType.java new file mode 100644 index 00000000000..78a6b2515b2 --- /dev/null +++ b/idea/testData/typeSubstitution/varargRawType.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargRawType { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargRawTypeWithBound.java b/idea/testData/typeSubstitution/varargRawTypeWithBound.java new file mode 100644 index 00000000000..cc7f8e8fb8b --- /dev/null +++ b/idea/testData/typeSubstitution/varargRawTypeWithBound.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargRawTypeWithBound { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargToClass.java b/idea/testData/typeSubstitution/varargToClass.java new file mode 100644 index 00000000000..7132de49e80 --- /dev/null +++ b/idea/testData/typeSubstitution/varargToClass.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargToClass { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/varargToClassWithWildcard.java b/idea/testData/typeSubstitution/varargToClassWithWildcard.java new file mode 100644 index 00000000000..93dc3b520af --- /dev/null +++ b/idea/testData/typeSubstitution/varargToClassWithWildcard.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface varargToClassWithWildcard { + interface Super { + void typeForSubstitute(T... a); + } + + interface Sub extends Super> { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/wildcardExtends.java b/idea/testData/typeSubstitution/wildcardExtends.java new file mode 100644 index 00000000000..721942f6376 --- /dev/null +++ b/idea/testData/typeSubstitution/wildcardExtends.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface wildcardExtends { + interface SuperWildcardExtends { + List typeForSubstitute(); + } + + interface MidWildcardExtends extends SuperWildcardExtends { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/wildcardExtendsObject.java b/idea/testData/typeSubstitution/wildcardExtendsObject.java new file mode 100644 index 00000000000..40e18ca5a83 --- /dev/null +++ b/idea/testData/typeSubstitution/wildcardExtendsObject.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface wildcardExtendsObject { + interface SuperWildcardExtendsObject { + List typeForSubstitute(); + } + + interface MidWildcardExtendsObject extends SuperWildcardExtendsObject { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/wildcardExtendsTypeParameter.java b/idea/testData/typeSubstitution/wildcardExtendsTypeParameter.java new file mode 100644 index 00000000000..d62939b11f3 --- /dev/null +++ b/idea/testData/typeSubstitution/wildcardExtendsTypeParameter.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface wildcardExtendsTypeParameter { + interface SuperWildcard { + Map typeForSubstitute(); + } + + interface MidWildcard extends SuperWildcard { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/wildcardSuper.java b/idea/testData/typeSubstitution/wildcardSuper.java new file mode 100644 index 00000000000..b1342fb7f1f --- /dev/null +++ b/idea/testData/typeSubstitution/wildcardSuper.java @@ -0,0 +1,10 @@ +import java.util.*; + +interface wildcardSuper { + interface SuperWildcardSuper { + List typeForSubstitute(); + } + + interface MidWildcardSuper extends SuperWildcardSuper { + } +} \ No newline at end of file diff --git a/idea/testData/typeSubstitution/wildcardToWildcard.java b/idea/testData/typeSubstitution/wildcardToWildcard.java new file mode 100644 index 00000000000..d52b18dd53c --- /dev/null +++ b/idea/testData/typeSubstitution/wildcardToWildcard.java @@ -0,0 +1,8 @@ +import java.util.*; + +interface wildcardToWildcard { + interface SupList extends List { + @Override + boolean addAll(Collection c); + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/lang/resolve/java/AbstractJavaTypeSubstitutorTest.java b/idea/tests/org/jetbrains/jet/lang/resolve/java/AbstractJavaTypeSubstitutorTest.java new file mode 100644 index 00000000000..fb0dffc21ef --- /dev/null +++ b/idea/tests/org/jetbrains/jet/lang/resolve/java/AbstractJavaTypeSubstitutorTest.java @@ -0,0 +1,115 @@ +/* + * Copyright 2010-2014 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.jet.lang.resolve.java; + +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.LightProjectDescriptor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.resolve.java.structure.JavaClassifierType; +import org.jetbrains.jet.lang.resolve.java.structure.JavaType; +import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeParameter; +import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaTypeImpl; +import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaTypeParameterImpl; +import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase; +import org.jetbrains.jet.plugin.JetLightProjectDescriptor; + +public abstract class AbstractJavaTypeSubstitutorTest extends JetLightCodeInsightFixtureTestCase { + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JetLightProjectDescriptor.INSTANCE; + } + + public void doTest(@NotNull String testFile) { + PsiFile psiFile = myFixture.configureByFile(testFile); + + Project project = myFixture.getProject(); + String javaClassName = psiFile.getName().substring(0, psiFile.getName().length() - ".java".length()); + PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(javaClassName, GlobalSearchScope.allScope(project)); + assert psiClass != null : "Wrong path to test file: " + testFile; + + assert psiClass.getInnerClasses().length > 0; + + for (PsiClass innerInterface : psiClass.getInnerClasses()) { + PsiMethod method = getMethodWithTestData(innerInterface); + + PsiClassType[] superTypes = innerInterface.getSuperTypes(); + for (PsiClassType superType : superTypes) { + if (method.getReturnType() != null) { + doTest(superType, method.getReturnType()); + } + if (method.getTypeParameters().length > 0) { + doTest(superType, method.getTypeParameters()[0]); + } + PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameters.length > 0) { + doTest(superType, parameters[0].getType()); + } + } + } + } + + private static void doTest(@NotNull PsiClassType type, @NotNull PsiTypeParameter typeParameter) { + PsiType expectedType = type.resolveGenerics().getSubstitutor().substitute(typeParameter); + + JavaClassifierType javaClassifierType = (JavaClassifierType) JavaTypeImpl.create(type); + JavaTypeParameter javaTypeToSubstitute = new JavaTypeParameterImpl(typeParameter); + JavaType actualType = javaClassifierType.getSubstitutor().substitute(javaTypeToSubstitute); + + if (actualType == null) { + assertEquals(expectedType, null); + } + else { + assertEquals(expectedType, ((JavaTypeImpl) actualType).getPsi()); + } + } + + private static void doTest(@NotNull PsiClassType type, @NotNull PsiType psiTypeToSubstitute) { + PsiType expectedType = type.resolveGenerics().getSubstitutor().substitute(psiTypeToSubstitute); + + JavaClassifierType javaClassifierType = (JavaClassifierType) JavaTypeImpl.create(type); + JavaType javaTypeToSubstitute = JavaTypeImpl.create(psiTypeToSubstitute); + JavaType actualType = javaClassifierType.getSubstitutor().substitute(javaTypeToSubstitute); + + if (expectedType instanceof PsiEllipsisType) { + PsiEllipsisType ellipsisType = (PsiEllipsisType) expectedType; + assertEquals(ellipsisType.toArrayType(), ((JavaTypeImpl) actualType).getPsi()); + } + else { + assertEquals(expectedType, ((JavaTypeImpl) actualType).getPsi()); + } + } + + @NotNull + private static PsiMethod getMethodWithTestData(@NotNull PsiClass psiClass) { + String substituteParameterName = "typeForSubstitute"; + PsiMethod[] methods = psiClass.findMethodsByName(substituteParameterName, false); + if (methods.length == 0) { + methods = psiClass.findMethodsByName(substituteParameterName, true); + } + + if (methods.length == 0) { + methods = psiClass.getMethods(); + } + + assert methods.length > 0 : "Wrong parameters for test: method typeForSubstitute not found"; + + return methods[0]; + } +} diff --git a/idea/tests/org/jetbrains/jet/lang/resolve/java/JavaTypeSubstitutorTestGenerated.java b/idea/tests/org/jetbrains/jet/lang/resolve/java/JavaTypeSubstitutorTestGenerated.java new file mode 100644 index 00000000000..0e101962a12 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/lang/resolve/java/JavaTypeSubstitutorTestGenerated.java @@ -0,0 +1,259 @@ +/* + * Copyright 2010-2014 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.jet.lang.resolve.java; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.lang.resolve.java.AbstractJavaTypeSubstitutorTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/typeSubstitution") +public class JavaTypeSubstitutorTestGenerated extends AbstractJavaTypeSubstitutorTest { + public void testAllFilesPresentInTypeSubstitution() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/typeSubstitution"), Pattern.compile("^(.+)\\.java$"), true); + } + + @TestMetadata("arrayType.java") + public void testArrayType() throws Exception { + doTest("idea/testData/typeSubstitution/arrayType.java"); + } + + @TestMetadata("classType.java") + public void testClassType() throws Exception { + doTest("idea/testData/typeSubstitution/classType.java"); + } + + @TestMetadata("classWithWildcard.java") + public void testClassWithWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/classWithWildcard.java"); + } + + @TestMetadata("genericArray.java") + public void testGenericArray() throws Exception { + doTest("idea/testData/typeSubstitution/genericArray.java"); + } + + @TestMetadata("innerParameter.java") + public void testInnerParameter() throws Exception { + doTest("idea/testData/typeSubstitution/innerParameter.java"); + } + + @TestMetadata("intersectionType.java") + public void testIntersectionType() throws Exception { + doTest("idea/testData/typeSubstitution/intersectionType.java"); + } + + @TestMetadata("intersectionTypeAsTypeParameter.java") + public void testIntersectionTypeAsTypeParameter() throws Exception { + doTest("idea/testData/typeSubstitution/intersectionTypeAsTypeParameter.java"); + } + + @TestMetadata("intersectionTypeInEnum.java") + public void testIntersectionTypeInEnum() throws Exception { + doTest("idea/testData/typeSubstitution/intersectionTypeInEnum.java"); + } + + @TestMetadata("intersectionTypeInInterfaceDeclaration.java") + public void testIntersectionTypeInInterfaceDeclaration() throws Exception { + doTest("idea/testData/typeSubstitution/intersectionTypeInInterfaceDeclaration.java"); + } + + @TestMetadata("intersectionTypeInTypeVariableClass.java") + public void testIntersectionTypeInTypeVariableClass() throws Exception { + doTest("idea/testData/typeSubstitution/intersectionTypeInTypeVariableClass.java"); + } + + @TestMetadata("mapEntry.java") + public void testMapEntry() throws Exception { + doTest("idea/testData/typeSubstitution/mapEntry.java"); + } + + @TestMetadata("primitiveType.java") + public void testPrimitiveType() throws Exception { + doTest("idea/testData/typeSubstitution/primitiveType.java"); + } + + @TestMetadata("rawArrayType.java") + public void testRawArrayType() throws Exception { + doTest("idea/testData/typeSubstitution/rawArrayType.java"); + } + + @TestMetadata("rawArrayTypeParameterWithBound.java") + public void testRawArrayTypeParameterWithBound() throws Exception { + doTest("idea/testData/typeSubstitution/rawArrayTypeParameterWithBound.java"); + } + + @TestMetadata("rawEnum.java") + public void testRawEnum() throws Exception { + doTest("idea/testData/typeSubstitution/rawEnum.java"); + } + + @TestMetadata("rawExtendsWildcard.java") + public void testRawExtendsWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/rawExtendsWildcard.java"); + } + + @TestMetadata("rawIntersectionType.java") + public void testRawIntersectionType() throws Exception { + doTest("idea/testData/typeSubstitution/rawIntersectionType.java"); + } + + @TestMetadata("rawSuperWildcard.java") + public void testRawSuperWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/rawSuperWildcard.java"); + } + + @TestMetadata("rawType.java") + public void testRawType() throws Exception { + doTest("idea/testData/typeSubstitution/rawType.java"); + } + + @TestMetadata("rawTypeInDeclaration.java") + public void testRawTypeInDeclaration() throws Exception { + doTest("idea/testData/typeSubstitution/rawTypeInDeclaration.java"); + } + + @TestMetadata("rawTypeWithBound.java") + public void testRawTypeWithBound() throws Exception { + doTest("idea/testData/typeSubstitution/rawTypeWithBound.java"); + } + + @TestMetadata("rawTypeWithSelfReferenceBound.java") + public void testRawTypeWithSelfReferenceBound() throws Exception { + doTest("idea/testData/typeSubstitution/rawTypeWithSelfReferenceBound.java"); + } + + @TestMetadata("rawWildcardInTypeVariableClass.java") + public void testRawWildcardInTypeVariableClass() throws Exception { + doTest("idea/testData/typeSubstitution/rawWildcardInTypeVariableClass.java"); + } + + @TestMetadata("rawWildcardWithBound.java") + public void testRawWildcardWithBound() throws Exception { + doTest("idea/testData/typeSubstitution/rawWildcardWithBound.java"); + } + + @TestMetadata("selfReference.java") + public void testSelfReference() throws Exception { + doTest("idea/testData/typeSubstitution/selfReference.java"); + } + + @TestMetadata("twoParameters.java") + public void testTwoParameters() throws Exception { + doTest("idea/testData/typeSubstitution/twoParameters.java"); + } + + @TestMetadata("twoParametersInSubClass.java") + public void testTwoParametersInSubClass() throws Exception { + doTest("idea/testData/typeSubstitution/twoParametersInSubClass.java"); + } + + @TestMetadata("typeVariableClass.java") + public void testTypeVariableClass() throws Exception { + doTest("idea/testData/typeSubstitution/typeVariableClass.java"); + } + + @TestMetadata("typeVariableRaw.java") + public void testTypeVariableRaw() throws Exception { + doTest("idea/testData/typeSubstitution/typeVariableRaw.java"); + } + + @TestMetadata("unboundedWildcard.java") + public void testUnboundedWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/unboundedWildcard.java"); + } + + @TestMetadata("unboundedWildcardToTypeParameter.java") + public void testUnboundedWildcardToTypeParameter() throws Exception { + doTest("idea/testData/typeSubstitution/unboundedWildcardToTypeParameter.java"); + } + + @TestMetadata("varargArray.java") + public void testVarargArray() throws Exception { + doTest("idea/testData/typeSubstitution/varargArray.java"); + } + + @TestMetadata("varargArrayTypeParameter.java") + public void testVarargArrayTypeParameter() throws Exception { + doTest("idea/testData/typeSubstitution/varargArrayTypeParameter.java"); + } + + @TestMetadata("varargClass.java") + public void testVarargClass() throws Exception { + doTest("idea/testData/typeSubstitution/varargClass.java"); + } + + @TestMetadata("varargClassWithWildcard.java") + public void testVarargClassWithWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/varargClassWithWildcard.java"); + } + + @TestMetadata("varargRawType.java") + public void testVarargRawType() throws Exception { + doTest("idea/testData/typeSubstitution/varargRawType.java"); + } + + @TestMetadata("varargRawTypeWithBound.java") + public void testVarargRawTypeWithBound() throws Exception { + doTest("idea/testData/typeSubstitution/varargRawTypeWithBound.java"); + } + + @TestMetadata("varargToClass.java") + public void testVarargToClass() throws Exception { + doTest("idea/testData/typeSubstitution/varargToClass.java"); + } + + @TestMetadata("varargToClassWithWildcard.java") + public void testVarargToClassWithWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/varargToClassWithWildcard.java"); + } + + @TestMetadata("wildcardExtends.java") + public void testWildcardExtends() throws Exception { + doTest("idea/testData/typeSubstitution/wildcardExtends.java"); + } + + @TestMetadata("wildcardExtendsObject.java") + public void testWildcardExtendsObject() throws Exception { + doTest("idea/testData/typeSubstitution/wildcardExtendsObject.java"); + } + + @TestMetadata("wildcardExtendsTypeParameter.java") + public void testWildcardExtendsTypeParameter() throws Exception { + doTest("idea/testData/typeSubstitution/wildcardExtendsTypeParameter.java"); + } + + @TestMetadata("wildcardSuper.java") + public void testWildcardSuper() throws Exception { + doTest("idea/testData/typeSubstitution/wildcardSuper.java"); + } + + @TestMetadata("wildcardToWildcard.java") + public void testWildcardToWildcard() throws Exception { + doTest("idea/testData/typeSubstitution/wildcardToWildcard.java"); + } + +}