Skip to content

Commit

Permalink
Remove ConstructorModel, Constructor and MemberClassConstructor
Browse files Browse the repository at this point in the history
They're not actually used since it's very difficult to usefully abstract
callable constructors and value constructors since they're very different
and existing abstractions such as Declaration are sufficient.

Part of #750
  • Loading branch information
tombentley committed Sep 29, 2015
1 parent 5ecafdb commit b534b5e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 81 deletions.
Expand Up @@ -104,30 +104,22 @@ public Type apply(@Name("arguments")
Sequential<?> arguments){
checkInit();

ceylon.language.meta.model.Constructor<Type, Sequential<? extends Object>> ctor = dispatch.checkConstructor();
if (ctor != null) {
return ctor.apply(arguments);
} else {
return Metamodel.apply(this, arguments,
dispatch.parameterProducedTypes,
dispatch.firstDefaulted,
dispatch.variadicIndex);
}
dispatch.checkConstructor();
return Metamodel.apply(this, arguments,
dispatch.parameterProducedTypes,
dispatch.firstDefaulted,
dispatch.variadicIndex);
}

@Override
public Type namedApply(@Name("arguments")
@TypeInfo("ceylon.language::Iterable<ceylon.language::Entry<ceylon.language::String,ceylon.language::Anything>,ceylon.language::Null>")
ceylon.language.Iterable<? extends ceylon.language.Entry<? extends ceylon.language.String,? extends java.lang.Object>,? extends java.lang.Object> arguments){
checkInit();
ceylon.language.meta.model.Constructor<Type, Sequential<? extends Object>> ctor = dispatch.checkConstructor();
if (ctor != null) {
return ctor.namedApply(arguments);
} else {
return Metamodel.namedApply(this, this,
(com.redhat.ceylon.model.typechecker.model.Functional)(freeConstructor != null ? freeConstructor.declaration : freeClass.declaration),
arguments, dispatch.getProducedParameterTypes());
}
dispatch.checkConstructor();
return Metamodel.namedApply(this, this,
(com.redhat.ceylon.model.typechecker.model.Functional)(freeConstructor != null ? freeConstructor.declaration : freeClass.declaration),
arguments, dispatch.getProducedParameterTypes());
}

@Override
Expand Down
Expand Up @@ -588,14 +588,13 @@ else if(foundMethod.getName().equals("copyTo")){
return method;
}

ceylon.language.meta.model.Constructor<Type, Sequential<? extends Object>> checkConstructor() {
void checkConstructor() {
if(((FreeClass)freeClass).getAbstract())
throw new InvocationException("Abstract class cannot be instantiated");
if(((FreeClass)freeClass).getAnonymous())
throw new InvocationException("Object class cannot be instantiated");
if(constructor == null)
throw Metamodel.newModelError("No constructor found for: "+freeClass.getName());
return null;
}

@Override
Expand Down Expand Up @@ -776,24 +775,16 @@ public Type apply() {

@Override
public Type apply(Sequential<? extends Object> arguments) {
ceylon.language.meta.model.Constructor<Type, Sequential<? extends Object>> ctor = checkConstructor();
if (ctor != null) {
return ctor.apply(arguments);
} else {
return Metamodel.apply(this, arguments, parameterProducedTypes, firstDefaulted, variadicIndex);
}
checkConstructor();
return Metamodel.apply(this, arguments, parameterProducedTypes, firstDefaulted, variadicIndex);
}

@Override
public Type namedApply(
Iterable<? extends Entry<? extends ceylon.language.String, ? extends Object>, ? extends Object> arguments) {
ceylon.language.meta.model.Constructor<Type, Sequential<? extends Object>> ctor = checkConstructor();
if (ctor != null) {
return ctor.namedApply(arguments);
} else {
return Metamodel.namedApply(this, this,
(com.redhat.ceylon.model.typechecker.model.Functional)(freeConstructor != null ? freeConstructor.declaration : freeClass.declaration),
arguments, parameterProducedTypes);
}
checkConstructor();
return Metamodel.namedApply(this, this,
(com.redhat.ceylon.model.typechecker.model.Functional)(freeConstructor != null ? freeConstructor.declaration : freeClass.declaration),
arguments, parameterProducedTypes);
}
}
21 changes: 0 additions & 21 deletions src/ceylon/language/meta/model/Constructor.ceylon

This file was deleted.

12 changes: 0 additions & 12 deletions src/ceylon/language/meta/model/ConstructorModel.ceylon

This file was deleted.

5 changes: 2 additions & 3 deletions src/ceylon/language/meta/model/Functional.ceylon
Expand Up @@ -3,9 +3,8 @@ import ceylon.language.meta.model {
ClosedType=Type
}

"Abstraction for models which have a parameter list. That is,
[[ClassModel]]s, [[ConstructorModel]]s and [[FunctionModel]]s."
shared sealed interface Functional /*satisfies Applicable<Anything,Arguments>*/{
"Abstraction for models which have a parameter list."
shared sealed interface Functional {
"The parameter types"
shared formal ClosedType<>[] parameterTypes;
}
Expand Down
10 changes: 0 additions & 10 deletions src/ceylon/language/meta/model/MemberClassConstructor.ceylon

This file was deleted.

4 changes: 2 additions & 2 deletions test/metamodel/bug692.ceylon
Expand Up @@ -13,6 +13,6 @@ shared void bug692() {

print(type(constructor));
// and
print((constructor of Anything)
is Constructor<Bug692,[String]>);
assert((constructor of Anything)
is CallableConstructor<Bug692,[String]>);
}

0 comments on commit b534b5e

Please sign in to comment.