Handle enclosing visibility + cache metadata parsing (#1026)

* Only allow public or internal classes

* Ensure consistent ordering of supertypes

* Eagerly load supertype typespecs for reuse

* Add regression test for https://github.com/square/moshi/issues/1022

* Add MoshiCachedClassInspector, wire in

* Check visibility of enclosed types too

Resolves #1022

* Fix comments
This commit is contained in:
Zac Sweers
2019-11-16 22:27:25 -05:00
committed by Jesse Wilson
parent ca207b2e06
commit 4241918d6b
6 changed files with 136 additions and 44 deletions

View File

@@ -1171,6 +1171,20 @@ class GeneratedAdaptersTest {
}
}
// Regression test for https://github.com/square/moshi/issues/1022
// Compile-only test
@JsonClass(generateAdapter = true)
internal data class MismatchParentAndNestedClassVisibility(
val type: Int,
val name: String? = null
) {
@JsonClass(generateAdapter = true)
data class NestedClass(
val nestedProperty: String
)
}
// Has to be outside to avoid Types seeing an owning class
@JsonClass(generateAdapter = true)
data class NullableTypeParams<T>(