Add frontend checks for missing dependency supertypes
Call checker and declaration checker are used in order to preserve backward compatibility. Attempt to use classifier usage checker was not good enouth, since not all errors found with it would actually be reported before. For example types and constructor calls don't cause supertypes to resolve, so missing supertypes would not lead to errors in case they are the only use of class name. Updated tests failing due to missing Java dependencies in superclasses.
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public class Sub extends Super {
|
||||
public String resolved() {
|
||||
return "Sub";
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public class Super {
|
||||
String unresolved() {
|
||||
return "Super";
|
||||
}
|
||||
}
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
|
||||
class test.Sub, unresolved supertypes: test.Super
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
class SubSub : Sub()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:4:14: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
class Client<T : Sub>(val prop: T)
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:5:6: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
fun <T : Sub> withTypeParam() {}
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:12:11: error: unresolved reference: unresolved
|
||||
Sub().unresolved()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:12:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
Sub().unresolved()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:13:14: error: unresolved reference: unresolved
|
||||
SubSub().unresolved()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:13:14: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
SubSub().unresolved()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:14:15: error: cannot access 'test.Super' which is a supertype of 'test.<no name provided>'. Check your module classpath for missing or conflicting dependencies
|
||||
val obj = object : Sub() {}
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:15:25: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
withCallRefArg(Sub::resolved)
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:16:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
Sub().resolved()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyErrorPositions/source.kt:17:11: error: cannot access 'test.Super' which is a supertype of 'test.Sub'. Check your module classpath for missing or conflicting dependencies
|
||||
Sub().extension()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import test.Sub;
|
||||
|
||||
class SubSub : Sub()
|
||||
class Client<T : Sub>(val prop: T)
|
||||
fun <T : Sub> withTypeParam() {}
|
||||
|
||||
fun withCallRefArg(arg: Sub.() -> String) {}
|
||||
|
||||
fun Sub.extension() {}
|
||||
|
||||
fun test() {
|
||||
Sub().unresolved()
|
||||
SubSub().unresolved()
|
||||
val obj = object : Sub() {}
|
||||
withCallRefArg(Sub::resolved)
|
||||
Sub().resolved()
|
||||
Sub().extension()
|
||||
}
|
||||
+6
@@ -1,7 +1,13 @@
|
||||
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
|
||||
class test.Sub, unresolved supertypes: test.Super
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
class SubSub : Sub()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:5:22: error: unresolved reference: foo
|
||||
fun bar() = SubSub().foo()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInJava/source.kt:5:22: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
fun bar() = SubSub().foo()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
Vendored
+6
@@ -1,7 +1,13 @@
|
||||
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
|
||||
class test.Sub, unresolved supertypes: test.Super
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:3:1: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
class SubSub : Sub()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:5:22: error: unresolved reference: foo
|
||||
fun bar() = SubSub().foo()
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyInKotlin/source.kt:5:22: error: cannot access 'test.Super' which is a supertype of 'SubSub'. Check your module classpath for missing or conflicting dependencies
|
||||
fun bar() = SubSub().foo()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package test;
|
||||
|
||||
public interface A { }
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public class B implements A {
|
||||
public static Object n() { return null; }
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
|
||||
class test.B, unresolved supertypes: test.A
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyMissingInterface/source.kt:5:15: error: cannot access 'test.A' which is a supertype of 'test.B'. Check your module classpath for missing or conflicting dependencies
|
||||
D.m(B.n())
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import test.*
|
||||
|
||||
public class C {
|
||||
fun test() {
|
||||
D.m(B.n())
|
||||
}
|
||||
}
|
||||
|
||||
public class D {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun m(o: Any?) {}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public class Sub extends Super {
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public class Super {
|
||||
String foo() {
|
||||
return "Super";
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import test.Sub as MySub;
|
||||
|
||||
typealias Sub = MySub
|
||||
|
||||
class Test<T>
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun useCallRef(ref: Any?) {}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun simpleFun(arg: Sub): Sub = Sub()
|
||||
|
||||
inline fun <reified T> inlineFun(t: T) = t
|
||||
|
||||
// Imports, aliases type references, constructor calls and callable references don't trigger supertype resolution.
|
||||
// There should be no error for backward compatibility, despite the missing supertype.
|
||||
fun test() {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val x: Sub = Sub()
|
||||
Test<Sub>()
|
||||
useCallRef(::Sub)
|
||||
simpleFun(Sub())
|
||||
inlineFun<Sub>(Sub())
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
public open class Super
|
||||
|
||||
public class SubClass : Super() {
|
||||
inner class Inner
|
||||
class InnerStatic
|
||||
}
|
||||
|
||||
public object SubObject : Super() {
|
||||
class InnerStatic
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
|
||||
class test.SubClass, unresolved supertypes: test.Super
|
||||
class test.SubObject, unresolved supertypes: test.Super
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/incompleteHierarchyOfEnclosingClass/source.kt:6:16: error: cannot access 'test.Super' which is a supertype of 'test.SubClass'. Check your module classpath for missing or conflicting dependencies
|
||||
SubClass().Inner() // Error - dispatch receiver misses supertype
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import test.*
|
||||
import test.SubClass.InnerStatic as ClassInnerStatic // No error - does not force supertype resolution for SubClass
|
||||
import test.SubObject.InnerStatic // TODO report error - imports from object force resolution of its supertypes
|
||||
|
||||
fun test() {
|
||||
SubClass().Inner() // Error - dispatch receiver misses supertype
|
||||
SubClass.InnerStatic() // No error - does not force supertype resolution for SubClass
|
||||
SubObject.InnerStatic() // TODO report error - for objects supertypes are resolved here
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package test;
|
||||
|
||||
public class Sub extends Super {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public class Super {
|
||||
public static final int I = 0;
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
OK
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import test.Sub.*;
|
||||
|
||||
class Test
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test;
|
||||
|
||||
public class A {
|
||||
public A (C.D x) {}
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package test;
|
||||
|
||||
public class C {
|
||||
public static class D extends C {
|
||||
public D() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static int g() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static D makeD() {
|
||||
return new D();
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/missingStaticClass/source.kt:4:15: error: cannot access class 'test.C.D'. Check your module classpath for missing or conflicting dependencies
|
||||
val c = C.makeD()
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import test.*;
|
||||
|
||||
fun test() {
|
||||
val c = C.makeD()
|
||||
}
|
||||
Reference in New Issue
Block a user