Skip to content

Commit

Permalink
Fixed effectively-immutable test...
Browse files Browse the repository at this point in the history
...which determines the only valid case where
the read-only interface is allowed to implement
the modifiable interface

the problem was that delegation methods where not taken into account.
they are not allowed in read-only and immutable cases because they are
likely breaking the immutability contract
  • Loading branch information
miho committed May 1, 2019
1 parent 2229b1a commit d2469b6
Show file tree
Hide file tree
Showing 5 changed files with 984 additions and 4 deletions.
7 changes: 5 additions & 2 deletions core/src/main/java/eu/mihosoft/vmf/core/ModelType.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,13 @@ public boolean allPropertyTypesAreInterfaceOnlyWithGettersOnlyOrImmutable() {

// TODO 10.02.2019 with t==null we currently assume immutable (future vmf versions might add
// more detailed options for non-model types)
//
// only guarantied to be effectively immutable if no delegations
// are defined
long numConformingProperties = getImplementation().getProperties().stream().map(p->p.getType()).
filter(t-> t==null || t.isInterfaceOnlyWithGettersOnly() || t.isImmutable()).count();
return numConformingProperties == getImplementation().getProperties().size();

return numConformingProperties == getImplementation().getProperties().size() && getDelegations().isEmpty();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* 181–192. http://doi.org/10.1007/s00791-014-0230-y
*#
// --------------------------------------------------------------------
// --- declaration of delegation methods
// --- declaration of constructor delegation methods
// --------------------------------------------------------------------

#foreach( $delegate in ${type.implementation.constructorDelegations})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
// --------------------------------------------------------------------
// --- declaration of delegation methods
// --------------------------------------------------------------------

## // ALL: ${type.implementation.delegations.size()}
## // METHODS: ${type.implementation.methodDelegations.size()}
## // CONSTRUCTOR: ${type.implementation.constructorDelegations.size()}
## // ONE_FOR_EACH_TYPE: ${type.implementation.delegationsOneForEachType.size()}
#foreach( $delegate in ${type.implementation.methodDelegations})
$delegate.methodDeclaration {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package eu.mihosoft.vmftest.complex.vmf_text.generated.miniclang;

import eu.mihosoft.vcollections.VList;
import eu.mihosoft.vmf.runtime.core.DelegatedBehavior;
import eu.mihosoft.vmf.runtime.core.VObject;

public class ControlFlowChildNodeDelegate implements DelegatedBehavior<VObject> {
private VObject obj;

@Override
public void setCaller(VObject caller) {
this.obj = obj;
}

public VList<ControlFlowScope> parentScopes() {
return null;
}
}
Loading

0 comments on commit d2469b6

Please sign in to comment.