ignore unresolved types in extends/implements

This commit is contained in:
Dave Holoway
2020-06-16 16:01:21 +01:00
parent 9ac6086bad
commit 46838686ea
2 changed files with 14 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
const ParseProblem = require('../parsetypes/parse-problem');
const {SourceType} = require('../source-type');
const { AnyType } = require('../body-types');
const { UnresolvedType } = require('java-mti');
/**
@@ -7,15 +8,18 @@ const { UnresolvedType } = require('java-mti');
* @param {*} probs
*/
function checkImplements(source_type, probs) {
if (source_type.implements_types.length === 0) {
const superinterfaces = source_type.implements_types
.map(st => st.resolved)
.filter(t => !(t instanceof AnyType));
if (superinterfaces.length === 0) {
return;
}
const interfaces = source_type.implements_types.map(it => it.resolved);
if (source_type.typeKind === 'interface') {
probs.push(ParseProblem.Error(source_type.implements_types[0].tokens, `Interface types cannot declare an implements section`));
}
if (source_type.typeKind === 'class') {
interfaces.forEach((intf, i) => {
superinterfaces.forEach((intf, i) => {
if (intf instanceof UnresolvedType) {
return;
}