Closed jvasileff closed 5 years ago
The sample project - bug7383.zip
This is one reason why Java infers implicit constraints for wildcards. Not saying y'all should do that - it's just interesting to see an example in practice.
So I don't know why the Java backend canonicalizes types in TypeInfo
annotations, and I think it's wrong that it does. The offending line of code is AbstractTransformer:3746
.
@jvasileff could you check that be37326 fixes the problem please?
I don't have anything except the sample project, so if ceylon compile lib && ceylon compile app
works I guess were good.
OK, @jvasileff, great, closing.
The intersection of a type parameter and its upper bound constraints simplifies to just the type parameter. For example, the intersection of
T satisfies Object
andObject
(T & Object
) is "just"T
.However, "redundant" intersection components are meaningful when substituting a type that is not a subtype of
T
's upper bound constraints intoT
. For example, after substituting an unconstrainedU
intoT
for use in the expressionT & Object
, the result will beU & Object
, not "just"U
as it would be for the simplified expressionT
.The "simplification" of types like
T & Object
is unintentionally material, and inconsistently performing type simplifications can produce inconsistent results.An example of this on the JVM backend is when a type like
T & Object
is used as the type of ashared
member. It is not simplified for code that is compiled at the same time, but it is simplified in the stored model used for future compiles.The attached two-module project demonstrates this. Compiling the modules at the same time works:
but compiling separately fails:
The relevant code in module
lib
is:and in
app
: