X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fcodegen%2Ftypes%2FJavaTypeTranslator.java;h=c528d83a65436addac291ab7f40ce54a3e1aadf0;hp=2e2dcef2f5778685e9022f6020a610fb64fea8b5;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaTypeTranslator.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaTypeTranslator.java index 2e2dcef2f..c528d83a6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaTypeTranslator.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaTypeTranslator.java @@ -2,7 +2,9 @@ package org.simantics.scl.compiler.internal.codegen.types; import org.cojen.classfile.TypeDesc; import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; +import org.simantics.scl.compiler.elaboration.modules.TypeAlias; import org.simantics.scl.compiler.elaboration.modules.TypeConstructor; +import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor; import org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.internal.codegen.utils.Constants; import org.simantics.scl.compiler.types.TApply; @@ -33,16 +35,20 @@ public class JavaTypeTranslator { parameters[len-i-1] = temp; } } + + private TypeConstructor getTypeConstructor(TCon con) { + TypeDescriptor typeDescriptor = environment.getTypeDescriptor(con); + if(typeDescriptor == null) + throw new InternalCompilerError("Didn't find type constructor " + con.module + "/" + con.name + "."); + if(typeDescriptor instanceof TypeAlias) + throw new InternalCompilerError("Type " + con.module + "/" + con.name + " is a type alias."); + return (TypeConstructor)typeDescriptor; + } public TypeDesc toTypeDesc(Type type) { while(true) { - if(type instanceof TCon) { - TCon con = (TCon)type; - TypeConstructor typeConstructor = environment.getTypeConstructor(con); - if(typeConstructor == null) - throw new InternalCompilerError("Didn't find type constructor " + con.module + "/" + con.name + "."); - return typeConstructor.construct(this, Type.EMPTY_ARRAY); - } + if(type instanceof TCon) + return getTypeConstructor((TCon)type).construct(this, Type.EMPTY_ARRAY); else if(type instanceof TApply) { int i=0; while(true) { @@ -51,7 +57,7 @@ public class JavaTypeTranslator { type = Types.canonical(apply.function); if(type instanceof TCon) { reverseParameters(i); - return environment.getTypeConstructor((TCon)type).construct(this, parameters); + return getTypeConstructor((TCon)type).construct(this, parameters); } else if(type instanceof TApply) ;