From b61ef125fcf0851518ed44dc3bd871c3792b755f Mon Sep 17 00:00:00 2001 From: Dave Holoway Date: Tue, 16 Jun 2020 18:01:32 +0100 Subject: [PATCH] don't report missing constructors if superclass has none --- langserver/java/validation/missing-constructor.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/langserver/java/validation/missing-constructor.js b/langserver/java/validation/missing-constructor.js index 005e51d..ce2211c 100644 --- a/langserver/java/validation/missing-constructor.js +++ b/langserver/java/validation/missing-constructor.js @@ -18,10 +18,12 @@ function checkConstructor(source_type, probs) { // - which means the inherited class is Object (and a default constructor exists) return; } - if (!superclass.constructors.find(c => c.parameterCount === 0)) { - // the source type has no declared constructors, but the superclass - // does not include a default (parameterless) constructor - probs.push(ParseProblem.Error(source_type.nameToken, `Class '${source_type.fullyDottedRawName}' requires a constructor to be declared because the inherited class '${superclass.fullyDottedRawName}' does not define a default constructor.`)); + if (superclass.constructors.length) { + if (!superclass.constructors.find(c => c.parameterCount === 0)) { + // the source type has no declared constructors, but the superclass + // does not include a default (parameterless) constructor + probs.push(ParseProblem.Error(source_type.nameToken, `Class '${source_type.fullyDottedRawName}' requires a constructor to be declared because the inherited class '${superclass.fullyDottedRawName}' does not define a default constructor.`)); + } } }