Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
relational-rags
Commits
2834ef70
Commit
2834ef70
authored
Jul 06, 2018
by
Niklas Fors
Browse files
Include supertype when checking for name duplicates
parent
549c19c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
spec/jastadd/Analysis.jrag
View file @
2834ef70
...
...
@@ -44,22 +44,31 @@ aspect ComponentAnalysis {
syn boolean Component.isAlreadyDeclared()
= !isTargetOfDirectedRelation()
&& toTypeDecl() != null
&& lookupComponent(toTypeDecl(), name()) != this;
inh Component Component.lookupComponent(TypeDecl td, String name);
eq Program.getChild().lookupComponent(TypeDecl td, String name) {
if (td != null) {
for (Component c: td.getComponents()) {
if (c.name().equals(name)) {
return c;
}
eq Program.getChild().lookupComponent(TypeDecl td, String name)
= lookupComponentSyn(td, name);
syn Component Program.lookupComponentSyn(TypeDecl td, String name) {
// Check super type first to find duplicates (shadowing is not allowed)
if (td.hasSuper() && td.getSuper().decl() != null) {
Component c = lookupComponentSyn(td.getSuper().decl(), name);
if (c != null) return c;
}
for (Component c: td.getComponents()) {
if (c.name().equals(name)) {
return c;
}
}
for (Relation r: getRelations()) {
Component c = r.getLeft().lookup(td, name);
if (c != null) return c;
c = r.getRight().lookup(td, name);
if (c != null) return c;
}
return null;
}
...
...
tests/errors/Inheritance.expected
0 → 100644
View file @
2834ef70
Errors:
Line 2, column 12: Component 'X' is already declared for type 'B1'
Line 6, column 5: Component 'X' is already declared for type 'B2'
tests/errors/Inheritance.relast
0 → 100644
View file @
2834ef70
A ::= X;
B1 : A ::= X;
B2 : A;
X;
rel B2.X -> X;
tests/errors/Makefile
View file @
2834ef70
...
...
@@ -4,4 +4,11 @@ build-jar:
(
cd
../../
&&
ant jar
)
test
:
java
-jar
../../relast-compiler.jar Errors.relast 2> Errors.out
||
true
diff Errors.out Errors.expected
\ No newline at end of file
diff Errors.out Errors.expected
java
-jar
../../relast-compiler.jar
Inheritance.relast
2>
Inheritance.out
||
true
diff
Inheritance.out
Inheritance.expected
@echo
"#"
@echo
"# ERROR TESTS OK"
@echo
"#"
\ No newline at end of file
tests/valid/Makefile
View file @
2834ef70
all
:
build-jar test
test
:
compile run check-idempotent
@
echo
"#"
@
echo
"# VALID TESTS OK"
@
echo
"#"
build-jar
:
(
cd
../../
&&
ant jar
)
...
...
tests/valid/Test.java
View file @
2834ef70
...
...
@@ -30,8 +30,6 @@ public class Test {
testBi9
();
testImmutableList
();
System
.
out
.
println
(
"TESTS OK"
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment