File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
main/scala-3/org/apache/flinkx/api
scala-2/org/apache/flinkx/api
scala-3/org/apache/flinkx/api Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ object TypeTagMacro:
1212 val flagsA = symA.flags
1313 val isModuleExpr = Expr (flagsA.is(Flags .Module ))
1414 val isCachableExpr = Expr (A match {
15+ // this type is not cachable if one of its type args is abstract
1516 case a : AppliedType => ! a.args.exists { t => t.typeSymbol.isAbstractType }
1617 case _ => true
1718 })
Original file line number Diff line number Diff line change @@ -36,14 +36,15 @@ class GenericCaseClassScala2Test extends AnyFlatSpec with should.Matchers {
3636
3737 if (classOf [Cat ].isAssignableFrom(aClass)) {
3838 aInfo should be theSameInstanceAs catInfo
39- aBasketInfo should be theSameInstanceAs catBasketInfo
39+ aBasketInfo should be theSameInstanceAs catBasketInfo // Type info of Basket[A] finds the cached type info of Basket[Cat]
4040 }
4141 if (classOf [Dog ].isAssignableFrom(aClass)) {
4242 aInfo should be theSameInstanceAs dogInfo
43- aBasketInfo should be theSameInstanceAs dogBasketInfo
43+ aBasketInfo should be theSameInstanceAs dogBasketInfo // Type info of Basket[A] finds the cached type info of Basket[Dog]
4444 }
4545 catBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs catInfo
4646 dogBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs dogInfo
47+ // Type info of Basket[A] holds a type info of the good type (Cat or Dog) found in the cache
4748 aBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs aInfo
4849 }
4950
Original file line number Diff line number Diff line change @@ -28,19 +28,20 @@ class GenericCaseClassScala3Test extends AnyFlatSpec with should.Matchers {
2828 val catBasketInfo : TypeInformation [Basket [Cat ]] = implicitly[TypeInformation [Basket [Cat ]]]
2929 // cacheKey=org.apache.flinkx.api.GenericCaseClassTest.Basket[org.apache.flinkx.api.GenericCaseClassTest.Dog] => OK
3030 val dogBasketInfo : TypeInformation [Basket [Dog ]] = implicitly[TypeInformation [Basket [Dog ]]]
31- // cacheKey=org.apache.flinkx.api.GenericCaseClassTest.Basket[A] => not cached
31+ // cacheKey=org.apache.flinkx.api.GenericCaseClassTest.Basket[A] => Basket[A] is not cachable
3232 val aBasketInfo : TypeInformation [Basket [A ]] = implicitly[TypeInformation [Basket [A ]]]
3333
3434 if (classOf [Cat ].isAssignableFrom(aClass)) {
3535 aInfo should be theSameInstanceAs catInfo
36- // aBasketInfo should be theSameInstanceAs catBasketInfo // Fails => aBasketInfo is not cached
36+ aBasketInfo shouldNot be theSameInstanceAs catBasketInfo // Basket[A] is not cachable
3737 }
3838 if (classOf [Dog ].isAssignableFrom(aClass)) {
3939 aInfo should be theSameInstanceAs dogInfo
40- // aBasketInfo should be theSameInstanceAs dogBasketInfo // Fails => aBasketInfo is not cached
40+ aBasketInfo shouldNot be theSameInstanceAs dogBasketInfo // Basket[A] is not cachable
4141 }
4242 catBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs catInfo
4343 dogBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs dogInfo
44+ // Type info of Basket[A] is not cached, but it holds a type info of the good type (Cat or Dog) found in the cache
4445 aBasketInfo.asInstanceOf [ProductTypeInformation [A ]].getFieldTypes()(0 ) should be theSameInstanceAs aInfo
4546 }
4647
You can’t perform that action at this time.
0 commit comments