Prohibit named parameters in function types in supertype position
This commit is contained in:
@@ -427,6 +427,17 @@ public class BodyResolver {
|
|||||||
JetTypeReference typeReference = entry.getKey();
|
JetTypeReference typeReference = entry.getKey();
|
||||||
JetType supertype = entry.getValue();
|
JetType supertype = entry.getValue();
|
||||||
|
|
||||||
|
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||||
|
if (typeElement instanceof JetFunctionType) {
|
||||||
|
for (JetParameter parameter : ((JetFunctionType) typeElement).getParameters()) {
|
||||||
|
PsiElement nameIdentifier = parameter.getNameIdentifier();
|
||||||
|
|
||||||
|
if (nameIdentifier != null) {
|
||||||
|
trace.report(Errors.UNSUPPORTED.on(nameIdentifier, "named parameter in function type in supertype position"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean addSupertype = true;
|
boolean addSupertype = true;
|
||||||
|
|
||||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ fun inParamNested(fn1: (fn2: (n: Int = <!UNSUPPORTED!>0<!>)->Unit)->Unit) {}
|
|||||||
|
|
||||||
fun inReturn(): (x: Int = <!UNSUPPORTED!>0<!>)->Unit = {}
|
fun inReturn(): (x: Int = <!UNSUPPORTED!>0<!>)->Unit = {}
|
||||||
|
|
||||||
class A : (x: Int = <!UNSUPPORTED!>0<!>)->Unit {
|
class A : (Int)->Unit {
|
||||||
override fun invoke(p1: Int) {
|
override fun invoke(p1: Int) {
|
||||||
var lambda: (x: Int = <!UNSUPPORTED!>0<!>)->Unit = {}
|
var lambda: (x: Int = <!UNSUPPORTED!>0<!>)->Unit = {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
abstract class A : Function1<Any, Unit>
|
||||||
|
|
||||||
|
abstract class B : (Int)->Unit
|
||||||
|
|
||||||
|
// Named parameter is prohibited because of possible inconsistency between
|
||||||
|
// type declaration and actual override
|
||||||
|
class C : (<!UNSUPPORTED!>x<!>: Int)->Unit {
|
||||||
|
override fun invoke(p1: Int): Unit {}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public abstract class A : (kotlin.Any) -> kotlin.Unit {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public abstract override /*1*/ /*fake_override*/ fun invoke(/*0*/ p1: kotlin.Any): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class B : (kotlin.Int) -> kotlin.Unit {
|
||||||
|
public constructor B()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public abstract override /*1*/ /*fake_override*/ fun invoke(/*0*/ p1: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class C : (kotlin.Int) -> kotlin.Unit {
|
||||||
|
public constructor C()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ fun invoke(/*0*/ p1: kotlin.Int): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
class A : (categoryName: <!SYNTAX!><!>)<!SYNTAX!><!> <!SYNTAX!><!>{<!SYNTAX!><!>
|
class A : (<!UNSUPPORTED!>categoryName<!>: <!SYNTAX!><!>)<!SYNTAX!><!> <!SYNTAX!><!>{<!SYNTAX!><!>
|
||||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package typeReferenceError
|
package typeReferenceError
|
||||||
|
|
||||||
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Pair<!><<!SYNTAX!><!>:(<!UNSUPPORTED!>val<!> c: <!SYNTAX!><!SYNTAX!><!>fun<!><!SYNTAX!><!> <!UNRESOLVED_REFERENCE!>main<!>()
|
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Pair<!><<!SYNTAX!><!>:(<!UNSUPPORTED!>val<!> <!UNSUPPORTED!>c<!>: <!SYNTAX!><!SYNTAX!><!>fun<!><!SYNTAX!><!> <!UNRESOLVED_REFERENCE!>main<!>()
|
||||||
+1
-1
@@ -10,7 +10,7 @@ fun inParamNested(fn1: (fn2: (<!UNSUPPORTED!>vararg<!> n: Int)->Unit)->Unit) {}
|
|||||||
|
|
||||||
fun inReturn(): (<!UNSUPPORTED!>vararg<!> x: Int)->Unit = {}
|
fun inReturn(): (<!UNSUPPORTED!>vararg<!> x: Int)->Unit = {}
|
||||||
|
|
||||||
class A : (<!UNSUPPORTED!>vararg<!> x: Int)->Unit {
|
class A : (<!UNSUPPORTED!>vararg<!> Int)->Unit {
|
||||||
override fun invoke(p1: Int) {
|
override fun invoke(p1: Int) {
|
||||||
var lambda: (<!UNSUPPORTED!>vararg<!> x: Int)->Unit = {}
|
var lambda: (<!UNSUPPORTED!>vararg<!> x: Int)->Unit = {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,6 +379,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||||
|
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/NamedFunctionTypeParameterInSupertype.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Nullability.kt")
|
@TestMetadata("Nullability.kt")
|
||||||
public void testNullability() throws Exception {
|
public void testNullability() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/Nullability.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/Nullability.kt");
|
||||||
|
|||||||
+2
-4
@@ -61,11 +61,9 @@ import org.jetbrains.kotlin.psi.psiUtil.isInsideOf
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.isPrivate
|
import org.jetbrains.kotlin.psi.psiUtil.isPrivate
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
import java.util.ArrayList
|
import java.util.*
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.HashSet
|
|
||||||
|
|
||||||
interface Mover: (originalElement: JetNamedDeclaration, targetFile: JetFile) -> JetNamedDeclaration {
|
interface Mover: (JetNamedDeclaration, JetFile) -> JetNamedDeclaration {
|
||||||
object Default: Mover {
|
object Default: Mover {
|
||||||
override fun invoke(originalElement: JetNamedDeclaration, targetFile: JetFile): JetNamedDeclaration {
|
override fun invoke(originalElement: JetNamedDeclaration, targetFile: JetFile): JetNamedDeclaration {
|
||||||
val newElement = targetFile.add(originalElement) as JetNamedDeclaration
|
val newElement = targetFile.add(originalElement) as JetNamedDeclaration
|
||||||
|
|||||||
Reference in New Issue
Block a user