Don't allow to call constructors of singletons
This fixes testKt2014
This commit is contained in:
+6
-2
@@ -72,9 +72,13 @@ public class CallableDescriptorCollectors {
|
|||||||
|
|
||||||
private static void addConstructors(JetScope scope, Name name, Collection<FunctionDescriptor> functions) {
|
private static void addConstructors(JetScope scope, Name name, Collection<FunctionDescriptor> functions) {
|
||||||
ClassifierDescriptor classifier = scope.getClassifier(name);
|
ClassifierDescriptor classifier = scope.getClassifier(name);
|
||||||
if (classifier instanceof ClassDescriptor && !ErrorUtils.isError(classifier)) {
|
if (!(classifier instanceof ClassDescriptor) || ErrorUtils.isError(classifier)) return;
|
||||||
functions.addAll(((ClassDescriptor) classifier).getConstructors());
|
ClassDescriptor classDescriptor = (ClassDescriptor) classifier;
|
||||||
|
if (classDescriptor.getKind().isSingleton()) {
|
||||||
|
// Constructors of singletons shouldn't be callable from the code
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
functions.addAll(classDescriptor.getConstructors());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user