Open OlegYch opened 13 years ago
What if you flip the processing order?
> scalaxb-0.6.7-SNAPSHOT Service2.wsdl Service3.wsdl
BaseProperty
is masked because it's duplicated. If the semantics are not identical, I don't know if I want to keep support it..
In this case it will work correctly: generate base trait and place all three types in one file.
I think it's a good idea to always generate the trait regardless of whether the type has subtypes. Looks like this way the issue would be resolved without much hassle.
Eventually there will be a better support via #53, but we can use last-win principle as a workaround. In case there is circular situation, you can always add the third wsdl at the end that repeats all inheritances.
I think it's a good idea to always generate the trait regardless of whether the type has subtypes.
Wouldn't that make the generated code more noisy?
It will, but it will also allow someone to define subtypes manually. And hopefully resolve this issue without resorting to modifying schemas (which are quite often regenerated). Maybe an option would be sufficient.
So, if there's a complex type called ipo:Address
, and scalaxb always generated Addressable
, all other complex types then need to refer to ipo:Address
as Addressable
in Scala code like:
trait Fooable {
val address: Addressable
}
case class Foo(address: Addressable) extends Fooable
and so on and so forth. This will make pattern matching annoying because you then need to make sure you're handling the sub type of Addressable
that may be written in the future.
foo match {
case Foo(Address(name, street, city)) =>
}
The above is no longer exhaustive. First, foo
may or may not be Foo
, and foo.address
may or may not be Address
.
Heh. Ensuring exhaustiveness in case of just one subtype is not a big deal. On the other hand currently traits are generated as not sealed so it becomes a problem when there are several subtypes anyway. That's actually another point for enhancement - you can add an option to generate sealed tratis so that compiler could check for exhaustiveness. Going back to the original issue of incorrect merging - i still think it should be fixed one way or another, because the goal of being able to generate valid code for a valid input imo is crucial.
the goal of being able to generate valid code for a valid input imo is crucial.
Right. In my opinion, the moment you have a duplicated types across the schemas, it's already invalid. I guess I could try to detect that the merged type needs trait or not, but this would be an enhancement, not a bug fix.
steps
compile two input files with the command
Service2.wsdl
Service3.wsdl
problem
Service3_type1.scala
Service2_type1.scala