JS frontend: added diagnostic about secondary constructors not supported yet.

This commit is contained in:
Zalim Bashorov
2015-03-20 12:28:01 +03:00
parent 9c88f9e744
commit d569ea5974
6 changed files with 54 additions and 0 deletions
@@ -37,6 +37,7 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by Delegates.lazy {
put(ErrorsJs.NOT_SUPPORTED, "Cannot translate (not supported yet): ''{0}''", RenderFirstLineOfElementText)
put(ErrorsJs.REFERENCE_TO_BUILTIN_MEMBERS_NOT_SUPPORTED, "Callable references for builtin members are not supported yet: ''{0}''", RenderFirstLineOfElementText)
put(ErrorsJs.NON_TOPLEVEL_CLASS_DECLARATION, "Non-toplevel {0} declarations not supported yet", Renderers.STRING)
put(ErrorsJs.SECONDARY_CONSTRUCTOR, "Secondary constructors not supported yet")
this
@@ -43,6 +43,7 @@ public interface ErrorsJs {
DiagnosticFactory1<JetElement, JetElement> NOT_SUPPORTED = DiagnosticFactory1.create(ERROR, DEFAULT);
DiagnosticFactory1<JetElement, JetElement> REFERENCE_TO_BUILTIN_MEMBERS_NOT_SUPPORTED = DiagnosticFactory1.create(ERROR, DEFAULT);
DiagnosticFactory1<JetNamedDeclaration, String> NON_TOPLEVEL_CLASS_DECLARATION = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
DiagnosticFactory0<JetNamedDeclaration> SECONDARY_CONSTRUCTOR = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
@SuppressWarnings("UnusedDeclaration")
Object _initializer = new Object() {
@@ -34,6 +34,12 @@ class ClassDeclarationChecker : DeclarationChecker {
if (declaration !is JetClassOrObject || declaration is JetObjectDeclaration || declaration is JetEnumEntry) return
if (declaration is JetClass) {
declaration.getSecondaryConstructors().forEach {
diagnosticHolder.report(ErrorsJs.SECONDARY_CONSTRUCTOR.on(it))
}
}
// hack to avoid to get diagnostics when compile kotlin builtins
val fqNameUnsafe = DescriptorUtils.getFqName(descriptor)
if (fqNameUnsafe.asString().startsWith("kotlin.")) return