Skip to content

Commit

Permalink
metamodel #226: removed many java warnings and todos
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Sep 11, 2013
1 parent c802c61 commit ea3888b
Show file tree
Hide file tree
Showing 36 changed files with 123 additions and 188 deletions.
3 changes: 2 additions & 1 deletion runtime/ceylon/language/model/typeLiteral_.java
Expand Up @@ -16,9 +16,10 @@ public final class typeLiteral_ {

private typeLiteral_() {}

@SuppressWarnings({ "unchecked", "hiding" })
@TypeInfo("ceylon.language.model::Type<Type>")
@TypeParameters(@TypeParameter(value = "Type", variance = Variance.OUT, satisfies = "ceylon.language::Anything"))
public static <Type> ceylon.language.model.Type<? extends Type> typeLiteral(@Ignore TypeDescriptor $reifiedType) {
return Metamodel.getAppliedMetamodel($reifiedType);
return (ceylon.language.model.Type<? extends Type>) Metamodel.getAppliedMetamodel($reifiedType);
}
}
Expand Up @@ -3,9 +3,9 @@
import ceylon.language.Sequential;
import ceylon.language.empty_;
import ceylon.language.model.Attribute$impl;
import ceylon.language.model.ValueModel$impl;
import ceylon.language.model.Model$impl;
import ceylon.language.model.Value;
import ceylon.language.model.ValueModel$impl;
import ceylon.language.model.declaration.ValueDeclaration;

import com.redhat.ceylon.compiler.java.metadata.Ceylon;
Expand All @@ -15,7 +15,6 @@
import com.redhat.ceylon.compiler.java.metadata.TypeParameters;
import com.redhat.ceylon.compiler.java.metadata.Variance;
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor;
import com.redhat.ceylon.compiler.typechecker.model.Generic;
import com.redhat.ceylon.compiler.typechecker.model.ProducedTypedReference;

