What am I missing here: ```// /vendor/org/group/a...
# adobe
a
What am I missing here:
Copy code
// /vendor/org/group/app2/Parent.cfc (/org mapping points to /vendor/org)
component {}


// /vendor/com/corp/app1/Child.cfc  (/com mapping points to /vendor/com)
import org.group.app2.Parent
component extends=Parent {}


// /vendor/me/test.cfm
<cfscript>
import org.group.app2.Parent
import com.corp.app1.Child

p = new Parent()
writeOutput(getMetadata(p).fullName) // org.group.app2.Parent

c = new Child() // errors with Could not find the ColdFusion component or interface Parent.
</cfscript>
If I change Child.cfc to be:
Copy code
// /com/corp/app1/Child.cfc
component extends=org.group.app2.Parent{}
It works. So it's not like CF can't find the CFCs in question. It's just not... looking.
Also relevant is the
import
statements are clearly working in the
test.cfm
file otherwise I'd not be able to create the
Parent
instance at all. 😐
t
I've found that import doesn't work for extends at all.
😡 1
really, the implementation generally seems kind of half-assed. I had to file a bug to get it to work with typed arrays. And it doesn't play nice with interfaces either.
Copy code
/** some.package.interfaces.Component */
interface {
   function some.other.package.interface ReturnInterface doSomething(InputInterface);
}
----------
import some.other.package.interface.*
/** some.package.implementation */
component implements="some.package.interfaces.Component" {
   function ReturnInterface doSomething(InputInterface) {}
complains because "some.other.packaage.interface.ReturnInterface" and "ReturnInterface" (imported from some.other.package.interface) are "not the same."
it's like it's doing type checking via string comparison.
a
It wouldn't f***in surprise me.
s
should import work for a class that’s extending another? I’d have thought that the import is for the parent…no?
a
import
statements are always local to the file that needs the the resource located. They do not consider how files interact / interrelate. An import is basically telling the rest of the code in that file where to find external resources.
t
I've gotten mixed results with that though... I haven't played with it to try and figure out the exact behavior, but I have a hunch that importing in the parent applies to the child too. But perhaps only starting in cf2018....