use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class ExpressionTransformer method isRecursiveReference.
//
// Helper functions
private boolean isRecursiveReference(Tree.StaticMemberOrTypeExpression expr) {
Declaration decl = expr.getDeclaration();
Scope s = expr.getScope();
// do we have decl as our container anywhere in the scope?
while (s != null && !Decl.equalScopeDecl(s, decl)) {
s = s.getContainer();
}
return Decl.equalScopeDecl(s, decl);
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class MethodOrValueReferenceVisitor method visit.
@Override
public void visit(Tree.Declaration that) {
Declaration dm = that.getDeclarationModel();
if (dm == declaration.getContainer() || (Decl.equal(dm, declaration) && !isClassWithConstructorMember(declaration)) || (dm instanceof Setter && ((Setter) dm).getGetter() == declaration)) {
if (!isCapturableMplParameter(declaration)) {
this.inCapturingScope = false;
}
}
super.visit(that);
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class MethodOrValueReferenceVisitor method isCapturableMplParameter.
/**
* Because methods with MPL use nested anonymous AbstractCallables
* if the declaration is a parameter in all but the last parameter list
* it should be captured.
*/
private boolean isCapturableMplParameter(Declaration d) {
if (!(d instanceof FunctionOrValue)) {
return false;
}
com.redhat.ceylon.model.typechecker.model.Parameter param = ((FunctionOrValue) d).getInitializerParameter();
if (param == null) {
return false;
}
Declaration paramDecl = param.getDeclaration();
if (paramDecl instanceof Functional) {
List<com.redhat.ceylon.model.typechecker.model.ParameterList> parameterLists = ((Functional) paramDecl).getParameterLists();
for (int i = 0; i < parameterLists.size() - 1; i++) {
if (parameterLists.get(i).getParameters().contains(param)) {
return true;
}
}
}
return false;
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class UnknownTypeCollector method visit.
public void visit(Tree.BaseMemberOrTypeExpression that) {
super.visit(that);
Declaration declaration = that.getDeclaration();
if (declaration == null)
return;
if (declaration instanceof Functional) {
Functional m = (Functional) declaration;
collectUnknownTypes(m.getType());
for (ParameterList pl : m.getParameterLists()) {
for (Parameter p : pl.getParameters()) {
collectUnknownTypes(p.getType());
}
}
} else if (declaration instanceof Value) {
Value v = (Value) declaration;
collectUnknownTypes(v.getType());
}
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class NamingTests method testCm.
@Test
public void testCm() throws Exception {
final Declaration decl = findDecl("Cm.ceylon", "Cm.m");
assertEquals("com.redhat.ceylon.compiler.java.codegen.Cm.m", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Aggregations