use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.FunctionImpl in project ceylon by eclipse.
the class FunctionDeclarationImpl method apply.
@Override
@TypeInfo("ceylon.language.meta.model::Function<Return,Arguments>")
@TypeParameters({ @TypeParameter("Return"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
public <Return extends Object, Arguments extends Sequential<? extends Object>> ceylon.language.meta.model.Function<Return, Arguments> apply(@Ignore TypeDescriptor $reifiedReturn, @Ignore TypeDescriptor $reifiedArguments, @Name("typeArguments") @TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::Type<ceylon.language::Anything>>") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (!getToplevel()) {
String msg;
if (getStatic()) {
msg = "Cannot apply a static declaration with no container type: use staticApply";
} else {
msg = "Cannot apply a member declaration with no container type: use memberApply";
}
throw new ceylon.language.meta.model.TypeApplicationException(msg);
}
List<org.eclipse.ceylon.model.typechecker.model.Type> producedTypes = Metamodel.getProducedTypes(typeArguments);
Metamodel.checkTypeArguments(null, declaration, producedTypes);
org.eclipse.ceylon.model.typechecker.model.Reference appliedFunction = declaration.appliedReference(null, producedTypes);
TypeDescriptor reifiedType = Metamodel.getTypeDescriptorForFunction(appliedFunction);
TypeDescriptor reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction);
Metamodel.checkReifiedTypeArgument("apply", "Function<$1,$2>", Variance.OUT, declaration.getUnit().getCallableReturnType(appliedFunction.getFullType()), $reifiedReturn, Variance.IN, Metamodel.getProducedTypeForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction), $reifiedArguments);
return new FunctionImpl<Return, Arguments>(reifiedType, reifiedArguments, appliedFunction, this, null, null);
}
use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.FunctionImpl in project ceylon by eclipse.
the class FunctionDeclarationImpl method staticApply.
@Override
public <Return extends Object, Arguments extends Sequential<? extends Object>> ceylon.language.meta.model.Function<Return, Arguments> staticApply(@Ignore TypeDescriptor $reifiedReturn, @Ignore TypeDescriptor $reifiedArguments, @Name("containerType") ceylon.language.meta.model.Type<? extends Object> containerType, @Name("typeArguments") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (!getStatic())
throw new ceylon.language.meta.model.TypeApplicationException("Cannot apply a " + (getToplevel() ? "toplevel" : "member") + " declaration to a container type: use " + (getToplevel() ? "apply" : "memberApply"));
List<org.eclipse.ceylon.model.typechecker.model.Type> producedTypes = Metamodel.getProducedTypes(typeArguments);
Metamodel.checkTypeArguments(null, declaration, producedTypes);
org.eclipse.ceylon.model.typechecker.model.Reference appliedFunction = declaration.appliedReference(((ClassOrInterfaceImpl<?>) containerType).producedType, producedTypes);
TypeDescriptor reifiedType = Metamodel.getTypeDescriptorForFunction(appliedFunction);
TypeDescriptor reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction);
if (getStatic()) {
producedTypes.addAll(0, Metamodel.getModel(containerType).getTypeArgumentList());
}
Metamodel.checkReifiedTypeArgument("apply", "Function<$1,$2>", Variance.OUT, declaration.getUnit().getCallableReturnType(appliedFunction.getFullType()), $reifiedReturn, Variance.IN, Metamodel.getProducedTypeForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction), $reifiedArguments);
return new FunctionImpl<Return, Arguments>(reifiedType, reifiedArguments, appliedFunction, this, containerType, null);
}
Aggregations