don't report missing constructors if superclass has none

This commit is contained in:
Dave Holoway
2020-06-16 18:01:32 +01:00
parent 6af16cac43
commit b61ef125fc

View File

@@ -18,10 +18,12 @@ function checkConstructor(source_type, probs) {
// - which means the inherited class is Object (and a default constructor exists) // - which means the inherited class is Object (and a default constructor exists)
return; return;
} }
if (!superclass.constructors.find(c => c.parameterCount === 0)) { if (superclass.constructors.length) {
// the source type has no declared constructors, but the superclass if (!superclass.constructors.find(c => c.parameterCount === 0)) {
// does not include a default (parameterless) constructor // the source type has no declared constructors, but the superclass
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.`)); // 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.`));
}
} }
} }