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:
Pavel Kirpichenkov
2019-11-05 12:03:53 +03:00
parent 388cd53105
commit 8c52bb4212
49 changed files with 423 additions and 1373 deletions
@@ -0,0 +1,7 @@
package test;
public class Sub extends Super {
public String resolved() {
return "Sub";
}
}
@@ -0,0 +1,7 @@
package test;
public class Super {
String unresolved() {
return "Super";
}
}
@@ -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
@@ -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()
}