Align extern class member ids with runtime
This commit is contained in:
parent
ec64d7309c
commit
ac2a734998
@ -4626,6 +4626,21 @@ class Compiler(
|
||||
val st = try {
|
||||
classCtx?.let { ctx ->
|
||||
predeclareClassMembers(ctx.declaredMembers, ctx.memberOverrides)
|
||||
val existingExternInfo = if (isExtern) resolveCompileClassInfo(nameToken.value) else null
|
||||
if (existingExternInfo != null) {
|
||||
ctx.memberFieldIds.putAll(existingExternInfo.fieldIds)
|
||||
ctx.memberMethodIds.putAll(existingExternInfo.methodIds)
|
||||
ctx.nextFieldId = maxOf(ctx.nextFieldId, existingExternInfo.nextFieldId)
|
||||
ctx.nextMethodId = maxOf(ctx.nextMethodId, existingExternInfo.nextMethodId)
|
||||
for (member in ctx.declaredMembers) {
|
||||
val hasField = member in existingExternInfo.fieldIds
|
||||
val hasMethod = member in existingExternInfo.methodIds
|
||||
if (!hasField && !hasMethod) {
|
||||
throw ScriptError(nameToken.pos, "extern member $member is not found in runtime class ${nameToken.value}")
|
||||
}
|
||||
}
|
||||
compileClassInfos[nameToken.value] = existingExternInfo
|
||||
} else {
|
||||
val baseIds = collectBaseMemberIds(baseSpecs.map { it.name })
|
||||
ctx.memberFieldIds.putAll(baseIds.fieldIds)
|
||||
ctx.memberMethodIds.putAll(baseIds.methodIds)
|
||||
@ -4659,6 +4674,7 @@ class Compiler(
|
||||
nextMethodId = ctx.nextMethodId
|
||||
)
|
||||
}
|
||||
}
|
||||
withLocalNames(constructorArgsDeclaration?.params?.map { it.name }?.toSet() ?: emptySet()) {
|
||||
parseScript()
|
||||
}
|
||||
@ -4688,6 +4704,21 @@ class Compiler(
|
||||
}
|
||||
resolutionSink?.declareClass(nameToken.value, baseSpecs.map { it.name }, startPos)
|
||||
classCtx?.let { ctx ->
|
||||
val existingExternInfo = if (isExtern) resolveCompileClassInfo(nameToken.value) else null
|
||||
if (existingExternInfo != null) {
|
||||
ctx.memberFieldIds.putAll(existingExternInfo.fieldIds)
|
||||
ctx.memberMethodIds.putAll(existingExternInfo.methodIds)
|
||||
ctx.nextFieldId = maxOf(ctx.nextFieldId, existingExternInfo.nextFieldId)
|
||||
ctx.nextMethodId = maxOf(ctx.nextMethodId, existingExternInfo.nextMethodId)
|
||||
for (member in ctx.declaredMembers) {
|
||||
val hasField = member in existingExternInfo.fieldIds
|
||||
val hasMethod = member in existingExternInfo.methodIds
|
||||
if (!hasField && !hasMethod) {
|
||||
throw ScriptError(nameToken.pos, "extern member $member is not found in runtime class ${nameToken.value}")
|
||||
}
|
||||
}
|
||||
compileClassInfos[nameToken.value] = existingExternInfo
|
||||
} else {
|
||||
val baseIds = collectBaseMemberIds(baseSpecs.map { it.name })
|
||||
ctx.memberFieldIds.putAll(baseIds.fieldIds)
|
||||
ctx.memberMethodIds.putAll(baseIds.methodIds)
|
||||
@ -4721,6 +4752,7 @@ class Compiler(
|
||||
nextMethodId = ctx.nextMethodId
|
||||
)
|
||||
}
|
||||
}
|
||||
// restore if no body starts here
|
||||
cc.restorePos(saved)
|
||||
null
|
||||
|
||||
@ -10,6 +10,8 @@ extern class Delegate
|
||||
|
||||
extern class Iterable<T> {
|
||||
fun iterator(): Iterator<T>
|
||||
fun forEach(action: (T)->Void): Void
|
||||
fun map<R>(transform: (T)->R): List<R>
|
||||
fun toList(): List<T>
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user