Skip to content

Commit

Permalink
AppliedInitializer and AppliedMemberInitializer
Browse files Browse the repository at this point in the history
Part of #750
  • Loading branch information
tombentley committed Sep 29, 2015
1 parent e452f0f commit ae935ac
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 1 deletion.
Expand Up @@ -335,6 +335,9 @@ public <Arguments extends Sequential<? extends Object>> java.lang.Object getDecl
if(ctor == null)
return null;
if (ctor instanceof CallableConstructorDeclaration) {
if (ctor instanceof FreeInitializerConstructor) {
return new AppliedInitializer<>(this);
}
FreeCallableConstructor callableCtor = (FreeCallableConstructor)ctor;
com.redhat.ceylon.model.typechecker.model.Type constructorType = callableCtor.constructor.appliedType(this.producedType, Collections.<com.redhat.ceylon.model.typechecker.model.Type>emptyList());
// anonymous classes don't have parameter lists
Expand Down
@@ -0,0 +1,156 @@
package com.redhat.ceylon.compiler.java.runtime.metamodel;

import ceylon.language.Entry;
import ceylon.language.Iterable;
import ceylon.language.Map;
import ceylon.language.Sequence;
import ceylon.language.Sequential;
import ceylon.language.String;
import ceylon.language.meta.declaration.CallableConstructorDeclaration;
import ceylon.language.meta.declaration.TypeParameter;
import ceylon.language.meta.model.CallableConstructor;
import ceylon.language.meta.model.Class;
import ceylon.language.meta.model.ClassModel;

public class AppliedInitializer<Type, Arguments extends Sequential<? extends Object>> implements CallableConstructor<Type, Arguments>{

private Class<Type, Arguments> clazz;

public AppliedInitializer(Class<Type, Arguments> clazz) {
this.clazz = clazz;
}

@Override
public Sequential<? extends ceylon.language.meta.model.Type<? extends Object>> getTypeArgumentList() {
return clazz.getTypeArgumentList();
}

@Override
public Sequential<? extends Sequence<? extends Object>> getTypeArgumentWithVarianceList() {
return clazz.getTypeArgumentWithVarianceList();
}

@Override
public Map<? extends TypeParameter, ? extends Sequence<? extends Object>> getTypeArgumentWithVariances() {
return clazz.getTypeArgumentWithVariances();
}

@Override
public Map<? extends TypeParameter, ? extends ceylon.language.meta.model.Type<? extends Object>> getTypeArguments() {
return clazz.getTypeArguments();
}

@Override
public Sequential<? extends ceylon.language.meta.model.Type<? extends Object>> getParameterTypes() {
// TODO Auto-generated method stub
return null;
}

@Override
public Type apply() {
return clazz.apply();
}

@Override
public Type apply(Sequential<? extends Object> arg0) {
return clazz.apply(arg0);
}

@Override
public Type namedApply(
Iterable<? extends Entry<? extends String, ? extends Object>, ? extends Object> arg0) {
return clazz.namedApply(arg0);
}

@Override
public Type $call$() {
return clazz.$call$();
}

@Override
public Type $callvariadic$() {
return clazz.$callvariadic$();
}

@Override
public Type $callvariadic$(Sequential<?> varargs) {
return clazz.$callvariadic$(varargs);
}

@Override
public Type $call$(Object arg0) {
return clazz.$call$(arg0);
}

@Override
public Type $callvariadic$(Object arg0) {
return clazz.$callvariadic$(arg0);
}

@Override
public Type $callvariadic$(Object arg0, Sequential<?> varargs) {
return clazz.$callvariadic$(arg0, varargs);
}

@Override
public Type $call$(Object arg0, Object arg1) {
return clazz.$call$(arg0, arg1);
}

@Override
public Type $callvariadic$(Object arg0, Object arg1) {
return clazz.$callvariadic$(arg0, arg1);
}

@Override
public Type $callvariadic$(Object arg0, Object arg1, Sequential<?> varargs) {
return clazz.$callvariadic$(arg0, arg1, varargs);
}

@Override
public Type $call$(Object arg0, Object arg1, Object arg2) {
return clazz.$call$(arg0, arg1, arg2);
}

@Override
public Type $callvariadic$(Object arg0, Object arg1, Object arg2) {
return clazz.$callvariadic$(arg0, arg1, arg2);
}

@Override
public Type $callvariadic$(Object arg0, Object arg1, Object arg2,
Sequential<?> varargs) {
return clazz.$callvariadic$(arg0, arg1, arg2, varargs);
}

@Override
public Type $call$(Object... args) {
return clazz.$call$(args);
}

@Override
public Type $callvariadic$(Object... argsAndVarargs) {
return clazz.$callvariadic$(argsAndVarargs);
}

@Override
public short $getVariadicParameterIndex$() {
return clazz.$getVariadicParameterIndex$();
}

@Override
public ClassModel getContainer() {
return clazz;
}

@Override
public CallableConstructorDeclaration getDeclaration() {
return (CallableConstructorDeclaration)clazz.getDefaultConstructor();
}

@Override
public ClassModel getType() {
return clazz;
}

}
Expand Up @@ -283,6 +283,11 @@ public <Arguments extends Sequential<? extends Object>>java.lang.Object getDecla
if(ctor == null)
return null;
if (ctor instanceof CallableConstructorDeclaration) {
if (ctor instanceof FreeInitializerConstructor) {
return new AppliedMemberInitializer<>(
this.$reifiedContainer, this.$reifiedType, $reified$Arguments,
this);
}
FreeCallableConstructor callableCtor = (FreeCallableConstructor)ctor;
// anonymous classes don't have parameter lists
//TypeDescriptor actualReifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.declaration.getUnit(), (Functional)callableCtor.constructor, this.producedType);
Expand Down

0 comments on commit ae935ac

Please sign in to comment.