Solution for EA-66870: Foo<in *> and Foo<out *> types are now treated as incorrect.
#EA-66870 Fixed.
This commit is contained in:
@@ -64,6 +64,11 @@ public class JetTypeProjection extends JetModifierListOwnerStub<KotlinTypeProjec
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ASTNode getProjectionNode() {
|
public ASTNode getProjectionNode() {
|
||||||
|
PsiElement star = findChildByType(JetTokens.MUL);
|
||||||
|
if (star != null) {
|
||||||
|
return star.getNode();
|
||||||
|
}
|
||||||
|
|
||||||
JetModifierList modifierList = getModifierList();
|
JetModifierList modifierList = getModifierList();
|
||||||
if (modifierList != null) {
|
if (modifierList != null) {
|
||||||
ASTNode node = modifierList.getModifierNode(JetTokens.IN_KEYWORD);
|
ASTNode node = modifierList.getModifierNode(JetTokens.IN_KEYWORD);
|
||||||
@@ -75,10 +80,6 @@ public class JetTypeProjection extends JetModifierListOwnerStub<KotlinTypeProjec
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PsiElement star = findChildByType(JetTokens.MUL);
|
|
||||||
if (star != null) {
|
|
||||||
return star.getNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve
|
package org.jetbrains.kotlin.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.context.TypeLazinessToken
|
import org.jetbrains.kotlin.context.TypeLazinessToken
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||||
@@ -24,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||||
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
|
import org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
|
||||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||||
@@ -272,6 +272,8 @@ public class TypeResolver(
|
|||||||
val projectionKind = argumentElement.getProjectionKind()
|
val projectionKind = argumentElement.getProjectionKind()
|
||||||
ModifiersChecker.checkIncompatibleVarianceModifiers(argumentElement.getModifierList(), c.trace)
|
ModifiersChecker.checkIncompatibleVarianceModifiers(argumentElement.getModifierList(), c.trace)
|
||||||
if (projectionKind == JetProjectionKind.STAR) {
|
if (projectionKind == JetProjectionKind.STAR) {
|
||||||
|
ModifiersChecker.reportIllegalModifiers(argumentElement.getModifierList(), listOf(JetTokens.IN_KEYWORD, JetTokens.OUT_KEYWORD), c.trace)
|
||||||
|
|
||||||
val parameters = constructor.getParameters()
|
val parameters = constructor.getParameters()
|
||||||
if (parameters.size() > i) {
|
if (parameters.size() > i) {
|
||||||
val parameterDescriptor = parameters[i]
|
val parameterDescriptor = parameters[i]
|
||||||
@@ -282,8 +284,7 @@ public class TypeResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO : handle the Foo<in *> case
|
val type = resolveType(c.noBareTypes(), argumentElement.getTypeReference()!!)
|
||||||
val type = resolveType(c.noBareTypes(), argumentElement.getTypeReference())
|
|
||||||
val kind = resolveProjectionKind(projectionKind)
|
val kind = resolveProjectionKind(projectionKind)
|
||||||
if (constructor.getParameters().size() > i) {
|
if (constructor.getParameters().size() > i) {
|
||||||
val parameterDescriptor = constructor.getParameters()[i]
|
val parameterDescriptor = constructor.getParameters()[i]
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Reproduces exception in TypeResolver.kt: EA-66870
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
abstract class J {
|
||||||
|
public abstract fun <T : Collection<S>, S : List<<!ILLEGAL_MODIFIER!>in<!> *>> foo(x: T)
|
||||||
|
fun bar() {
|
||||||
|
val s = ArrayList<ArrayList<Int>>()
|
||||||
|
foo(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal abstract class J {
|
||||||
|
public constructor J()
|
||||||
|
internal final fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract fun </*0*/ T : kotlin.Collection<S>, /*1*/ S : kotlin.List<*>> foo(/*0*/ x: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Reproduces exception in TypeResolver.kt: EA-66870
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
|
abstract class J {
|
||||||
|
public abstract fun <T : Collection<S>, S : List<<!ILLEGAL_MODIFIER!>out<!> *>> foo(x: T)
|
||||||
|
fun bar() {
|
||||||
|
val s = ArrayList<ArrayList<Int>>()
|
||||||
|
foo(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal abstract class J {
|
||||||
|
public constructor J()
|
||||||
|
internal final fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract fun </*0*/ T : kotlin.Collection<S>, /*1*/ S : kotlin.List<*>> foo(/*0*/ x: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
+12
@@ -35,6 +35,18 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("instar.kt")
|
||||||
|
public void testInstar() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/instar.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outstar.kt")
|
||||||
|
public void testOutstar() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/outstar.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations")
|
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user