This project is deprecated go here instead: https://github.com/ceylon/ceylon
ceylon / ceylon-model Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED
License: Apache License 2.0
DEPRECATED
License: Apache License 2.0
This project is deprecated go here instead: https://github.com/ceylon/ceylon
TypePrinter
renders the type Tuple<Nothing,Nothing,Empty & Tuple<Nothing,Nothing,Empty>>
as Nothing[2]
.
Is there any documentation available? Examples and typical scenarios in which this library would be useful would be great.
A while back, @FroMage did some optimization work for some utility functions for interrogating tuple types in Util
. I disabled them for now because they were still based on recursion instead of while
. We need to confirm that these optimizations are sill relevant—that they still help—and if so put them back in, after removing the use of recursion.
I get the following error when calling module
.resourceBypath() on a module located in a folder containing spaces:
java.lang.RuntimeException: java.net.URISyntaxException: Illegal character in path at index 43: classpath:/Users/bastien/Dev/workspace/with spaces/modules/my/pkg/1.0.0/my.pkg-1.0.0.car!my/pkg/foo.txt
at com.redhat.ceylon.model.loader.impl.reflect.CachedTOCJars$CachedTOCJar.getContentUri(CachedTOCJars.java:130)
at com.redhat.ceylon.model.loader.impl.reflect.CachedTOCJars.getContentUri(CachedTOCJars.java:258)
at com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader.getContentUri(RuntimeModelLoader.java:85)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ModuleImpl.resourceByPath(ModuleImpl.java:142)
at my.pkg.test_.test(test.ceylon:2)
at my.pkg.test_.main(test.ceylon)
Steps to reproduce:
run.ceylon
:shared void run() {
if (exists res = `module`.resourceByPath("foo.txt")) {
print(res.textContent());
}
}
foo.txt
in resource/my/module
I fixed it, but it needs to be reviewed by @gavinking
In ceylon/ceylon.language@d61c9bb I fixed eclipse-archived/ceylon-ide-eclipse#1444 by catching an Error
. I think it would be much better if instead of that, we changed the logic in ReflectionModelLoader.lookupNewClassMirror()
to not look for the class under two different names.
Wouldn't be appropriate to use Optional? Could you at least use @nullable?
The example in eclipse-archived/ceylon-sdk#441 fails with the stack trace below.
ceylon run: possible undecidability: typechecker detected possible nontermination and aborted algorithm
com.redhat.ceylon.model.typechecker.model.DecidabilityException: possible undecidability: typechecker detected possible nontermination and aborted algorithm
at com.redhat.ceylon.model.typechecker.model.Type.checkDepth(Type.java:1653)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:178)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:452)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:208)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyTuple(Type.java:462)
at com.redhat.ceylon.model.typechecker.model.Type.isExactlyInternal(Type.java:337)
at com.redhat.ceylon.model.typechecker.model.Type.isTypeArgumentListAssignable(Type.java:789)
at com.redhat.ceylon.model.typechecker.model.Type.isSubtypeOfInternal(Type.java:697)
at com.redhat.ceylon.model.typechecker.model.Type.isSubtypeOfInternal(Type.java:691)
at com.redhat.ceylon.model.typechecker.model.Type.isSubtypeOf(Type.java:549)
at com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor.is(TypeDescriptor.java:1361)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.isReified(Metamodel.java:346)
at com.redhat.ceylon.compiler.java.Util.isReified(Util.java:63)
at ceylon.promise.Deferred$promise_.foobar$priv$(Deferred.ceylon:159)
at ceylon.promise.Deferred$promise_.map$canonical$(Deferred.ceylon:92)
at ceylon.promise.Deferred$promise_.map(Deferred.ceylon:52)
at ceylon.promise.Conjunction.map$canonical$(Conjunction.ceylon:58)
at ceylon.promise.Conjunction.map(Conjunction.ceylon:57)
at ceylon.promise.Completion$impl.completed$canonical$(Completion.ceylon:29)
at ceylon.promise.Completion$impl.completed(Completion.ceylon:28)
at ceylon.promise.Conjunction.completed$canonical$(Conjunction.ceylon)
at ceylon.promise.Conjunction.completed(Conjunction.ceylon)
at simple.run_.run(run.ceylon:13)
at simple.run_.main(run.ceylon)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:57)
at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:48)
at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:75)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:122)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:106)
at ceylon.modules.Main.execute(Main.java:69)
at ceylon.modules.Main.main(Main.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.modules.Module.run(Module.java:312)
at org.jboss.modules.Main.main(Main.java:460)
at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:244)
at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:491)
at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:380)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:114)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:41)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.redhat.ceylon.launcher.Bootstrap.run(Bootstrap.java:55)
at com.redhat.ceylon.launcher.Bootstrap.main(Bootstrap.java:32)
Several frameworks have attempted to improve on Java’s nullability support by introducing annotations for something being @Nullable
or @NotNull
/@NonNull
/@Nonnull
. We should recognize these annotations, and warn or error if:
@Nullable
value (method return type, or field) is assigned to a Ceylon non-optional value or a Java @NotNull
, or@Nullable
value is assigned to a Java @NotNull
value (method parameter, setter parameter, or field).Behavior on unannotated elements should not change. Some frameworks define only one annotation because the other is the default, but we can’t detect that.
Test cases / examples: https://gist.github.com/lucaswerkmeister/07556232a9bd060dd593
Annotations to support (suggestion, potentially incomplete; list from Kotlin):
org.jetbrains.annotation
: @Nullable
, @NotNull
android.support.annotation
: @Nullable
, @NonNull
javax.annotation
: @Nullable
, @Nonnull
(JSR 305, not in main Java yet apparently)edu.umd.cs.findbugs.annotations
: @Nullable
, @NonNull
javax.validation.constraints
: @Null
(“must be null
” – wat?), @NotNull
lombok
: @NonNull
org.eclipse.jdt.annotation
: @Nullable
, @NonNull
– warning, without JS these links redirect you to the main help page for some stupid reasonorg.checkerframework.checker.nullness.qual
: @Nullable
, @NonNull
Alternatively, we could assume that any annotation named @Nullable
, @NotNull
, @NonNull
, @Nonnull
has this meaning. I think that’s probably a reasonable assumption.
I'm not sure if it belongs here, but this code ...
import ceylon.language.meta.declaration {
ClassDeclaration,
FunctionDeclaration
}
import ceylon.language.meta {
type
}
shared class A {
shared new() {}
shared void b() {}
}
shared void test() {
[FunctionDeclaration, ClassDeclaration?] cd = [`function A.b`, `class A`];
type(cd);
}
cause
ceylon run: Failed to load declaration [ReflectionClass: class com.redhat.
ceylon.compiler.java.runtime.metamodel.FreeClassWithConstructors]: Failed to
load methods in com.redhat.ceylon.compiler.java.runtime.metamodel.
FreeClassWithConstructors
com.redhat.ceylon.model.loader.ModelResolutionException: Failed to load declaration [ReflectionClass: class com.redhat.ceylon.compiler.java.runtime.metamodel.FreeClassWithConstructors]: Failed to load methods in com.redhat.ceylon.compiler.java.runtime.metamodel.FreeClassWithConstructors
at com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader$1.reportError(RuntimeModelLoader.java:209)
at com.redhat.ceylon.model.typechecker.model.UnknownType.reportErrors(UnknownType.java:94)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorForProducedType(Metamodel.java:909)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorsForProducedTypes(Metamodel.java:948)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorForProducedType(Metamodel.java:870)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorsForProducedTypes(Metamodel.java:948)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorForProducedType(Metamodel.java:861)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorsForProducedTypes(Metamodel.java:948)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorForProducedType(Metamodel.java:870)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getTypeDescriptorForArguments(Metamodel.java:1250)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getAppliedMetamodel(Metamodel.java:634)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getAppliedMetamodel(Metamodel.java:367)
at ceylon.language.meta.type_.type(type_.java:34)
at bar.test_.test(test.ceylon:17)
at bar.test_.main(test.ceylon)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:57)
at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:48)
at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:75)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:122)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:106)
at ceylon.modules.Main.execute(Main.java:69)
at ceylon.modules.Main.main(Main.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.modules.Module.run(Module.java:312)
at org.jboss.modules.Main.main(Main.java:460)
at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:244)
at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:491)
at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:380)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:114)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:41)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:34)
at com.redhat.ceylon.launcher.Launcher.main(Launcher.java:27)
I don't know where the getReference()
method of Declaration
came from, or what its semantics are supposed to be, but it seems to be broken, producing ProducedType
s with missing type args.
The code that uses it almost all seems to by using it with TypedDeclaration
s, where it is just a proxy for getTypedReference()
, so the existing code can just call that directly.
We need to remove this thing.
Given:
import ceylon.interop.java {
javaClassFromDeclaration
}
import ceylon.language.meta.model {
Interface,
Type
}
import java.lang {
ObjectArray,
JClass=Class
}
import java.lang.reflect {
Proxy,
InvocationHandler,
JMethod=Method
}
import java.util.\ifunction {
Predicate
}
shared void run() {
Predicate<String> p = wrap(`Predicate<String>`, (String s) => s.empty);
print("``p.test("")``, ``p.test("asdasd")``");
}
T wrap<T,out R,in A>(Type<T> t, R(A) fun) {
assert (is Interface<T> i = `T`);
value c = javaClassFromDeclaration(i.declaration);
value a = ObjectArray<JClass<out Object>>(1);
a.set(0, c);
object handler satisfies InvocationHandler {
shared actual Object? invoke(Object o, JMethod m, ObjectArray<Object> as) {
assert (as.size==1, is A a = as.get(0));
return fun(a) of Object?;
}
}
assert (is T p = Proxy.newProxyInstance(c.classLoader, a, handler));
return p;
}
I get:
ceylon run: Failed to resolve com.sun.proxy.$Proxy54
com.redhat.ceylon.model.loader.ModelResolutionException: Failed to resolve com.sun.proxy.$Proxy54
at com.redhat.ceylon.model.loader.AbstractModelLoader.convertToDeclaration(AbstractModelLoader.java:1643)
at com.redhat.ceylon.model.loader.AbstractModelLoader.convertToDeclaration(AbstractModelLoader.java:1602)
at com.redhat.ceylon.model.loader.AbstractModelLoader.getDeclaration(AbstractModelLoader.java:4886)
at com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor$Class.toProducedType(TypeDescriptor.java:309)
at com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor$Class.toType(TypeDescriptor.java:301)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getProducedType(Metamodel.java:378)
at com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor.is(TypeDescriptor.java:1361)
at com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor$Class.is(TypeDescriptor.java:263)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.isReified(Metamodel.java:344)
at com.redhat.ceylon.compiler.java.Util.isReified(Util.java:63)
at foo.wrap_.wrap(run.ceylon:38)
For some reason that I simply don't understand, after a couple of bites at the cherry, @chochos has still not been able to solve ceylon/ceylon-js#637.
But it strikes me that the backend is now the wrong place for this error checking to be done anyway. If the model loader where to mark Java stuff as native("jvm")
, wouldn't we get those checks for free, during typechecking?
This should be accepted by the typechecker:
void fun<T>(T t)
given T satisfies Summable<Float> {
Float float = t of Float;
}
In ceylon/ceylon-compiler#2356 we fixed the fact that native headers weren't reconstructed when loading the model but the heuristics aren't 100% correct (we assume anything native and shared has a header, which is true, but it ignores the fact that private elements may have headers too).
For a real fix we need to introduce some kind of marker annotation, let's say @NativeHeader
, which we can put on native declarations so the mode loader knows that it should construct a header.
In my opinion it would be great to use maven for retrieve dependencies (include your jar of junit it is... an outdated practice) and make this library available on Maven Central. You can easily do that using OSSHR Nexus. Let me know if I can help.
Missing expected token: CLOSE_PAR, got: WORD[=] at CeylonAstType(RedHatType, ceylon.language::Anything(com.redhat.ceylon.compiler.typechecker.tree::Node, ceylon.ast.core::Node)=)
(This is uncommitted ceylon.ast WIP; I’ll add an independent test case later.)
From a first look at the code it seems that you support building models through reflection but not from directly looking into jars without loading them? Am I wrong?
Reflection is bad for several reasons, the first one is that loading a class cause the static initializers to be executed and this is not necessarily what I would like to happen. Looking into a Jar would instead avoid these issues.
It would be also nice to build models directly from source code. It could be done starting from the output of JavaParser, for example.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.