@Ceylon(major = 5)
Expand Down Expand Up @@ -48,21 +47,18 @@ public AppliedAttribute(@Ignore TypeDescriptor $reifiedContainer,
@Override
@Ignore
public ValueModel$impl<Type> $ceylon$language$model$ValueModel$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Model$impl $ceylon$language$model$Model$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Attribute$impl<Container, Type> $ceylon$language$model$Attribute$impl() {
// TODO Auto-generated method stub
return null;
}

Expand All @@ -80,7 +76,7 @@ public ceylon.language.model.Type<? extends Type> getType() {

@Override
protected Value<? extends Type> bindTo(Object instance) {
return new AppliedValue($reifiedType, declaration, typedReference, getContainer(), instance);
return new AppliedValue<Type>($reifiedType, declaration, typedReference, getContainer(), instance);
}

@Ignore
Expand All @@ -89,13 +85,14 @@ protected Value<? extends Type> bindTo(Object instance) {
return TypeDescriptor.klass(AppliedAttribute.class, super.$reifiedType, $reifiedType);
}

public static ceylon.language.model.Attribute instance(@Ignore TypeDescriptor $reifiedSubType, @Ignore TypeDescriptor reifiedValueType,
FreeAttribute value, ProducedTypedReference valueTypedReference,
com.redhat.ceylon.compiler.typechecker.model.TypedDeclaration decl,
ceylon.language.model.ClassOrInterface<? extends Object> container) {
public static <ContainerType, ValueType> ceylon.language.model.Attribute<ContainerType, ValueType>
instance(@Ignore TypeDescriptor $reifiedSubType, @Ignore TypeDescriptor reifiedValueType,
FreeAttribute value, ProducedTypedReference valueTypedReference,
com.redhat.ceylon.compiler.typechecker.model.TypedDeclaration decl,
ceylon.language.model.ClassOrInterface<? extends Object> container) {
return decl.isVariable()
? new AppliedVariableAttribute($reifiedSubType, reifiedValueType, value, valueTypedReference, container)
: new AppliedAttribute($reifiedSubType, reifiedValueType, value, valueTypedReference, container);
? new AppliedVariableAttribute<ContainerType, ValueType>($reifiedSubType, reifiedValueType, value, valueTypedReference, container)
: new AppliedAttribute<ContainerType, ValueType>($reifiedSubType, reifiedValueType, value, valueTypedReference, container);
}

@Override
Expand Down Expand Up @@ -173,7 +170,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof ceylon.language.model.Attribute == false)
return false;
ceylon.language.model.Attribute other = (ceylon.language.model.Attribute) obj;
ceylon.language.model.Attribute<?,?> other = (ceylon.language.model.Attribute<?,?>) obj;
return getDeclaration().equals(other.getDeclaration())
&& getDeclaringClassOrInterface().equals(other.getDeclaringClassOrInterface());
}
Expand Down
Expand Up @@ -57,14 +57,12 @@ public AppliedClass(@Ignore TypeDescriptor $reifiedType,
@Override
@Ignore
public Class$impl<Type, Arguments> $ceylon$language$model$Class$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public ClassModel$impl<Type, Arguments> $ceylon$language$model$ClassModel$impl() {
// TODO Auto-generated method stub
return null;
}

Expand Down Expand Up @@ -183,7 +181,7 @@ private MethodHandle reflectionToMethodHandle(Object found, Class<?> javaClass,
java.lang.Class<?>[] parameterTypes;
try {
if(found instanceof java.lang.reflect.Constructor){
((java.lang.reflect.Constructor) found).setAccessible(true);
((java.lang.reflect.Constructor<?>) found).setAccessible(true);
constructor = MethodHandles.lookup().unreflectConstructor((java.lang.reflect.Constructor<?>)found);
parameterTypes = ((java.lang.reflect.Constructor<?>)found).getParameterTypes();
}else{
Expand Down Expand Up @@ -396,7 +394,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof AppliedClass == false)
return false;
AppliedClass other = (AppliedClass) obj;
AppliedClass<?,?> other = (AppliedClass<?,?>) obj;
// in theory, if our instance is the same, our containing type should be the same
// and if we don't have an instance we're a toplevel and have no containing type
return getDeclaration().equals(other.getDeclaration())
Expand Down
Expand Up @@ -47,29 +47,25 @@ public abstract class AppliedClassOrInterface<Type>

@Override
@Ignore
public ceylon.language.model.Type$impl $ceylon$language$model$Type$impl() {
// TODO Auto-generated method stub
public ceylon.language.model.Type$impl<Type> $ceylon$language$model$Type$impl() {
return null;
}

@Override
@Ignore
public ceylon.language.model.Generic$impl $ceylon$language$model$Generic$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Model$impl $ceylon$language$model$Model$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public ClassOrInterface$impl<Type> $ceylon$language$model$ClassOrInterface$impl() {
// TODO Auto-generated method stub
return null;
}

Expand All @@ -96,14 +92,14 @@ protected void init() {
}

List<com.redhat.ceylon.compiler.typechecker.model.ProducedType> satisfiedTypes = decl.getSatisfiedTypes();
ceylon.language.model.Interface[] interfaces = new ceylon.language.model.Interface[satisfiedTypes.size()];
ceylon.language.model.Interface<?>[] interfaces = new ceylon.language.model.Interface[satisfiedTypes.size()];
int i=0;
for(com.redhat.ceylon.compiler.typechecker.model.ProducedType pt : satisfiedTypes){
com.redhat.ceylon.compiler.typechecker.model.ProducedType resolvedPt = pt.substitute(producedType.getTypeArguments());
interfaces[i++] = (ceylon.language.model.Interface) Metamodel.getAppliedMetamodel(resolvedPt);
interfaces[i++] = (ceylon.language.model.Interface<?>) Metamodel.getAppliedMetamodel(resolvedPt);
}
// FIXME: reified type is wrong here and most likely in ClassOrInterfaceType too
this.interfaces = (Sequential)Util.sequentialInstance(FreeClassOrInterface.$InterfacesTypeDescriptor, interfaces);
this.interfaces = Util.sequentialInstance(FreeClassOrInterface.$InterfacesTypeDescriptor, interfaces);
}

@Override
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class AppliedFunction<Type, Arguments extends Sequential<? extends Object
@Ignore
private final TypeDescriptor $reifiedArguments;

private ceylon.language.model.Type type;
private ceylon.language.model.Type<? extends Type> type;
protected FreeFunction declaration;
private MethodHandle method;
private MethodHandle[] dispatch;
Expand Down Expand Up @@ -198,28 +198,24 @@ public FreeFunction getDeclaration(){
@Override
@Ignore
public ceylon.language.model.Generic$impl $ceylon$language$model$Generic$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Model$impl $ceylon$language$model$Model$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public FunctionModel$impl $ceylon$language$model$FunctionModel$impl() {
// TODO Auto-generated method stub
public FunctionModel$impl<Type, Arguments> $ceylon$language$model$FunctionModel$impl() {
return null;
}

@Override
@Ignore
public Function$impl<Type, Arguments> $ceylon$language$model$Function$impl() {
// TODO Auto-generated method stub
return null;
}

Expand Down
Expand Up @@ -36,14 +36,12 @@ public AppliedInterface(@Ignore TypeDescriptor $reifiedType,
@Override
@Ignore
public Interface$impl<Type> $ceylon$language$model$Interface$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public InterfaceModel$impl<Type> $ceylon$language$model$InterfaceModel$impl() {
// TODO Auto-generated method stub
return null;
}

Expand Down Expand Up @@ -72,7 +70,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof AppliedInterface == false)
return false;
AppliedInterface other = (AppliedInterface) obj;
AppliedInterface<?> other = (AppliedInterface<?>) obj;
// in theory, if our instance is the same, our containing type should be the same
// and if we don't have an instance we're a toplevel and have no containing type
return getDeclaration().equals(other.getDeclaration())
Expand Down
Expand Up @@ -6,10 +6,9 @@
import ceylon.language.Iterator;
import ceylon.language.Sequential;
import ceylon.language.finished_;
import ceylon.language.model.IntersectionType$impl;
import ceylon.language.model.Type;
import ceylon.language.model.Type$impl;
import ceylon.language.model.IntersectionType$impl;
import ceylon.language.model.declaration.OpenType;

import com.redhat.ceylon.compiler.java.Util;
import com.redhat.ceylon.compiler.java.metadata.Ceylon;
Expand Down Expand Up @@ -45,7 +44,7 @@ public class AppliedIntersectionType<Intersection>
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Iterator<? extends Type> iterator = satisfiedTypes.iterator();
Iterator<? extends Type<?>> iterator = satisfiedTypes.iterator();
Object next=iterator.next();
sb.append(next);
while (!((next=iterator.next()) instanceof Finished)) {
Expand All @@ -63,20 +62,18 @@ public String toString() {
for(com.redhat.ceylon.compiler.typechecker.model.ProducedType pt : satisfiedTypes){
types[i++] = Metamodel.getAppliedMetamodel(pt);
}
this.satisfiedTypes = (Sequential)Util.sequentialInstance(TypeDescriptor.klass(ceylon.language.model.Type.class, ceylon.language.Anything.$TypeDescriptor), types);
this.satisfiedTypes = Util.sequentialInstance(TypeDescriptor.klass(ceylon.language.model.Type.class, ceylon.language.Anything.$TypeDescriptor), types);
}

@Override
@Ignore
public Type$impl $ceylon$language$model$Type$impl() {
// TODO Auto-generated method stub
public Type$impl<Intersection> $ceylon$language$model$Type$impl() {
return null;
}

@Override
@Ignore
public IntersectionType$impl $ceylon$language$model$IntersectionType$impl() {
// TODO Auto-generated method stub
public IntersectionType$impl<Intersection> $ceylon$language$model$IntersectionType$impl() {
return null;
}

Expand All @@ -90,7 +87,7 @@ public ceylon.language.Sequential<? extends ceylon.language.model.Type<?>> getSa
public int hashCode() {
int result = 1;
// do not use caseTypes.hashCode because order is not significant
Iterator<? extends Type> iterator = satisfiedTypes.iterator();
Iterator<? extends Type<?>> iterator = satisfiedTypes.iterator();
Object obj;
while((obj = iterator.next()) != finished_.$get()){
result = result + obj.hashCode();
Expand All @@ -106,7 +103,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof AppliedIntersectionType == false)
return false;
AppliedIntersectionType other = (AppliedIntersectionType) obj;
AppliedIntersectionType<?> other = (AppliedIntersectionType<?>) obj;
return other.model.isExactly(model);
}
}
Expand Up @@ -36,7 +36,6 @@ public AppliedMember(@Ignore TypeDescriptor $reifiedType, @Ignore TypeDescriptor
@Override
@Ignore
public Member$impl<Type, Kind> $ceylon$language$model$Member$impl() {
// TODO Auto-generated method stub
return null;
}

Expand Down
Expand Up @@ -35,21 +35,18 @@ public class AppliedMemberClass<Container, Type, Arguments extends Sequential<?
@Override
@Ignore
public ClassModel$impl<Type, Arguments> $ceylon$language$model$ClassModel$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Member$impl<Container, Class<? extends Type, ? super Arguments>> $ceylon$language$model$Member$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public MemberClass$impl<Container, Type, Arguments> $ceylon$language$model$MemberClass$impl() {
// TODO Auto-generated method stub
return null;
}

Expand All @@ -62,7 +59,7 @@ public class AppliedMemberClass<Container, Type, Arguments extends Sequential<?
@Override
@Ignore
public Class<? extends Type, ? super Arguments> $call(Object arg0) {
return new AppliedClass($reifiedType, $reifiedArguments, super.producedType, getContainer(), arg0);
return new AppliedClass<Type, Arguments>($reifiedType, $reifiedArguments, super.producedType, getContainer(), arg0);
}

@Override
Expand Down Expand Up @@ -185,7 +182,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof ceylon.language.model.MemberClass == false)
return false;
ceylon.language.model.MemberClass other = (ceylon.language.model.MemberClass) obj;
ceylon.language.model.MemberClass<?, ?, ?> other = (ceylon.language.model.MemberClass<?, ?, ?>) obj;
return getDeclaration().equals(other.getDeclaration())
&& getDeclaringClassOrInterface().equals(other.getDeclaringClassOrInterface())
&& getTypeArguments().equals(other.getTypeArguments());
Expand Down
Expand Up @@ -31,21 +31,18 @@ public class AppliedMemberInterface<Container, Type>
@Override
@Ignore
public InterfaceModel$impl<Type> $ceylon$language$model$InterfaceModel$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public Member$impl<Container, Interface<? extends Type>> $ceylon$language$model$Member$impl() {
// TODO Auto-generated method stub
return null;
}

@Override
@Ignore
public MemberInterface$impl<Container, Type> $ceylon$language$model$MemberInterface$impl() {
// TODO Auto-generated method stub
return null;
}

Expand All @@ -58,7 +55,7 @@ public class AppliedMemberInterface<Container, Type>
@Override
@Ignore
public Interface<? extends Type> $call(Object arg0) {
return new AppliedInterface($reifiedType, super.producedType, getContainer(), arg0);
return new AppliedInterface<Type>($reifiedType, super.producedType, getContainer(), arg0);
}

@Override
Expand Down Expand Up @@ -179,7 +176,7 @@ public boolean equals(Object obj) {
return true;
if(obj instanceof ceylon.language.model.MemberInterface == false)
return false;
ceylon.language.model.MemberInterface other = (ceylon.language.model.MemberInterface) obj;
ceylon.language.model.MemberInterface<?, ?> other = (ceylon.language.model.MemberInterface<?, ?>) obj;
return getDeclaration().equals(other.getDeclaration())
&& getDeclaringClassOrInterface().equals(other.getDeclaringClassOrInterface())
&& getTypeArguments().equals(other.getTypeArguments());
Expand Down

0 comments on commit ea3888b

Please sign in to comment.