Skip to content

Commit

Permalink
fix override check
Browse files Browse the repository at this point in the history
  • Loading branch information
peq committed Feb 13, 2020
1 parent 9cc999d commit b20a0b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Expand Up @@ -47,6 +47,7 @@ private static FunctionSignature filterSigs(
return candidates.get(0);
}

sigs = candidates;
candidates = filterByIfNotDefinedAnnotation(candidates);
if (candidates.isEmpty()) {
// parameters match for no element, just return the first signature
Expand All @@ -55,6 +56,7 @@ private static FunctionSignature filterSigs(
return candidates.get(0);
}

sigs = candidates;
candidates = filterByHasTypeClasses(candidates);
if (candidates.isEmpty()) {
// parameters match for no element, just return the first signature
Expand All @@ -64,7 +66,6 @@ private static FunctionSignature filterSigs(
}



if (argTypes.stream().noneMatch(t -> t instanceof WurstTypeUnknown)) {
// only show overloading error, if type for all arguments could be determined
StringBuilder alternatives = new StringBuilder();
Expand Down
Expand Up @@ -85,6 +85,10 @@ public static WPos getErrorPos(Element e) {
return e.attrSource();
}

public static WPos getErrorPos(InstanceDecl e) {
return e.getImplementedInterface().attrErrorPos();
}

public static WPos getErrorPos(SomeSuperConstructorCall e) {
return e.getKeywordSource();
}
Expand Down
Expand Up @@ -1786,7 +1786,11 @@ public void case_FuncDef(FuncDef f) {
}
}
} else {
check(VisibilityPublic.class, Annotation.class);
if (isInInstanceDecl(f)) {
check(VisibilityPublic.class, Annotation.class, ModOverride.class);
} else {
check(VisibilityPublic.class, Annotation.class);
}
}
if (f.attrIsCompiletime()) {
if (f.getParameters().size() > 0) {
Expand Down Expand Up @@ -1860,6 +1864,17 @@ public void case_InstanceDecl(InstanceDecl instanceDecl) {
}
}

private boolean isInInstanceDecl(FuncDef f) {
Element e = f;
while (e != null) {
if (e instanceof InstanceDecl) {
return true;
}
e = e.getParent();
}
return false;
}

private static String printMod(Class<? extends Modifier> c) {
String name = c.getName().toLowerCase();
name = name.replaceFirst("^.*\\.", "");
Expand Down

0 comments on commit b20a0b3

Please sign in to comment.