@@ -34,36 +34,33 @@ internal fun loadProtocolSchemaDependencies(
34
34
): ParsedProtocolSchemaSet {
35
35
val dependencies = schema.taggedDependencies.entries
36
36
.associate { (tag, type) ->
37
- require(tag != 0 ) { " Dependency $type tag must be non-zero" }
38
- type to loadProtocolSchema(type, classLoader, tag)
37
+ require(tag in 1 .. MAX_SCHEMA_TAG ) {
38
+ " Dependency $type tag must be in range (0, $MAX_SCHEMA_TAG ]: $tag "
39
+ }
40
+ val dependency = loadProtocolSchema(type, classLoader)
41
+ .withTagOffset(tag * MAX_MEMBER_TAG )
42
+
43
+ require(dependency.dependencies.isEmpty()) {
44
+ " Schema dependency $type also has its own dependencies. " +
45
+ " For now, only a single level of dependencies is supported."
46
+ }
47
+
48
+ type to dependency
39
49
}
40
50
return ParsedProtocolSchemaSet (schema, dependencies)
41
51
}
42
52
43
53
internal fun loadProtocolSchema (
44
54
type : FqType ,
45
55
classLoader : ClassLoader ,
46
- tag : Int = 0,
47
56
): ProtocolSchema {
48
- require(tag in 0 .. MAX_SCHEMA_TAG ) {
49
- " $type tag must be 0 for the root or in range (0, $MAX_SCHEMA_TAG ] as a dependency: $tag "
50
- }
51
- val tagOffset = tag * MAX_MEMBER_TAG
52
-
53
57
val path = ParsedProtocolSchema .toEmbeddedPath(type)
54
- val schema = classLoader
58
+ return classLoader
55
59
.getResourceAsStream(path)
56
60
?.use(InputStream ::readBytes)
57
61
?.decodeToString()
58
- ?.let { json -> ParsedProtocolSchema .parseEmbeddedJson(json, tagOffset ) }
62
+ ?.let { json -> ParsedProtocolSchema .parseEmbeddedJson(json) }
59
63
? : throw IllegalArgumentException (" Unable to locate JSON for $type at $path " )
60
-
61
- require(tag == 0 || schema.dependencies.isEmpty()) {
62
- " Schema dependency $type also has its own dependencies. " +
63
- " For now, only a single level of dependencies is supported."
64
- }
65
-
66
- return schema
67
64
}
68
65
69
66
/* * Returns true if [memberType] is a known special modifier tag and name. */
0 commit comments