Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Not found declaration in runtime while testing #682

Open
Podmev opened this issue Aug 15, 2017 · 0 comments
Open

Not found declaration in runtime while testing #682

Podmev opened this issue Aug 15, 2017 · 0 comments

Comments

@Podmev
Copy link

Podmev commented Aug 15, 2017

Strange bug when testing with ceylon test engine with unused method in test class when that method uses class from not directly imported module.
But when we run directly without test engine everything works.

Simple example. Suppose we have 3 modules: a, b, c.
Module b imports a and exports it (shared import), and module c imports module b. We test something in module c.

module a "1.0.0" {}
module b "1.0.0" {
    shared import a "1.0.0";
}
module c "1.0.0" {
    import b "1.0.0";
    import ceylon.test "1.3.2";
}

in module a we have class X:

shared class X(shared String s) {}

In module c we have testing class with unused method that uses class X.

import a {
    X
}

import ceylon.test {
    test,
    assertTrue
}
shared class TestClass() {
    X createUnusedX(String s) => X(s);

    test
    shared void trueTest(){
        assertTrue(true);
    }
}

after command in terminal

ceylon test --compile=force c/1.0.0

we have:

Source found for module c, compiling...
source/c/TestClass.ceylon:10: warning: declaration is never used: function 'createUnusedX' has no local references
X createUnusedX(String s) => X(s);
^
1 warning
Note: Created module c/1.0.0
ceylon test: Error while loading the c/1.0.0 module:
Declaration 'a.X' could not be found in module 'c' or its imported modules but was found in the non-imported module 'a'
com.redhat.ceylon.model.loader.ModelResolutionException: Error while loading the c/1.0.0 module:
Declaration 'a.X' could not be found in module 'c' or its imported modules but was found in the non-imported module 'a'
at com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader$2.reportError(RuntimeModelLoader.java:270)
at com.redhat.ceylon.model.typechecker.model.UnknownType.reportErrors(UnknownType.java:94)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getMetamodel(Metamodel.java:597)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.FunctionDeclarationImpl.(FunctionDeclarationImpl.java:65)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.getOrCreateMetamodel(Metamodel.java:402)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl.addDeclarationTo(ClassOrInterfaceDeclarationImpl.java:114)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl.init(ClassOrInterfaceDeclarationImpl.java:99)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassDeclarationImpl.init(ClassDeclarationImpl.java:59)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl.checkInit(ClassOrInterfaceDeclarationImpl.java:163)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl.filteredMembers(ClassOrInterfaceDeclarationImpl.java:231)
at com.redhat.ceylon.compiler.java.runtime.metamodel.decl.ClassOrInterfaceDeclarationImpl.annotatedMemberDeclarations(ClassOrInterfaceDeclarationImpl.java:205)
at ceylon.test.engine.findCandidatesInClass_.findCandidatesInClass(DefaultTestRunner.ceylon:261)
at ceylon.test.engine.findCandidatesInPackage_.findCandidatesInPackage(DefaultTestRunner.ceylon:255)
at ceylon.test.engine.findCandidatesInModule_.findCandidatesInModule(DefaultTestRunner.ceylon:246)
at ceylon.test.engine.findCandidates_.findCandidates(DefaultTestRunner.ceylon:225)
at ceylon.test.engine.createExecutors_.createExecutors(DefaultTestRunner.ceylon:135)
at ceylon.test.engine.DefaultTestRunner.initExecutors$priv$(DefaultTestRunner.ceylon:50)
at ceylon.test.engine.DefaultTestRunner.(DefaultTestRunner.ceylon:53)
at ceylon.test.engine.internal.Runner.run(Runner.ceylon:35)
at ceylon.test.runTestTool_.runTestTool(tool.ceylon:9)
at ceylon.test.runTestTool_.main(tool.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:498)
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:68)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:105)
at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:101)
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:498)
at org.jboss.modules.Module.run(Module.java:308)
at org.jboss.modules.Main.main(Main.java:487)
at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:355)
at ceylon.modules.bootstrap.CeylonTestTool.run(CeylonTestTool.java:127)
at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:547)
at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:423)
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:498)
at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:108)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:38)
at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:31)
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:498)
at com.redhat.ceylon.launcher.Bootstrap.runVersion(Bootstrap.java:162)
at com.redhat.ceylon.launcher.Bootstrap.runInternal(Bootstrap.java:117)
at com.redhat.ceylon.launcher.Bootstrap.run(Bootstrap.java:93)
at com.redhat.ceylon.launcher.Bootstrap.main(Bootstrap.java:85)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant